babylon.module.d.ts 5.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145
  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<void>;
  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 _skipFrustumClipping;
  35954. /**
  35955. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35956. */
  35957. set skipFrustumClipping(value: boolean);
  35958. get skipFrustumClipping(): boolean;
  35959. private _forcePointsCloud;
  35960. /**
  35961. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35962. */
  35963. set forcePointsCloud(value: boolean);
  35964. get forcePointsCloud(): boolean;
  35965. /**
  35966. * Gets or sets the active clipplane 1
  35967. */
  35968. clipPlane: Nullable<Plane>;
  35969. /**
  35970. * Gets or sets the active clipplane 2
  35971. */
  35972. clipPlane2: Nullable<Plane>;
  35973. /**
  35974. * Gets or sets the active clipplane 3
  35975. */
  35976. clipPlane3: Nullable<Plane>;
  35977. /**
  35978. * Gets or sets the active clipplane 4
  35979. */
  35980. clipPlane4: Nullable<Plane>;
  35981. /**
  35982. * Gets or sets the active clipplane 5
  35983. */
  35984. clipPlane5: Nullable<Plane>;
  35985. /**
  35986. * Gets or sets the active clipplane 6
  35987. */
  35988. clipPlane6: Nullable<Plane>;
  35989. /**
  35990. * Gets or sets a boolean indicating if animations are enabled
  35991. */
  35992. animationsEnabled: boolean;
  35993. private _animationPropertiesOverride;
  35994. /**
  35995. * Gets or sets the animation properties override
  35996. */
  35997. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35998. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35999. /**
  36000. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36001. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36002. */
  36003. useConstantAnimationDeltaTime: boolean;
  36004. /**
  36005. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36006. * Please note that it requires to run a ray cast through the scene on every frame
  36007. */
  36008. constantlyUpdateMeshUnderPointer: boolean;
  36009. /**
  36010. * Defines the HTML cursor to use when hovering over interactive elements
  36011. */
  36012. hoverCursor: string;
  36013. /**
  36014. * Defines the HTML default cursor to use (empty by default)
  36015. */
  36016. defaultCursor: string;
  36017. /**
  36018. * Defines wether cursors are handled by the scene.
  36019. */
  36020. doNotHandleCursors: boolean;
  36021. /**
  36022. * This is used to call preventDefault() on pointer down
  36023. * in order to block unwanted artifacts like system double clicks
  36024. */
  36025. preventDefaultOnPointerDown: boolean;
  36026. /**
  36027. * This is used to call preventDefault() on pointer up
  36028. * in order to block unwanted artifacts like system double clicks
  36029. */
  36030. preventDefaultOnPointerUp: boolean;
  36031. /**
  36032. * Gets or sets user defined metadata
  36033. */
  36034. metadata: any;
  36035. /**
  36036. * For internal use only. Please do not use.
  36037. */
  36038. reservedDataStore: any;
  36039. /**
  36040. * Gets the name of the plugin used to load this scene (null by default)
  36041. */
  36042. loadingPluginName: string;
  36043. /**
  36044. * Use this array to add regular expressions used to disable offline support for specific urls
  36045. */
  36046. disableOfflineSupportExceptionRules: RegExp[];
  36047. /**
  36048. * An event triggered when the scene is disposed.
  36049. */
  36050. onDisposeObservable: Observable<Scene>;
  36051. private _onDisposeObserver;
  36052. /** Sets a function to be executed when this scene is disposed. */
  36053. set onDispose(callback: () => void);
  36054. /**
  36055. * An event triggered before rendering the scene (right after animations and physics)
  36056. */
  36057. onBeforeRenderObservable: Observable<Scene>;
  36058. private _onBeforeRenderObserver;
  36059. /** Sets a function to be executed before rendering this scene */
  36060. set beforeRender(callback: Nullable<() => void>);
  36061. /**
  36062. * An event triggered after rendering the scene
  36063. */
  36064. onAfterRenderObservable: Observable<Scene>;
  36065. /**
  36066. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36067. */
  36068. onAfterRenderCameraObservable: Observable<Camera>;
  36069. private _onAfterRenderObserver;
  36070. /** Sets a function to be executed after rendering this scene */
  36071. set afterRender(callback: Nullable<() => void>);
  36072. /**
  36073. * An event triggered before animating the scene
  36074. */
  36075. onBeforeAnimationsObservable: Observable<Scene>;
  36076. /**
  36077. * An event triggered after animations processing
  36078. */
  36079. onAfterAnimationsObservable: Observable<Scene>;
  36080. /**
  36081. * An event triggered before draw calls are ready to be sent
  36082. */
  36083. onBeforeDrawPhaseObservable: Observable<Scene>;
  36084. /**
  36085. * An event triggered after draw calls have been sent
  36086. */
  36087. onAfterDrawPhaseObservable: Observable<Scene>;
  36088. /**
  36089. * An event triggered when the scene is ready
  36090. */
  36091. onReadyObservable: Observable<Scene>;
  36092. /**
  36093. * An event triggered before rendering a camera
  36094. */
  36095. onBeforeCameraRenderObservable: Observable<Camera>;
  36096. private _onBeforeCameraRenderObserver;
  36097. /** Sets a function to be executed before rendering a camera*/
  36098. set beforeCameraRender(callback: () => void);
  36099. /**
  36100. * An event triggered after rendering a camera
  36101. */
  36102. onAfterCameraRenderObservable: Observable<Camera>;
  36103. private _onAfterCameraRenderObserver;
  36104. /** Sets a function to be executed after rendering a camera*/
  36105. set afterCameraRender(callback: () => void);
  36106. /**
  36107. * An event triggered when active meshes evaluation is about to start
  36108. */
  36109. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36110. /**
  36111. * An event triggered when active meshes evaluation is done
  36112. */
  36113. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36114. /**
  36115. * An event triggered when particles rendering is about to start
  36116. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36117. */
  36118. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36119. /**
  36120. * An event triggered when particles rendering is done
  36121. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36122. */
  36123. onAfterParticlesRenderingObservable: Observable<Scene>;
  36124. /**
  36125. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36126. */
  36127. onDataLoadedObservable: Observable<Scene>;
  36128. /**
  36129. * An event triggered when a camera is created
  36130. */
  36131. onNewCameraAddedObservable: Observable<Camera>;
  36132. /**
  36133. * An event triggered when a camera is removed
  36134. */
  36135. onCameraRemovedObservable: Observable<Camera>;
  36136. /**
  36137. * An event triggered when a light is created
  36138. */
  36139. onNewLightAddedObservable: Observable<Light>;
  36140. /**
  36141. * An event triggered when a light is removed
  36142. */
  36143. onLightRemovedObservable: Observable<Light>;
  36144. /**
  36145. * An event triggered when a geometry is created
  36146. */
  36147. onNewGeometryAddedObservable: Observable<Geometry>;
  36148. /**
  36149. * An event triggered when a geometry is removed
  36150. */
  36151. onGeometryRemovedObservable: Observable<Geometry>;
  36152. /**
  36153. * An event triggered when a transform node is created
  36154. */
  36155. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36156. /**
  36157. * An event triggered when a transform node is removed
  36158. */
  36159. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36160. /**
  36161. * An event triggered when a mesh is created
  36162. */
  36163. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36164. /**
  36165. * An event triggered when a mesh is removed
  36166. */
  36167. onMeshRemovedObservable: Observable<AbstractMesh>;
  36168. /**
  36169. * An event triggered when a skeleton is created
  36170. */
  36171. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36172. /**
  36173. * An event triggered when a skeleton is removed
  36174. */
  36175. onSkeletonRemovedObservable: Observable<Skeleton>;
  36176. /**
  36177. * An event triggered when a material is created
  36178. */
  36179. onNewMaterialAddedObservable: Observable<Material>;
  36180. /**
  36181. * An event triggered when a material is removed
  36182. */
  36183. onMaterialRemovedObservable: Observable<Material>;
  36184. /**
  36185. * An event triggered when a texture is created
  36186. */
  36187. onNewTextureAddedObservable: Observable<BaseTexture>;
  36188. /**
  36189. * An event triggered when a texture is removed
  36190. */
  36191. onTextureRemovedObservable: Observable<BaseTexture>;
  36192. /**
  36193. * An event triggered when render targets are about to be rendered
  36194. * Can happen multiple times per frame.
  36195. */
  36196. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36197. /**
  36198. * An event triggered when render targets were rendered.
  36199. * Can happen multiple times per frame.
  36200. */
  36201. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36202. /**
  36203. * An event triggered before calculating deterministic simulation step
  36204. */
  36205. onBeforeStepObservable: Observable<Scene>;
  36206. /**
  36207. * An event triggered after calculating deterministic simulation step
  36208. */
  36209. onAfterStepObservable: Observable<Scene>;
  36210. /**
  36211. * An event triggered when the activeCamera property is updated
  36212. */
  36213. onActiveCameraChanged: Observable<Scene>;
  36214. /**
  36215. * This Observable will be triggered before 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. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36220. /**
  36221. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36222. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36223. * 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)
  36224. */
  36225. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36226. /**
  36227. * This Observable will when a mesh has been imported into the scene.
  36228. */
  36229. onMeshImportedObservable: Observable<AbstractMesh>;
  36230. /**
  36231. * This Observable will when an animation file has been imported into the scene.
  36232. */
  36233. onAnimationFileImportedObservable: Observable<Scene>;
  36234. /**
  36235. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36236. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36237. */
  36238. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36239. /** @hidden */
  36240. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36241. /**
  36242. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36243. */
  36244. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36245. /**
  36246. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36247. */
  36248. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36249. /**
  36250. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36251. */
  36252. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36253. /** Callback called when a pointer move is detected */
  36254. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36255. /** Callback called when a pointer down is detected */
  36256. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36257. /** Callback called when a pointer up is detected */
  36258. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36259. /** Callback called when a pointer pick is detected */
  36260. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36261. /**
  36262. * 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).
  36263. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36264. */
  36265. onPrePointerObservable: Observable<PointerInfoPre>;
  36266. /**
  36267. * Observable event triggered each time an input event is received from the rendering canvas
  36268. */
  36269. onPointerObservable: Observable<PointerInfo>;
  36270. /**
  36271. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36272. */
  36273. get unTranslatedPointer(): Vector2;
  36274. /**
  36275. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36276. */
  36277. static get DragMovementThreshold(): number;
  36278. static set DragMovementThreshold(value: number);
  36279. /**
  36280. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36281. */
  36282. static get LongPressDelay(): number;
  36283. static set LongPressDelay(value: number);
  36284. /**
  36285. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36286. */
  36287. static get DoubleClickDelay(): number;
  36288. static set DoubleClickDelay(value: number);
  36289. /** If you need to check double click without raising a single click at first click, enable this flag */
  36290. static get ExclusiveDoubleClickMode(): boolean;
  36291. static set ExclusiveDoubleClickMode(value: boolean);
  36292. /** @hidden */
  36293. _mirroredCameraPosition: Nullable<Vector3>;
  36294. /**
  36295. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36296. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36297. */
  36298. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36299. /**
  36300. * Observable event triggered each time an keyboard event is received from the hosting window
  36301. */
  36302. onKeyboardObservable: Observable<KeyboardInfo>;
  36303. private _useRightHandedSystem;
  36304. /**
  36305. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36306. */
  36307. set useRightHandedSystem(value: boolean);
  36308. get useRightHandedSystem(): boolean;
  36309. private _timeAccumulator;
  36310. private _currentStepId;
  36311. private _currentInternalStep;
  36312. /**
  36313. * Sets the step Id used by deterministic lock step
  36314. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36315. * @param newStepId defines the step Id
  36316. */
  36317. setStepId(newStepId: number): void;
  36318. /**
  36319. * Gets the step Id used by deterministic lock step
  36320. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36321. * @returns the step Id
  36322. */
  36323. getStepId(): number;
  36324. /**
  36325. * Gets the internal step used by deterministic lock step
  36326. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36327. * @returns the internal step
  36328. */
  36329. getInternalStep(): number;
  36330. private _fogEnabled;
  36331. /**
  36332. * Gets or sets a boolean indicating if fog is enabled on this scene
  36333. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36334. * (Default is true)
  36335. */
  36336. set fogEnabled(value: boolean);
  36337. get fogEnabled(): boolean;
  36338. private _fogMode;
  36339. /**
  36340. * Gets or sets the fog mode to use
  36341. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36342. * | mode | value |
  36343. * | --- | --- |
  36344. * | FOGMODE_NONE | 0 |
  36345. * | FOGMODE_EXP | 1 |
  36346. * | FOGMODE_EXP2 | 2 |
  36347. * | FOGMODE_LINEAR | 3 |
  36348. */
  36349. set fogMode(value: number);
  36350. get fogMode(): number;
  36351. /**
  36352. * Gets or sets the fog color to use
  36353. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36354. * (Default is Color3(0.2, 0.2, 0.3))
  36355. */
  36356. fogColor: Color3;
  36357. /**
  36358. * Gets or sets the fog density to use
  36359. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36360. * (Default is 0.1)
  36361. */
  36362. fogDensity: number;
  36363. /**
  36364. * Gets or sets the fog start distance to use
  36365. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36366. * (Default is 0)
  36367. */
  36368. fogStart: number;
  36369. /**
  36370. * Gets or sets the fog end distance to use
  36371. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36372. * (Default is 1000)
  36373. */
  36374. fogEnd: number;
  36375. private _shadowsEnabled;
  36376. /**
  36377. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36378. */
  36379. set shadowsEnabled(value: boolean);
  36380. get shadowsEnabled(): boolean;
  36381. private _lightsEnabled;
  36382. /**
  36383. * Gets or sets a boolean indicating if lights are enabled on this scene
  36384. */
  36385. set lightsEnabled(value: boolean);
  36386. get lightsEnabled(): boolean;
  36387. /** All of the active cameras added to this scene. */
  36388. activeCameras: Camera[];
  36389. /** @hidden */
  36390. _activeCamera: Nullable<Camera>;
  36391. /** Gets or sets the current active camera */
  36392. get activeCamera(): Nullable<Camera>;
  36393. set activeCamera(value: Nullable<Camera>);
  36394. private _defaultMaterial;
  36395. /** The default material used on meshes when no material is affected */
  36396. get defaultMaterial(): Material;
  36397. /** The default material used on meshes when no material is affected */
  36398. set defaultMaterial(value: Material);
  36399. private _texturesEnabled;
  36400. /**
  36401. * Gets or sets a boolean indicating if textures are enabled on this scene
  36402. */
  36403. set texturesEnabled(value: boolean);
  36404. get texturesEnabled(): boolean;
  36405. /**
  36406. * Gets or sets a boolean indicating if particles are enabled on this scene
  36407. */
  36408. particlesEnabled: boolean;
  36409. /**
  36410. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36411. */
  36412. spritesEnabled: boolean;
  36413. private _skeletonsEnabled;
  36414. /**
  36415. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36416. */
  36417. set skeletonsEnabled(value: boolean);
  36418. get skeletonsEnabled(): boolean;
  36419. /**
  36420. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36421. */
  36422. lensFlaresEnabled: boolean;
  36423. /**
  36424. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36426. */
  36427. collisionsEnabled: boolean;
  36428. private _collisionCoordinator;
  36429. /** @hidden */
  36430. get collisionCoordinator(): ICollisionCoordinator;
  36431. /**
  36432. * Defines the gravity applied to this scene (used only for collisions)
  36433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36434. */
  36435. gravity: Vector3;
  36436. /**
  36437. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36438. */
  36439. postProcessesEnabled: boolean;
  36440. /**
  36441. * The list of postprocesses added to the scene
  36442. */
  36443. postProcesses: PostProcess[];
  36444. /**
  36445. * Gets the current postprocess manager
  36446. */
  36447. postProcessManager: PostProcessManager;
  36448. /**
  36449. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36450. */
  36451. renderTargetsEnabled: boolean;
  36452. /**
  36453. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36454. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36455. */
  36456. dumpNextRenderTargets: boolean;
  36457. /**
  36458. * The list of user defined render targets added to the scene
  36459. */
  36460. customRenderTargets: RenderTargetTexture[];
  36461. /**
  36462. * Defines if texture loading must be delayed
  36463. * If true, textures will only be loaded when they need to be rendered
  36464. */
  36465. useDelayedTextureLoading: boolean;
  36466. /**
  36467. * Gets the list of meshes imported to the scene through SceneLoader
  36468. */
  36469. importedMeshesFiles: String[];
  36470. /**
  36471. * Gets or sets a boolean indicating if probes are enabled on this scene
  36472. */
  36473. probesEnabled: boolean;
  36474. /**
  36475. * Gets or sets the current offline provider to use to store scene data
  36476. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36477. */
  36478. offlineProvider: IOfflineProvider;
  36479. /**
  36480. * Gets or sets the action manager associated with the scene
  36481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36482. */
  36483. actionManager: AbstractActionManager;
  36484. private _meshesForIntersections;
  36485. /**
  36486. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36487. */
  36488. proceduralTexturesEnabled: boolean;
  36489. private _engine;
  36490. private _totalVertices;
  36491. /** @hidden */
  36492. _activeIndices: PerfCounter;
  36493. /** @hidden */
  36494. _activeParticles: PerfCounter;
  36495. /** @hidden */
  36496. _activeBones: PerfCounter;
  36497. private _animationRatio;
  36498. /** @hidden */
  36499. _animationTimeLast: number;
  36500. /** @hidden */
  36501. _animationTime: number;
  36502. /**
  36503. * Gets or sets a general scale for animation speed
  36504. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36505. */
  36506. animationTimeScale: number;
  36507. /** @hidden */
  36508. _cachedMaterial: Nullable<Material>;
  36509. /** @hidden */
  36510. _cachedEffect: Nullable<Effect>;
  36511. /** @hidden */
  36512. _cachedVisibility: Nullable<number>;
  36513. private _renderId;
  36514. private _frameId;
  36515. private _executeWhenReadyTimeoutId;
  36516. private _intermediateRendering;
  36517. private _viewUpdateFlag;
  36518. private _projectionUpdateFlag;
  36519. /** @hidden */
  36520. _toBeDisposed: Nullable<IDisposable>[];
  36521. private _activeRequests;
  36522. /** @hidden */
  36523. _pendingData: any[];
  36524. private _isDisposed;
  36525. /**
  36526. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36527. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36528. */
  36529. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36530. private _activeMeshes;
  36531. private _processedMaterials;
  36532. private _renderTargets;
  36533. /** @hidden */
  36534. _activeParticleSystems: SmartArray<IParticleSystem>;
  36535. private _activeSkeletons;
  36536. private _softwareSkinnedMeshes;
  36537. private _renderingManager;
  36538. /** @hidden */
  36539. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36540. private _transformMatrix;
  36541. private _sceneUbo;
  36542. /** @hidden */
  36543. _viewMatrix: Matrix;
  36544. private _projectionMatrix;
  36545. /** @hidden */
  36546. _forcedViewPosition: Nullable<Vector3>;
  36547. /** @hidden */
  36548. _frustumPlanes: Plane[];
  36549. /**
  36550. * Gets the list of frustum planes (built from the active camera)
  36551. */
  36552. get frustumPlanes(): Plane[];
  36553. /**
  36554. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36555. * This is useful if there are more lights that the maximum simulteanous authorized
  36556. */
  36557. requireLightSorting: boolean;
  36558. /** @hidden */
  36559. readonly useMaterialMeshMap: boolean;
  36560. /** @hidden */
  36561. readonly useClonedMeshhMap: boolean;
  36562. private _externalData;
  36563. private _uid;
  36564. /**
  36565. * @hidden
  36566. * Backing store of defined scene components.
  36567. */
  36568. _components: ISceneComponent[];
  36569. /**
  36570. * @hidden
  36571. * Backing store of defined scene components.
  36572. */
  36573. _serializableComponents: ISceneSerializableComponent[];
  36574. /**
  36575. * List of components to register on the next registration step.
  36576. */
  36577. private _transientComponents;
  36578. /**
  36579. * Registers the transient components if needed.
  36580. */
  36581. private _registerTransientComponents;
  36582. /**
  36583. * @hidden
  36584. * Add a component to the scene.
  36585. * Note that the ccomponent could be registered on th next frame if this is called after
  36586. * the register component stage.
  36587. * @param component Defines the component to add to the scene
  36588. */
  36589. _addComponent(component: ISceneComponent): void;
  36590. /**
  36591. * @hidden
  36592. * Gets a component from the scene.
  36593. * @param name defines the name of the component to retrieve
  36594. * @returns the component or null if not present
  36595. */
  36596. _getComponent(name: string): Nullable<ISceneComponent>;
  36597. /**
  36598. * @hidden
  36599. * Defines the actions happening before camera updates.
  36600. */
  36601. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36602. /**
  36603. * @hidden
  36604. * Defines the actions happening before clear the canvas.
  36605. */
  36606. _beforeClearStage: Stage<SimpleStageAction>;
  36607. /**
  36608. * @hidden
  36609. * Defines the actions when collecting render targets for the frame.
  36610. */
  36611. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36612. /**
  36613. * @hidden
  36614. * Defines the actions happening for one camera in the frame.
  36615. */
  36616. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36617. /**
  36618. * @hidden
  36619. * Defines the actions happening during the per mesh ready checks.
  36620. */
  36621. _isReadyForMeshStage: Stage<MeshStageAction>;
  36622. /**
  36623. * @hidden
  36624. * Defines the actions happening before evaluate active mesh checks.
  36625. */
  36626. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36627. /**
  36628. * @hidden
  36629. * Defines the actions happening during the evaluate sub mesh checks.
  36630. */
  36631. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36632. /**
  36633. * @hidden
  36634. * Defines the actions happening during the active mesh stage.
  36635. */
  36636. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36637. /**
  36638. * @hidden
  36639. * Defines the actions happening during the per camera render target step.
  36640. */
  36641. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36642. /**
  36643. * @hidden
  36644. * Defines the actions happening just before the active camera is drawing.
  36645. */
  36646. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36647. /**
  36648. * @hidden
  36649. * Defines the actions happening just before a render target is drawing.
  36650. */
  36651. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36652. /**
  36653. * @hidden
  36654. * Defines the actions happening just before a rendering group is drawing.
  36655. */
  36656. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36657. /**
  36658. * @hidden
  36659. * Defines the actions happening just before a mesh is drawing.
  36660. */
  36661. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36662. /**
  36663. * @hidden
  36664. * Defines the actions happening just after a mesh has been drawn.
  36665. */
  36666. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36667. /**
  36668. * @hidden
  36669. * Defines the actions happening just after a rendering group has been drawn.
  36670. */
  36671. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36672. /**
  36673. * @hidden
  36674. * Defines the actions happening just after the active camera has been drawn.
  36675. */
  36676. _afterCameraDrawStage: Stage<CameraStageAction>;
  36677. /**
  36678. * @hidden
  36679. * Defines the actions happening just after a render target has been drawn.
  36680. */
  36681. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36682. /**
  36683. * @hidden
  36684. * Defines the actions happening just after rendering all cameras and computing intersections.
  36685. */
  36686. _afterRenderStage: Stage<SimpleStageAction>;
  36687. /**
  36688. * @hidden
  36689. * Defines the actions happening when a pointer move event happens.
  36690. */
  36691. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36692. /**
  36693. * @hidden
  36694. * Defines the actions happening when a pointer down event happens.
  36695. */
  36696. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36697. /**
  36698. * @hidden
  36699. * Defines the actions happening when a pointer up event happens.
  36700. */
  36701. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36702. /**
  36703. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36704. */
  36705. private geometriesByUniqueId;
  36706. /**
  36707. * Creates a new Scene
  36708. * @param engine defines the engine to use to render this scene
  36709. * @param options defines the scene options
  36710. */
  36711. constructor(engine: Engine, options?: SceneOptions);
  36712. /**
  36713. * Gets a string idenfifying the name of the class
  36714. * @returns "Scene" string
  36715. */
  36716. getClassName(): string;
  36717. private _defaultMeshCandidates;
  36718. /**
  36719. * @hidden
  36720. */
  36721. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36722. private _defaultSubMeshCandidates;
  36723. /**
  36724. * @hidden
  36725. */
  36726. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36727. /**
  36728. * Sets the default candidate providers for the scene.
  36729. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36730. * and getCollidingSubMeshCandidates to their default function
  36731. */
  36732. setDefaultCandidateProviders(): void;
  36733. /**
  36734. * Gets the mesh that is currently under the pointer
  36735. */
  36736. get meshUnderPointer(): Nullable<AbstractMesh>;
  36737. /**
  36738. * Gets or sets the current on-screen X position of the pointer
  36739. */
  36740. get pointerX(): number;
  36741. set pointerX(value: number);
  36742. /**
  36743. * Gets or sets the current on-screen Y position of the pointer
  36744. */
  36745. get pointerY(): number;
  36746. set pointerY(value: number);
  36747. /**
  36748. * Gets the cached material (ie. the latest rendered one)
  36749. * @returns the cached material
  36750. */
  36751. getCachedMaterial(): Nullable<Material>;
  36752. /**
  36753. * Gets the cached effect (ie. the latest rendered one)
  36754. * @returns the cached effect
  36755. */
  36756. getCachedEffect(): Nullable<Effect>;
  36757. /**
  36758. * Gets the cached visibility state (ie. the latest rendered one)
  36759. * @returns the cached visibility state
  36760. */
  36761. getCachedVisibility(): Nullable<number>;
  36762. /**
  36763. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36764. * @param material defines the current material
  36765. * @param effect defines the current effect
  36766. * @param visibility defines the current visibility state
  36767. * @returns true if one parameter is not cached
  36768. */
  36769. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36770. /**
  36771. * Gets the engine associated with the scene
  36772. * @returns an Engine
  36773. */
  36774. getEngine(): Engine;
  36775. /**
  36776. * Gets the total number of vertices rendered per frame
  36777. * @returns the total number of vertices rendered per frame
  36778. */
  36779. getTotalVertices(): number;
  36780. /**
  36781. * Gets the performance counter for total vertices
  36782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36783. */
  36784. get totalVerticesPerfCounter(): PerfCounter;
  36785. /**
  36786. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36787. * @returns the total number of active indices rendered per frame
  36788. */
  36789. getActiveIndices(): number;
  36790. /**
  36791. * Gets the performance counter for active indices
  36792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36793. */
  36794. get totalActiveIndicesPerfCounter(): PerfCounter;
  36795. /**
  36796. * Gets the total number of active particles rendered per frame
  36797. * @returns the total number of active particles rendered per frame
  36798. */
  36799. getActiveParticles(): number;
  36800. /**
  36801. * Gets the performance counter for active particles
  36802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36803. */
  36804. get activeParticlesPerfCounter(): PerfCounter;
  36805. /**
  36806. * Gets the total number of active bones rendered per frame
  36807. * @returns the total number of active bones rendered per frame
  36808. */
  36809. getActiveBones(): number;
  36810. /**
  36811. * Gets the performance counter for active bones
  36812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36813. */
  36814. get activeBonesPerfCounter(): PerfCounter;
  36815. /**
  36816. * Gets the array of active meshes
  36817. * @returns an array of AbstractMesh
  36818. */
  36819. getActiveMeshes(): SmartArray<AbstractMesh>;
  36820. /**
  36821. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36822. * @returns a number
  36823. */
  36824. getAnimationRatio(): number;
  36825. /**
  36826. * Gets an unique Id for the current render phase
  36827. * @returns a number
  36828. */
  36829. getRenderId(): number;
  36830. /**
  36831. * Gets an unique Id for the current frame
  36832. * @returns a number
  36833. */
  36834. getFrameId(): number;
  36835. /** Call this function if you want to manually increment the render Id*/
  36836. incrementRenderId(): void;
  36837. private _createUbo;
  36838. /**
  36839. * Use this method to simulate a pointer move on a mesh
  36840. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36841. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36842. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36843. * @returns the current scene
  36844. */
  36845. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36846. /**
  36847. * Use this method to simulate a pointer down on a mesh
  36848. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36849. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36850. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36851. * @returns the current scene
  36852. */
  36853. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36854. /**
  36855. * Use this method to simulate a pointer up on a mesh
  36856. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36857. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36858. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36859. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36860. * @returns the current scene
  36861. */
  36862. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36863. /**
  36864. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36865. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36866. * @returns true if the pointer was captured
  36867. */
  36868. isPointerCaptured(pointerId?: number): boolean;
  36869. /**
  36870. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36871. * @param attachUp defines if you want to attach events to pointerup
  36872. * @param attachDown defines if you want to attach events to pointerdown
  36873. * @param attachMove defines if you want to attach events to pointermove
  36874. */
  36875. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36876. /** Detaches all event handlers*/
  36877. detachControl(): void;
  36878. /**
  36879. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36880. * Delay loaded resources are not taking in account
  36881. * @return true if all required resources are ready
  36882. */
  36883. isReady(): boolean;
  36884. /** Resets all cached information relative to material (including effect and visibility) */
  36885. resetCachedMaterial(): void;
  36886. /**
  36887. * Registers a function to be called before every frame render
  36888. * @param func defines the function to register
  36889. */
  36890. registerBeforeRender(func: () => void): void;
  36891. /**
  36892. * Unregisters a function called before every frame render
  36893. * @param func defines the function to unregister
  36894. */
  36895. unregisterBeforeRender(func: () => void): void;
  36896. /**
  36897. * Registers a function to be called after every frame render
  36898. * @param func defines the function to register
  36899. */
  36900. registerAfterRender(func: () => void): void;
  36901. /**
  36902. * Unregisters a function called after every frame render
  36903. * @param func defines the function to unregister
  36904. */
  36905. unregisterAfterRender(func: () => void): void;
  36906. private _executeOnceBeforeRender;
  36907. /**
  36908. * The provided function will run before render once and will be disposed afterwards.
  36909. * A timeout delay can be provided so that the function will be executed in N ms.
  36910. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36911. * @param func The function to be executed.
  36912. * @param timeout optional delay in ms
  36913. */
  36914. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36915. /** @hidden */
  36916. _addPendingData(data: any): void;
  36917. /** @hidden */
  36918. _removePendingData(data: any): void;
  36919. /**
  36920. * Returns the number of items waiting to be loaded
  36921. * @returns the number of items waiting to be loaded
  36922. */
  36923. getWaitingItemsCount(): number;
  36924. /**
  36925. * Returns a boolean indicating if the scene is still loading data
  36926. */
  36927. get isLoading(): boolean;
  36928. /**
  36929. * Registers a function to be executed when the scene is ready
  36930. * @param {Function} func - the function to be executed
  36931. */
  36932. executeWhenReady(func: () => void): void;
  36933. /**
  36934. * Returns a promise that resolves when the scene is ready
  36935. * @returns A promise that resolves when the scene is ready
  36936. */
  36937. whenReadyAsync(): Promise<void>;
  36938. /** @hidden */
  36939. _checkIsReady(): void;
  36940. /**
  36941. * Gets all animatable attached to the scene
  36942. */
  36943. get animatables(): Animatable[];
  36944. /**
  36945. * Resets the last animation time frame.
  36946. * Useful to override when animations start running when loading a scene for the first time.
  36947. */
  36948. resetLastAnimationTimeFrame(): void;
  36949. /**
  36950. * Gets the current view matrix
  36951. * @returns a Matrix
  36952. */
  36953. getViewMatrix(): Matrix;
  36954. /**
  36955. * Gets the current projection matrix
  36956. * @returns a Matrix
  36957. */
  36958. getProjectionMatrix(): Matrix;
  36959. /**
  36960. * Gets the current transform matrix
  36961. * @returns a Matrix made of View * Projection
  36962. */
  36963. getTransformMatrix(): Matrix;
  36964. /**
  36965. * Sets the current transform matrix
  36966. * @param viewL defines the View matrix to use
  36967. * @param projectionL defines the Projection matrix to use
  36968. * @param viewR defines the right View matrix to use (if provided)
  36969. * @param projectionR defines the right Projection matrix to use (if provided)
  36970. */
  36971. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36972. /**
  36973. * Gets the uniform buffer used to store scene data
  36974. * @returns a UniformBuffer
  36975. */
  36976. getSceneUniformBuffer(): UniformBuffer;
  36977. /**
  36978. * Gets an unique (relatively to the current scene) Id
  36979. * @returns an unique number for the scene
  36980. */
  36981. getUniqueId(): number;
  36982. /**
  36983. * Add a mesh to the list of scene's meshes
  36984. * @param newMesh defines the mesh to add
  36985. * @param recursive if all child meshes should also be added to the scene
  36986. */
  36987. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36988. /**
  36989. * Remove a mesh for the list of scene's meshes
  36990. * @param toRemove defines the mesh to remove
  36991. * @param recursive if all child meshes should also be removed from the scene
  36992. * @returns the index where the mesh was in the mesh list
  36993. */
  36994. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36995. /**
  36996. * Add a transform node to the list of scene's transform nodes
  36997. * @param newTransformNode defines the transform node to add
  36998. */
  36999. addTransformNode(newTransformNode: TransformNode): void;
  37000. /**
  37001. * Remove a transform node for the list of scene's transform nodes
  37002. * @param toRemove defines the transform node to remove
  37003. * @returns the index where the transform node was in the transform node list
  37004. */
  37005. removeTransformNode(toRemove: TransformNode): number;
  37006. /**
  37007. * Remove a skeleton for the list of scene's skeletons
  37008. * @param toRemove defines the skeleton to remove
  37009. * @returns the index where the skeleton was in the skeleton list
  37010. */
  37011. removeSkeleton(toRemove: Skeleton): number;
  37012. /**
  37013. * Remove a morph target for the list of scene's morph targets
  37014. * @param toRemove defines the morph target to remove
  37015. * @returns the index where the morph target was in the morph target list
  37016. */
  37017. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37018. /**
  37019. * Remove a light for the list of scene's lights
  37020. * @param toRemove defines the light to remove
  37021. * @returns the index where the light was in the light list
  37022. */
  37023. removeLight(toRemove: Light): number;
  37024. /**
  37025. * Remove a camera for the list of scene's cameras
  37026. * @param toRemove defines the camera to remove
  37027. * @returns the index where the camera was in the camera list
  37028. */
  37029. removeCamera(toRemove: Camera): number;
  37030. /**
  37031. * Remove a particle system for the list of scene's particle systems
  37032. * @param toRemove defines the particle system to remove
  37033. * @returns the index where the particle system was in the particle system list
  37034. */
  37035. removeParticleSystem(toRemove: IParticleSystem): number;
  37036. /**
  37037. * Remove a animation for the list of scene's animations
  37038. * @param toRemove defines the animation to remove
  37039. * @returns the index where the animation was in the animation list
  37040. */
  37041. removeAnimation(toRemove: Animation): number;
  37042. /**
  37043. * Will stop the animation of the given target
  37044. * @param target - the target
  37045. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37046. * @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)
  37047. */
  37048. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37049. /**
  37050. * Removes the given animation group from this scene.
  37051. * @param toRemove The animation group to remove
  37052. * @returns The index of the removed animation group
  37053. */
  37054. removeAnimationGroup(toRemove: AnimationGroup): number;
  37055. /**
  37056. * Removes the given multi-material from this scene.
  37057. * @param toRemove The multi-material to remove
  37058. * @returns The index of the removed multi-material
  37059. */
  37060. removeMultiMaterial(toRemove: MultiMaterial): number;
  37061. /**
  37062. * Removes the given material from this scene.
  37063. * @param toRemove The material to remove
  37064. * @returns The index of the removed material
  37065. */
  37066. removeMaterial(toRemove: Material): number;
  37067. /**
  37068. * Removes the given action manager from this scene.
  37069. * @param toRemove The action manager to remove
  37070. * @returns The index of the removed action manager
  37071. */
  37072. removeActionManager(toRemove: AbstractActionManager): number;
  37073. /**
  37074. * Removes the given texture from this scene.
  37075. * @param toRemove The texture to remove
  37076. * @returns The index of the removed texture
  37077. */
  37078. removeTexture(toRemove: BaseTexture): number;
  37079. /**
  37080. * Adds the given light to this scene
  37081. * @param newLight The light to add
  37082. */
  37083. addLight(newLight: Light): void;
  37084. /**
  37085. * Sorts the list list based on light priorities
  37086. */
  37087. sortLightsByPriority(): void;
  37088. /**
  37089. * Adds the given camera to this scene
  37090. * @param newCamera The camera to add
  37091. */
  37092. addCamera(newCamera: Camera): void;
  37093. /**
  37094. * Adds the given skeleton to this scene
  37095. * @param newSkeleton The skeleton to add
  37096. */
  37097. addSkeleton(newSkeleton: Skeleton): void;
  37098. /**
  37099. * Adds the given particle system to this scene
  37100. * @param newParticleSystem The particle system to add
  37101. */
  37102. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37103. /**
  37104. * Adds the given animation to this scene
  37105. * @param newAnimation The animation to add
  37106. */
  37107. addAnimation(newAnimation: Animation): void;
  37108. /**
  37109. * Adds the given animation group to this scene.
  37110. * @param newAnimationGroup The animation group to add
  37111. */
  37112. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37113. /**
  37114. * Adds the given multi-material to this scene
  37115. * @param newMultiMaterial The multi-material to add
  37116. */
  37117. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37118. /**
  37119. * Adds the given material to this scene
  37120. * @param newMaterial The material to add
  37121. */
  37122. addMaterial(newMaterial: Material): void;
  37123. /**
  37124. * Adds the given morph target to this scene
  37125. * @param newMorphTargetManager The morph target to add
  37126. */
  37127. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37128. /**
  37129. * Adds the given geometry to this scene
  37130. * @param newGeometry The geometry to add
  37131. */
  37132. addGeometry(newGeometry: Geometry): void;
  37133. /**
  37134. * Adds the given action manager to this scene
  37135. * @param newActionManager The action manager to add
  37136. */
  37137. addActionManager(newActionManager: AbstractActionManager): void;
  37138. /**
  37139. * Adds the given texture to this scene.
  37140. * @param newTexture The texture to add
  37141. */
  37142. addTexture(newTexture: BaseTexture): void;
  37143. /**
  37144. * Switch active camera
  37145. * @param newCamera defines the new active camera
  37146. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37147. */
  37148. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37149. /**
  37150. * sets the active camera of the scene using its ID
  37151. * @param id defines the camera's ID
  37152. * @return the new active camera or null if none found.
  37153. */
  37154. setActiveCameraByID(id: string): Nullable<Camera>;
  37155. /**
  37156. * sets the active camera of the scene using its name
  37157. * @param name defines the camera's name
  37158. * @returns the new active camera or null if none found.
  37159. */
  37160. setActiveCameraByName(name: string): Nullable<Camera>;
  37161. /**
  37162. * get an animation group using its name
  37163. * @param name defines the material's name
  37164. * @return the animation group or null if none found.
  37165. */
  37166. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37167. /**
  37168. * Get a material using its unique id
  37169. * @param uniqueId defines the material's unique id
  37170. * @return the material or null if none found.
  37171. */
  37172. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37173. /**
  37174. * get a material using its id
  37175. * @param id defines the material's ID
  37176. * @return the material or null if none found.
  37177. */
  37178. getMaterialByID(id: string): Nullable<Material>;
  37179. /**
  37180. * Gets a the last added material using a given id
  37181. * @param id defines the material's ID
  37182. * @return the last material with the given id or null if none found.
  37183. */
  37184. getLastMaterialByID(id: string): Nullable<Material>;
  37185. /**
  37186. * Gets a material using its name
  37187. * @param name defines the material's name
  37188. * @return the material or null if none found.
  37189. */
  37190. getMaterialByName(name: string): Nullable<Material>;
  37191. /**
  37192. * Get a texture using its unique id
  37193. * @param uniqueId defines the texture's unique id
  37194. * @return the texture or null if none found.
  37195. */
  37196. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37197. /**
  37198. * Gets a camera using its id
  37199. * @param id defines the id to look for
  37200. * @returns the camera or null if not found
  37201. */
  37202. getCameraByID(id: string): Nullable<Camera>;
  37203. /**
  37204. * Gets a camera using its unique id
  37205. * @param uniqueId defines the unique id to look for
  37206. * @returns the camera or null if not found
  37207. */
  37208. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37209. /**
  37210. * Gets a camera using its name
  37211. * @param name defines the camera's name
  37212. * @return the camera or null if none found.
  37213. */
  37214. getCameraByName(name: string): Nullable<Camera>;
  37215. /**
  37216. * Gets a bone using its id
  37217. * @param id defines the bone's id
  37218. * @return the bone or null if not found
  37219. */
  37220. getBoneByID(id: string): Nullable<Bone>;
  37221. /**
  37222. * Gets a bone using its id
  37223. * @param name defines the bone's name
  37224. * @return the bone or null if not found
  37225. */
  37226. getBoneByName(name: string): Nullable<Bone>;
  37227. /**
  37228. * Gets a light node using its name
  37229. * @param name defines the the light's name
  37230. * @return the light or null if none found.
  37231. */
  37232. getLightByName(name: string): Nullable<Light>;
  37233. /**
  37234. * Gets a light node using its id
  37235. * @param id defines the light's id
  37236. * @return the light or null if none found.
  37237. */
  37238. getLightByID(id: string): Nullable<Light>;
  37239. /**
  37240. * Gets a light node using its scene-generated unique ID
  37241. * @param uniqueId defines the light's unique id
  37242. * @return the light or null if none found.
  37243. */
  37244. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37245. /**
  37246. * Gets a particle system by id
  37247. * @param id defines the particle system id
  37248. * @return the corresponding system or null if none found
  37249. */
  37250. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37251. /**
  37252. * Gets a geometry using its ID
  37253. * @param id defines the geometry's id
  37254. * @return the geometry or null if none found.
  37255. */
  37256. getGeometryByID(id: string): Nullable<Geometry>;
  37257. private _getGeometryByUniqueID;
  37258. /**
  37259. * Add a new geometry to this scene
  37260. * @param geometry defines the geometry to be added to the scene.
  37261. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37262. * @return a boolean defining if the geometry was added or not
  37263. */
  37264. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37265. /**
  37266. * Removes an existing geometry
  37267. * @param geometry defines the geometry to be removed from the scene
  37268. * @return a boolean defining if the geometry was removed or not
  37269. */
  37270. removeGeometry(geometry: Geometry): boolean;
  37271. /**
  37272. * Gets the list of geometries attached to the scene
  37273. * @returns an array of Geometry
  37274. */
  37275. getGeometries(): Geometry[];
  37276. /**
  37277. * Gets the first added mesh found of a given ID
  37278. * @param id defines the id to search for
  37279. * @return the mesh found or null if not found at all
  37280. */
  37281. getMeshByID(id: string): Nullable<AbstractMesh>;
  37282. /**
  37283. * Gets a list of meshes using their id
  37284. * @param id defines the id to search for
  37285. * @returns a list of meshes
  37286. */
  37287. getMeshesByID(id: string): Array<AbstractMesh>;
  37288. /**
  37289. * Gets the first added transform node found of a given ID
  37290. * @param id defines the id to search for
  37291. * @return the found transform node or null if not found at all.
  37292. */
  37293. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37294. /**
  37295. * Gets a transform node with its auto-generated unique id
  37296. * @param uniqueId efines the unique id to search for
  37297. * @return the found transform node or null if not found at all.
  37298. */
  37299. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37300. /**
  37301. * Gets a list of transform nodes using their id
  37302. * @param id defines the id to search for
  37303. * @returns a list of transform nodes
  37304. */
  37305. getTransformNodesByID(id: string): Array<TransformNode>;
  37306. /**
  37307. * Gets a mesh with its auto-generated unique id
  37308. * @param uniqueId defines the unique id to search for
  37309. * @return the found mesh or null if not found at all.
  37310. */
  37311. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37312. /**
  37313. * Gets a the last added mesh using a given id
  37314. * @param id defines the id to search for
  37315. * @return the found mesh or null if not found at all.
  37316. */
  37317. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37318. /**
  37319. * Gets a the last added 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. getLastEntryByID(id: string): Nullable<Node>;
  37324. /**
  37325. * Gets a node (Mesh, Camera, Light) using a given id
  37326. * @param id defines the id to search for
  37327. * @return the found node or null if not found at all
  37328. */
  37329. getNodeByID(id: string): Nullable<Node>;
  37330. /**
  37331. * Gets a node (Mesh, Camera, Light) using a given name
  37332. * @param name defines the name to search for
  37333. * @return the found node or null if not found at all.
  37334. */
  37335. getNodeByName(name: string): Nullable<Node>;
  37336. /**
  37337. * Gets a mesh using a given name
  37338. * @param name defines the name to search for
  37339. * @return the found mesh or null if not found at all.
  37340. */
  37341. getMeshByName(name: string): Nullable<AbstractMesh>;
  37342. /**
  37343. * Gets a transform node using a given name
  37344. * @param name defines the name to search for
  37345. * @return the found transform node or null if not found at all.
  37346. */
  37347. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37348. /**
  37349. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37350. * @param id defines the id to search for
  37351. * @return the found skeleton or null if not found at all.
  37352. */
  37353. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37354. /**
  37355. * Gets a skeleton using a given auto generated unique id
  37356. * @param uniqueId defines the unique id to search for
  37357. * @return the found skeleton or null if not found at all.
  37358. */
  37359. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37360. /**
  37361. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37362. * @param id defines the id to search for
  37363. * @return the found skeleton or null if not found at all.
  37364. */
  37365. getSkeletonById(id: string): Nullable<Skeleton>;
  37366. /**
  37367. * Gets a skeleton using a given name
  37368. * @param name defines the name to search for
  37369. * @return the found skeleton or null if not found at all.
  37370. */
  37371. getSkeletonByName(name: string): Nullable<Skeleton>;
  37372. /**
  37373. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37374. * @param id defines the id to search for
  37375. * @return the found morph target manager or null if not found at all.
  37376. */
  37377. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37378. /**
  37379. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37380. * @param id defines the id to search for
  37381. * @return the found morph target or null if not found at all.
  37382. */
  37383. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37384. /**
  37385. * Gets a boolean indicating if the given mesh is active
  37386. * @param mesh defines the mesh to look for
  37387. * @returns true if the mesh is in the active list
  37388. */
  37389. isActiveMesh(mesh: AbstractMesh): boolean;
  37390. /**
  37391. * Return a unique id as a string which can serve as an identifier for the scene
  37392. */
  37393. get uid(): string;
  37394. /**
  37395. * Add an externaly attached data from its key.
  37396. * This method call will fail and return false, if such key already exists.
  37397. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37398. * @param key the unique key that identifies the data
  37399. * @param data the data object to associate to the key for this Engine instance
  37400. * @return true if no such key were already present and the data was added successfully, false otherwise
  37401. */
  37402. addExternalData<T>(key: string, data: T): boolean;
  37403. /**
  37404. * Get an externaly attached data from its key
  37405. * @param key the unique key that identifies the data
  37406. * @return the associated data, if present (can be null), or undefined if not present
  37407. */
  37408. getExternalData<T>(key: string): Nullable<T>;
  37409. /**
  37410. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37411. * @param key the unique key that identifies the data
  37412. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37413. * @return the associated data, can be null if the factory returned null.
  37414. */
  37415. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37416. /**
  37417. * Remove an externaly attached data from the Engine instance
  37418. * @param key the unique key that identifies the data
  37419. * @return true if the data was successfully removed, false if it doesn't exist
  37420. */
  37421. removeExternalData(key: string): boolean;
  37422. private _evaluateSubMesh;
  37423. /**
  37424. * Clear the processed materials smart array preventing retention point in material dispose.
  37425. */
  37426. freeProcessedMaterials(): void;
  37427. private _preventFreeActiveMeshesAndRenderingGroups;
  37428. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37429. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37430. * when disposing several meshes in a row or a hierarchy of meshes.
  37431. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37432. */
  37433. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37434. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37435. /**
  37436. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37437. */
  37438. freeActiveMeshes(): void;
  37439. /**
  37440. * Clear the info related to rendering groups preventing retention points during dispose.
  37441. */
  37442. freeRenderingGroups(): void;
  37443. /** @hidden */
  37444. _isInIntermediateRendering(): boolean;
  37445. /**
  37446. * Lambda returning the list of potentially active meshes.
  37447. */
  37448. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37449. /**
  37450. * Lambda returning the list of potentially active sub meshes.
  37451. */
  37452. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37453. /**
  37454. * Lambda returning the list of potentially intersecting sub meshes.
  37455. */
  37456. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37457. /**
  37458. * Lambda returning the list of potentially colliding sub meshes.
  37459. */
  37460. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37461. private _activeMeshesFrozen;
  37462. private _skipEvaluateActiveMeshesCompletely;
  37463. /**
  37464. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37465. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37466. * @returns the current scene
  37467. */
  37468. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37469. /**
  37470. * Use this function to restart evaluating active meshes on every frame
  37471. * @returns the current scene
  37472. */
  37473. unfreezeActiveMeshes(): Scene;
  37474. private _evaluateActiveMeshes;
  37475. private _activeMesh;
  37476. /**
  37477. * Update the transform matrix to update from the current active camera
  37478. * @param force defines a boolean used to force the update even if cache is up to date
  37479. */
  37480. updateTransformMatrix(force?: boolean): void;
  37481. private _bindFrameBuffer;
  37482. /** @hidden */
  37483. _allowPostProcessClearColor: boolean;
  37484. /** @hidden */
  37485. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37486. private _processSubCameras;
  37487. private _checkIntersections;
  37488. /** @hidden */
  37489. _advancePhysicsEngineStep(step: number): void;
  37490. /**
  37491. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37492. */
  37493. getDeterministicFrameTime: () => number;
  37494. /** @hidden */
  37495. _animate(): void;
  37496. /** Execute all animations (for a frame) */
  37497. animate(): void;
  37498. /**
  37499. * Render the scene
  37500. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37501. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37502. */
  37503. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37504. /**
  37505. * Freeze all materials
  37506. * A frozen material will not be updatable but should be faster to render
  37507. */
  37508. freezeMaterials(): void;
  37509. /**
  37510. * Unfreeze all materials
  37511. * A frozen material will not be updatable but should be faster to render
  37512. */
  37513. unfreezeMaterials(): void;
  37514. /**
  37515. * Releases all held ressources
  37516. */
  37517. dispose(): void;
  37518. /**
  37519. * Gets if the scene is already disposed
  37520. */
  37521. get isDisposed(): boolean;
  37522. /**
  37523. * Call this function to reduce memory footprint of the scene.
  37524. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37525. */
  37526. clearCachedVertexData(): void;
  37527. /**
  37528. * This function will remove the local cached buffer data from texture.
  37529. * It will save memory but will prevent the texture from being rebuilt
  37530. */
  37531. cleanCachedTextureBuffer(): void;
  37532. /**
  37533. * Get the world extend vectors with an optional filter
  37534. *
  37535. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37536. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37537. */
  37538. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37539. min: Vector3;
  37540. max: Vector3;
  37541. };
  37542. /**
  37543. * Creates a ray that can be used to pick in the scene
  37544. * @param x defines the x coordinate of the origin (on-screen)
  37545. * @param y defines the y coordinate of the origin (on-screen)
  37546. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37547. * @param camera defines the camera to use for the picking
  37548. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37549. * @returns a Ray
  37550. */
  37551. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37552. /**
  37553. * Creates a ray that can be used to pick in the scene
  37554. * @param x defines the x coordinate of the origin (on-screen)
  37555. * @param y defines the y coordinate of the origin (on-screen)
  37556. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37557. * @param result defines the ray where to store the picking ray
  37558. * @param camera defines the camera to use for the picking
  37559. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37560. * @returns the current scene
  37561. */
  37562. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37563. /**
  37564. * Creates a ray that can be used to pick in the scene
  37565. * @param x defines the x coordinate of the origin (on-screen)
  37566. * @param y defines the y coordinate of the origin (on-screen)
  37567. * @param camera defines the camera to use for the picking
  37568. * @returns a Ray
  37569. */
  37570. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37571. /**
  37572. * Creates a ray that can be used to pick in the scene
  37573. * @param x defines the x coordinate of the origin (on-screen)
  37574. * @param y defines the y coordinate of the origin (on-screen)
  37575. * @param result defines the ray where to store the picking ray
  37576. * @param camera defines the camera to use for the picking
  37577. * @returns the current scene
  37578. */
  37579. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37580. /** Launch a ray to try to pick a mesh in the scene
  37581. * @param x position on screen
  37582. * @param y position on screen
  37583. * @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
  37584. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37585. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37586. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37587. * @returns a PickingInfo
  37588. */
  37589. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37590. /** Use the given ray to pick a mesh in the scene
  37591. * @param ray The ray to use to pick meshes
  37592. * @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
  37593. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37594. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37595. * @returns a PickingInfo
  37596. */
  37597. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37598. /**
  37599. * Launch a ray to try to pick a mesh in the scene
  37600. * @param x X position on screen
  37601. * @param y Y position on screen
  37602. * @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
  37603. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37604. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37605. * @returns an array of PickingInfo
  37606. */
  37607. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37608. /**
  37609. * Launch a ray to try to pick a mesh in the scene
  37610. * @param ray Ray to use
  37611. * @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
  37612. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37613. * @returns an array of PickingInfo
  37614. */
  37615. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37616. /**
  37617. * Force the value of meshUnderPointer
  37618. * @param mesh defines the mesh to use
  37619. */
  37620. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37621. /**
  37622. * Gets the mesh under the pointer
  37623. * @returns a Mesh or null if no mesh is under the pointer
  37624. */
  37625. getPointerOverMesh(): Nullable<AbstractMesh>;
  37626. /** @hidden */
  37627. _rebuildGeometries(): void;
  37628. /** @hidden */
  37629. _rebuildTextures(): void;
  37630. private _getByTags;
  37631. /**
  37632. * Get a list of meshes by tags
  37633. * @param tagsQuery defines the tags query to use
  37634. * @param forEach defines a predicate used to filter results
  37635. * @returns an array of Mesh
  37636. */
  37637. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37638. /**
  37639. * Get a list of cameras by tags
  37640. * @param tagsQuery defines the tags query to use
  37641. * @param forEach defines a predicate used to filter results
  37642. * @returns an array of Camera
  37643. */
  37644. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37645. /**
  37646. * Get a list of lights by tags
  37647. * @param tagsQuery defines the tags query to use
  37648. * @param forEach defines a predicate used to filter results
  37649. * @returns an array of Light
  37650. */
  37651. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37652. /**
  37653. * Get a list of materials by tags
  37654. * @param tagsQuery defines the tags query to use
  37655. * @param forEach defines a predicate used to filter results
  37656. * @returns an array of Material
  37657. */
  37658. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37659. /**
  37660. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37661. * This allowed control for front to back rendering or reversly depending of the special needs.
  37662. *
  37663. * @param renderingGroupId The rendering group id corresponding to its index
  37664. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37665. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37666. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37667. */
  37668. 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;
  37669. /**
  37670. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37671. *
  37672. * @param renderingGroupId The rendering group id corresponding to its index
  37673. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37674. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37675. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37676. */
  37677. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37678. /**
  37679. * Gets the current auto clear configuration for one rendering group of the rendering
  37680. * manager.
  37681. * @param index the rendering group index to get the information for
  37682. * @returns The auto clear setup for the requested rendering group
  37683. */
  37684. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37685. private _blockMaterialDirtyMechanism;
  37686. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37687. get blockMaterialDirtyMechanism(): boolean;
  37688. set blockMaterialDirtyMechanism(value: boolean);
  37689. /**
  37690. * Will flag all materials as dirty to trigger new shader compilation
  37691. * @param flag defines the flag used to specify which material part must be marked as dirty
  37692. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37693. */
  37694. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37695. /** @hidden */
  37696. _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;
  37697. /** @hidden */
  37698. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37699. /** @hidden */
  37700. _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;
  37701. /** @hidden */
  37702. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37703. /** @hidden */
  37704. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37705. /** @hidden */
  37706. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37707. }
  37708. }
  37709. declare module "babylonjs/assetContainer" {
  37710. import { AbstractScene } from "babylonjs/abstractScene";
  37711. import { Scene } from "babylonjs/scene";
  37712. import { Mesh } from "babylonjs/Meshes/mesh";
  37713. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37714. import { Skeleton } from "babylonjs/Bones/skeleton";
  37715. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37716. import { Animatable } from "babylonjs/Animations/animatable";
  37717. import { Nullable } from "babylonjs/types";
  37718. import { Node } from "babylonjs/node";
  37719. /**
  37720. * Set of assets to keep when moving a scene into an asset container.
  37721. */
  37722. export class KeepAssets extends AbstractScene {
  37723. }
  37724. /**
  37725. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37726. */
  37727. export class InstantiatedEntries {
  37728. /**
  37729. * List of new root nodes (eg. nodes with no parent)
  37730. */
  37731. rootNodes: TransformNode[];
  37732. /**
  37733. * List of new skeletons
  37734. */
  37735. skeletons: Skeleton[];
  37736. /**
  37737. * List of new animation groups
  37738. */
  37739. animationGroups: AnimationGroup[];
  37740. }
  37741. /**
  37742. * Container with a set of assets that can be added or removed from a scene.
  37743. */
  37744. export class AssetContainer extends AbstractScene {
  37745. /**
  37746. * The scene the AssetContainer belongs to.
  37747. */
  37748. scene: Scene;
  37749. /**
  37750. * Instantiates an AssetContainer.
  37751. * @param scene The scene the AssetContainer belongs to.
  37752. */
  37753. constructor(scene: Scene);
  37754. /**
  37755. * Instantiate or clone all meshes and add the new ones to the scene.
  37756. * Skeletons and animation groups will all be cloned
  37757. * @param nameFunction defines an optional function used to get new names for clones
  37758. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37759. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37760. */
  37761. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37762. /**
  37763. * Adds all the assets from the container to the scene.
  37764. */
  37765. addAllToScene(): void;
  37766. /**
  37767. * Removes all the assets in the container from the scene
  37768. */
  37769. removeAllFromScene(): void;
  37770. /**
  37771. * Disposes all the assets in the container
  37772. */
  37773. dispose(): void;
  37774. private _moveAssets;
  37775. /**
  37776. * Removes all the assets contained in the scene and adds them to the container.
  37777. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37778. */
  37779. moveAllFromScene(keepAssets?: KeepAssets): void;
  37780. /**
  37781. * 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.
  37782. * @returns the root mesh
  37783. */
  37784. createRootMesh(): Mesh;
  37785. /**
  37786. * Merge animations from this asset container into a scene
  37787. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37788. * @param animatables set of animatables to retarget to a node from the scene
  37789. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37790. */
  37791. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37792. }
  37793. }
  37794. declare module "babylonjs/abstractScene" {
  37795. import { Scene } from "babylonjs/scene";
  37796. import { Nullable } from "babylonjs/types";
  37797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37798. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37799. import { Geometry } from "babylonjs/Meshes/geometry";
  37800. import { Skeleton } from "babylonjs/Bones/skeleton";
  37801. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37802. import { AssetContainer } from "babylonjs/assetContainer";
  37803. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37804. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37805. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37806. import { Material } from "babylonjs/Materials/material";
  37807. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37808. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37809. import { Camera } from "babylonjs/Cameras/camera";
  37810. import { Light } from "babylonjs/Lights/light";
  37811. import { Node } from "babylonjs/node";
  37812. import { Animation } from "babylonjs/Animations/animation";
  37813. /**
  37814. * Defines how the parser contract is defined.
  37815. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37816. */
  37817. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37818. /**
  37819. * Defines how the individual parser contract is defined.
  37820. * These parser can parse an individual asset
  37821. */
  37822. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37823. /**
  37824. * Base class of the scene acting as a container for the different elements composing a scene.
  37825. * This class is dynamically extended by the different components of the scene increasing
  37826. * flexibility and reducing coupling
  37827. */
  37828. export abstract class AbstractScene {
  37829. /**
  37830. * Stores the list of available parsers in the application.
  37831. */
  37832. private static _BabylonFileParsers;
  37833. /**
  37834. * Stores the list of available individual parsers in the application.
  37835. */
  37836. private static _IndividualBabylonFileParsers;
  37837. /**
  37838. * Adds a parser in the list of available ones
  37839. * @param name Defines the name of the parser
  37840. * @param parser Defines the parser to add
  37841. */
  37842. static AddParser(name: string, parser: BabylonFileParser): void;
  37843. /**
  37844. * Gets a general parser from the list of avaialble ones
  37845. * @param name Defines the name of the parser
  37846. * @returns the requested parser or null
  37847. */
  37848. static GetParser(name: string): Nullable<BabylonFileParser>;
  37849. /**
  37850. * Adds n individual parser in the list of available ones
  37851. * @param name Defines the name of the parser
  37852. * @param parser Defines the parser to add
  37853. */
  37854. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37855. /**
  37856. * Gets an individual parser from the list of avaialble ones
  37857. * @param name Defines the name of the parser
  37858. * @returns the requested parser or null
  37859. */
  37860. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37861. /**
  37862. * Parser json data and populate both a scene and its associated container object
  37863. * @param jsonData Defines the data to parse
  37864. * @param scene Defines the scene to parse the data for
  37865. * @param container Defines the container attached to the parsing sequence
  37866. * @param rootUrl Defines the root url of the data
  37867. */
  37868. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37869. /**
  37870. * Gets the list of root nodes (ie. nodes with no parent)
  37871. */
  37872. rootNodes: Node[];
  37873. /** All of the cameras added to this scene
  37874. * @see http://doc.babylonjs.com/babylon101/cameras
  37875. */
  37876. cameras: Camera[];
  37877. /**
  37878. * All of the lights added to this scene
  37879. * @see http://doc.babylonjs.com/babylon101/lights
  37880. */
  37881. lights: Light[];
  37882. /**
  37883. * All of the (abstract) meshes added to this scene
  37884. */
  37885. meshes: AbstractMesh[];
  37886. /**
  37887. * The list of skeletons added to the scene
  37888. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37889. */
  37890. skeletons: Skeleton[];
  37891. /**
  37892. * All of the particle systems added to this scene
  37893. * @see http://doc.babylonjs.com/babylon101/particles
  37894. */
  37895. particleSystems: IParticleSystem[];
  37896. /**
  37897. * Gets a list of Animations associated with the scene
  37898. */
  37899. animations: Animation[];
  37900. /**
  37901. * All of the animation groups added to this scene
  37902. * @see http://doc.babylonjs.com/how_to/group
  37903. */
  37904. animationGroups: AnimationGroup[];
  37905. /**
  37906. * All of the multi-materials added to this scene
  37907. * @see http://doc.babylonjs.com/how_to/multi_materials
  37908. */
  37909. multiMaterials: MultiMaterial[];
  37910. /**
  37911. * All of the materials added to this scene
  37912. * In the context of a Scene, it is not supposed to be modified manually.
  37913. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37914. * Note also that the order of the Material within the array is not significant and might change.
  37915. * @see http://doc.babylonjs.com/babylon101/materials
  37916. */
  37917. materials: Material[];
  37918. /**
  37919. * The list of morph target managers added to the scene
  37920. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37921. */
  37922. morphTargetManagers: MorphTargetManager[];
  37923. /**
  37924. * The list of geometries used in the scene.
  37925. */
  37926. geometries: Geometry[];
  37927. /**
  37928. * All of the tranform nodes added to this scene
  37929. * In the context of a Scene, it is not supposed to be modified manually.
  37930. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37931. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37932. * @see http://doc.babylonjs.com/how_to/transformnode
  37933. */
  37934. transformNodes: TransformNode[];
  37935. /**
  37936. * ActionManagers available on the scene.
  37937. */
  37938. actionManagers: AbstractActionManager[];
  37939. /**
  37940. * Textures to keep.
  37941. */
  37942. textures: BaseTexture[];
  37943. /**
  37944. * Environment texture for the scene
  37945. */
  37946. environmentTexture: Nullable<BaseTexture>;
  37947. /**
  37948. * @returns all meshes, lights, cameras, transformNodes and bones
  37949. */
  37950. getNodes(): Array<Node>;
  37951. }
  37952. }
  37953. declare module "babylonjs/Audio/sound" {
  37954. import { Observable } from "babylonjs/Misc/observable";
  37955. import { Vector3 } from "babylonjs/Maths/math.vector";
  37956. import { Nullable } from "babylonjs/types";
  37957. import { Scene } from "babylonjs/scene";
  37958. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37959. /**
  37960. * Interface used to define options for Sound class
  37961. */
  37962. export interface ISoundOptions {
  37963. /**
  37964. * Does the sound autoplay once loaded.
  37965. */
  37966. autoplay?: boolean;
  37967. /**
  37968. * Does the sound loop after it finishes playing once.
  37969. */
  37970. loop?: boolean;
  37971. /**
  37972. * Sound's volume
  37973. */
  37974. volume?: number;
  37975. /**
  37976. * Is it a spatial sound?
  37977. */
  37978. spatialSound?: boolean;
  37979. /**
  37980. * Maximum distance to hear that sound
  37981. */
  37982. maxDistance?: number;
  37983. /**
  37984. * Uses user defined attenuation function
  37985. */
  37986. useCustomAttenuation?: boolean;
  37987. /**
  37988. * Define the roll off factor of spatial sounds.
  37989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37990. */
  37991. rolloffFactor?: number;
  37992. /**
  37993. * Define the reference distance the sound should be heard perfectly.
  37994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37995. */
  37996. refDistance?: number;
  37997. /**
  37998. * Define the distance attenuation model the sound will follow.
  37999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38000. */
  38001. distanceModel?: string;
  38002. /**
  38003. * Defines the playback speed (1 by default)
  38004. */
  38005. playbackRate?: number;
  38006. /**
  38007. * Defines if the sound is from a streaming source
  38008. */
  38009. streaming?: boolean;
  38010. /**
  38011. * Defines an optional length (in seconds) inside the sound file
  38012. */
  38013. length?: number;
  38014. /**
  38015. * Defines an optional offset (in seconds) inside the sound file
  38016. */
  38017. offset?: number;
  38018. /**
  38019. * If true, URLs will not be required to state the audio file codec to use.
  38020. */
  38021. skipCodecCheck?: boolean;
  38022. }
  38023. /**
  38024. * Defines a sound that can be played in the application.
  38025. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38027. */
  38028. export class Sound {
  38029. /**
  38030. * The name of the sound in the scene.
  38031. */
  38032. name: string;
  38033. /**
  38034. * Does the sound autoplay once loaded.
  38035. */
  38036. autoplay: boolean;
  38037. /**
  38038. * Does the sound loop after it finishes playing once.
  38039. */
  38040. loop: boolean;
  38041. /**
  38042. * Does the sound use a custom attenuation curve to simulate the falloff
  38043. * happening when the source gets further away from the camera.
  38044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38045. */
  38046. useCustomAttenuation: boolean;
  38047. /**
  38048. * The sound track id this sound belongs to.
  38049. */
  38050. soundTrackId: number;
  38051. /**
  38052. * Is this sound currently played.
  38053. */
  38054. isPlaying: boolean;
  38055. /**
  38056. * Is this sound currently paused.
  38057. */
  38058. isPaused: boolean;
  38059. /**
  38060. * Does this sound enables spatial sound.
  38061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38062. */
  38063. spatialSound: boolean;
  38064. /**
  38065. * Define the reference distance the sound should be heard perfectly.
  38066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38067. */
  38068. refDistance: number;
  38069. /**
  38070. * Define the roll off factor of spatial sounds.
  38071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38072. */
  38073. rolloffFactor: number;
  38074. /**
  38075. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38077. */
  38078. maxDistance: number;
  38079. /**
  38080. * Define the distance attenuation model the sound will follow.
  38081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38082. */
  38083. distanceModel: string;
  38084. /**
  38085. * @hidden
  38086. * Back Compat
  38087. **/
  38088. onended: () => any;
  38089. /**
  38090. * Observable event when the current playing sound finishes.
  38091. */
  38092. onEndedObservable: Observable<Sound>;
  38093. private _panningModel;
  38094. private _playbackRate;
  38095. private _streaming;
  38096. private _startTime;
  38097. private _startOffset;
  38098. private _position;
  38099. /** @hidden */
  38100. _positionInEmitterSpace: boolean;
  38101. private _localDirection;
  38102. private _volume;
  38103. private _isReadyToPlay;
  38104. private _isDirectional;
  38105. private _readyToPlayCallback;
  38106. private _audioBuffer;
  38107. private _soundSource;
  38108. private _streamingSource;
  38109. private _soundPanner;
  38110. private _soundGain;
  38111. private _inputAudioNode;
  38112. private _outputAudioNode;
  38113. private _coneInnerAngle;
  38114. private _coneOuterAngle;
  38115. private _coneOuterGain;
  38116. private _scene;
  38117. private _connectedTransformNode;
  38118. private _customAttenuationFunction;
  38119. private _registerFunc;
  38120. private _isOutputConnected;
  38121. private _htmlAudioElement;
  38122. private _urlType;
  38123. private _length?;
  38124. private _offset?;
  38125. /** @hidden */
  38126. static _SceneComponentInitialization: (scene: Scene) => void;
  38127. /**
  38128. * Create a sound and attach it to a scene
  38129. * @param name Name of your sound
  38130. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38131. * @param scene defines the scene the sound belongs to
  38132. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38133. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38134. */
  38135. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38136. /**
  38137. * Release the sound and its associated resources
  38138. */
  38139. dispose(): void;
  38140. /**
  38141. * Gets if the sounds is ready to be played or not.
  38142. * @returns true if ready, otherwise false
  38143. */
  38144. isReady(): boolean;
  38145. private _soundLoaded;
  38146. /**
  38147. * Sets the data of the sound from an audiobuffer
  38148. * @param audioBuffer The audioBuffer containing the data
  38149. */
  38150. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38151. /**
  38152. * Updates the current sounds options such as maxdistance, loop...
  38153. * @param options A JSON object containing values named as the object properties
  38154. */
  38155. updateOptions(options: ISoundOptions): void;
  38156. private _createSpatialParameters;
  38157. private _updateSpatialParameters;
  38158. /**
  38159. * Switch the panning model to HRTF:
  38160. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38162. */
  38163. switchPanningModelToHRTF(): void;
  38164. /**
  38165. * Switch the panning model to Equal Power:
  38166. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38168. */
  38169. switchPanningModelToEqualPower(): void;
  38170. private _switchPanningModel;
  38171. /**
  38172. * Connect this sound to a sound track audio node like gain...
  38173. * @param soundTrackAudioNode the sound track audio node to connect to
  38174. */
  38175. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38176. /**
  38177. * Transform this sound into a directional source
  38178. * @param coneInnerAngle Size of the inner cone in degree
  38179. * @param coneOuterAngle Size of the outer cone in degree
  38180. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38181. */
  38182. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38183. /**
  38184. * Gets or sets the inner angle for the directional cone.
  38185. */
  38186. get directionalConeInnerAngle(): number;
  38187. /**
  38188. * Gets or sets the inner angle for the directional cone.
  38189. */
  38190. set directionalConeInnerAngle(value: number);
  38191. /**
  38192. * Gets or sets the outer angle for the directional cone.
  38193. */
  38194. get directionalConeOuterAngle(): number;
  38195. /**
  38196. * Gets or sets the outer angle for the directional cone.
  38197. */
  38198. set directionalConeOuterAngle(value: number);
  38199. /**
  38200. * Sets the position of the emitter if spatial sound is enabled
  38201. * @param newPosition Defines the new posisiton
  38202. */
  38203. setPosition(newPosition: Vector3): void;
  38204. /**
  38205. * Sets the local direction of the emitter if spatial sound is enabled
  38206. * @param newLocalDirection Defines the new local direction
  38207. */
  38208. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38209. private _updateDirection;
  38210. /** @hidden */
  38211. updateDistanceFromListener(): void;
  38212. /**
  38213. * Sets a new custom attenuation function for the sound.
  38214. * @param callback Defines the function used for the attenuation
  38215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38216. */
  38217. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38218. /**
  38219. * Play the sound
  38220. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38221. * @param offset (optional) Start the sound at a specific time in seconds
  38222. * @param length (optional) Sound duration (in seconds)
  38223. */
  38224. play(time?: number, offset?: number, length?: number): void;
  38225. private _onended;
  38226. /**
  38227. * Stop the sound
  38228. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38229. */
  38230. stop(time?: number): void;
  38231. /**
  38232. * Put the sound in pause
  38233. */
  38234. pause(): void;
  38235. /**
  38236. * Sets a dedicated volume for this sounds
  38237. * @param newVolume Define the new volume of the sound
  38238. * @param time Define time for gradual change to new volume
  38239. */
  38240. setVolume(newVolume: number, time?: number): void;
  38241. /**
  38242. * Set the sound play back rate
  38243. * @param newPlaybackRate Define the playback rate the sound should be played at
  38244. */
  38245. setPlaybackRate(newPlaybackRate: number): void;
  38246. /**
  38247. * Gets the volume of the sound.
  38248. * @returns the volume of the sound
  38249. */
  38250. getVolume(): number;
  38251. /**
  38252. * Attach the sound to a dedicated mesh
  38253. * @param transformNode The transform node to connect the sound with
  38254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38255. */
  38256. attachToMesh(transformNode: TransformNode): void;
  38257. /**
  38258. * Detach the sound from the previously attached mesh
  38259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38260. */
  38261. detachFromMesh(): void;
  38262. private _onRegisterAfterWorldMatrixUpdate;
  38263. /**
  38264. * Clone the current sound in the scene.
  38265. * @returns the new sound clone
  38266. */
  38267. clone(): Nullable<Sound>;
  38268. /**
  38269. * Gets the current underlying audio buffer containing the data
  38270. * @returns the audio buffer
  38271. */
  38272. getAudioBuffer(): Nullable<AudioBuffer>;
  38273. /**
  38274. * Serializes the Sound in a JSON representation
  38275. * @returns the JSON representation of the sound
  38276. */
  38277. serialize(): any;
  38278. /**
  38279. * Parse a JSON representation of a sound to innstantiate in a given scene
  38280. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38281. * @param scene Define the scene the new parsed sound should be created in
  38282. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38283. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38284. * @returns the newly parsed sound
  38285. */
  38286. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38287. }
  38288. }
  38289. declare module "babylonjs/Actions/directAudioActions" {
  38290. import { Action } from "babylonjs/Actions/action";
  38291. import { Condition } from "babylonjs/Actions/condition";
  38292. import { Sound } from "babylonjs/Audio/sound";
  38293. /**
  38294. * This defines an action helpful to play a defined sound on a triggered action.
  38295. */
  38296. export class PlaySoundAction extends Action {
  38297. private _sound;
  38298. /**
  38299. * Instantiate the action
  38300. * @param triggerOptions defines the trigger options
  38301. * @param sound defines the sound to play
  38302. * @param condition defines the trigger related conditions
  38303. */
  38304. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38305. /** @hidden */
  38306. _prepare(): void;
  38307. /**
  38308. * Execute the action and play the sound.
  38309. */
  38310. execute(): void;
  38311. /**
  38312. * Serializes the actions and its related information.
  38313. * @param parent defines the object to serialize in
  38314. * @returns the serialized object
  38315. */
  38316. serialize(parent: any): any;
  38317. }
  38318. /**
  38319. * This defines an action helpful to stop a defined sound on a triggered action.
  38320. */
  38321. export class StopSoundAction extends Action {
  38322. private _sound;
  38323. /**
  38324. * Instantiate the action
  38325. * @param triggerOptions defines the trigger options
  38326. * @param sound defines the sound to stop
  38327. * @param condition defines the trigger related conditions
  38328. */
  38329. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38330. /** @hidden */
  38331. _prepare(): void;
  38332. /**
  38333. * Execute the action and stop the sound.
  38334. */
  38335. execute(): void;
  38336. /**
  38337. * Serializes the actions and its related information.
  38338. * @param parent defines the object to serialize in
  38339. * @returns the serialized object
  38340. */
  38341. serialize(parent: any): any;
  38342. }
  38343. }
  38344. declare module "babylonjs/Actions/interpolateValueAction" {
  38345. import { Action } from "babylonjs/Actions/action";
  38346. import { Condition } from "babylonjs/Actions/condition";
  38347. import { Observable } from "babylonjs/Misc/observable";
  38348. /**
  38349. * This defines an action responsible to change the value of a property
  38350. * by interpolating between its current value and the newly set one once triggered.
  38351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38352. */
  38353. export class InterpolateValueAction extends Action {
  38354. /**
  38355. * Defines the path of the property where the value should be interpolated
  38356. */
  38357. propertyPath: string;
  38358. /**
  38359. * Defines the target value at the end of the interpolation.
  38360. */
  38361. value: any;
  38362. /**
  38363. * Defines the time it will take for the property to interpolate to the value.
  38364. */
  38365. duration: number;
  38366. /**
  38367. * Defines if the other scene animations should be stopped when the action has been triggered
  38368. */
  38369. stopOtherAnimations?: boolean;
  38370. /**
  38371. * Defines a callback raised once the interpolation animation has been done.
  38372. */
  38373. onInterpolationDone?: () => void;
  38374. /**
  38375. * Observable triggered once the interpolation animation has been done.
  38376. */
  38377. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38378. private _target;
  38379. private _effectiveTarget;
  38380. private _property;
  38381. /**
  38382. * Instantiate the action
  38383. * @param triggerOptions defines the trigger options
  38384. * @param target defines the object containing the value to interpolate
  38385. * @param propertyPath defines the path to the property in the target object
  38386. * @param value defines the target value at the end of the interpolation
  38387. * @param duration deines the time it will take for the property to interpolate to the value.
  38388. * @param condition defines the trigger related conditions
  38389. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38390. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38391. */
  38392. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38393. /** @hidden */
  38394. _prepare(): void;
  38395. /**
  38396. * Execute the action starts the value interpolation.
  38397. */
  38398. execute(): void;
  38399. /**
  38400. * Serializes the actions and its related information.
  38401. * @param parent defines the object to serialize in
  38402. * @returns the serialized object
  38403. */
  38404. serialize(parent: any): any;
  38405. }
  38406. }
  38407. declare module "babylonjs/Actions/index" {
  38408. export * from "babylonjs/Actions/abstractActionManager";
  38409. export * from "babylonjs/Actions/action";
  38410. export * from "babylonjs/Actions/actionEvent";
  38411. export * from "babylonjs/Actions/actionManager";
  38412. export * from "babylonjs/Actions/condition";
  38413. export * from "babylonjs/Actions/directActions";
  38414. export * from "babylonjs/Actions/directAudioActions";
  38415. export * from "babylonjs/Actions/interpolateValueAction";
  38416. }
  38417. declare module "babylonjs/Animations/index" {
  38418. export * from "babylonjs/Animations/animatable";
  38419. export * from "babylonjs/Animations/animation";
  38420. export * from "babylonjs/Animations/animationGroup";
  38421. export * from "babylonjs/Animations/animationPropertiesOverride";
  38422. export * from "babylonjs/Animations/easing";
  38423. export * from "babylonjs/Animations/runtimeAnimation";
  38424. export * from "babylonjs/Animations/animationEvent";
  38425. export * from "babylonjs/Animations/animationGroup";
  38426. export * from "babylonjs/Animations/animationKey";
  38427. export * from "babylonjs/Animations/animationRange";
  38428. export * from "babylonjs/Animations/animatable.interface";
  38429. }
  38430. declare module "babylonjs/Audio/soundTrack" {
  38431. import { Sound } from "babylonjs/Audio/sound";
  38432. import { Analyser } from "babylonjs/Audio/analyser";
  38433. import { Scene } from "babylonjs/scene";
  38434. /**
  38435. * Options allowed during the creation of a sound track.
  38436. */
  38437. export interface ISoundTrackOptions {
  38438. /**
  38439. * The volume the sound track should take during creation
  38440. */
  38441. volume?: number;
  38442. /**
  38443. * Define if the sound track is the main sound track of the scene
  38444. */
  38445. mainTrack?: boolean;
  38446. }
  38447. /**
  38448. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38449. * It will be also used in a future release to apply effects on a specific track.
  38450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38451. */
  38452. export class SoundTrack {
  38453. /**
  38454. * The unique identifier of the sound track in the scene.
  38455. */
  38456. id: number;
  38457. /**
  38458. * The list of sounds included in the sound track.
  38459. */
  38460. soundCollection: Array<Sound>;
  38461. private _outputAudioNode;
  38462. private _scene;
  38463. private _connectedAnalyser;
  38464. private _options;
  38465. private _isInitialized;
  38466. /**
  38467. * Creates a new sound track.
  38468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38469. * @param scene Define the scene the sound track belongs to
  38470. * @param options
  38471. */
  38472. constructor(scene: Scene, options?: ISoundTrackOptions);
  38473. private _initializeSoundTrackAudioGraph;
  38474. /**
  38475. * Release the sound track and its associated resources
  38476. */
  38477. dispose(): void;
  38478. /**
  38479. * Adds a sound to this sound track
  38480. * @param sound define the cound to add
  38481. * @ignoreNaming
  38482. */
  38483. AddSound(sound: Sound): void;
  38484. /**
  38485. * Removes a sound to this sound track
  38486. * @param sound define the cound to remove
  38487. * @ignoreNaming
  38488. */
  38489. RemoveSound(sound: Sound): void;
  38490. /**
  38491. * Set a global volume for the full sound track.
  38492. * @param newVolume Define the new volume of the sound track
  38493. */
  38494. setVolume(newVolume: number): void;
  38495. /**
  38496. * Switch the panning model to HRTF:
  38497. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38499. */
  38500. switchPanningModelToHRTF(): void;
  38501. /**
  38502. * Switch the panning model to Equal Power:
  38503. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38505. */
  38506. switchPanningModelToEqualPower(): void;
  38507. /**
  38508. * Connect the sound track to an audio analyser allowing some amazing
  38509. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38511. * @param analyser The analyser to connect to the engine
  38512. */
  38513. connectToAnalyser(analyser: Analyser): void;
  38514. }
  38515. }
  38516. declare module "babylonjs/Audio/audioSceneComponent" {
  38517. import { Sound } from "babylonjs/Audio/sound";
  38518. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38519. import { Nullable } from "babylonjs/types";
  38520. import { Vector3 } from "babylonjs/Maths/math.vector";
  38521. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38522. import { Scene } from "babylonjs/scene";
  38523. import { AbstractScene } from "babylonjs/abstractScene";
  38524. import "babylonjs/Audio/audioEngine";
  38525. module "babylonjs/abstractScene" {
  38526. interface AbstractScene {
  38527. /**
  38528. * The list of sounds used in the scene.
  38529. */
  38530. sounds: Nullable<Array<Sound>>;
  38531. }
  38532. }
  38533. module "babylonjs/scene" {
  38534. interface Scene {
  38535. /**
  38536. * @hidden
  38537. * Backing field
  38538. */
  38539. _mainSoundTrack: SoundTrack;
  38540. /**
  38541. * The main sound track played by the scene.
  38542. * It cotains your primary collection of sounds.
  38543. */
  38544. mainSoundTrack: SoundTrack;
  38545. /**
  38546. * The list of sound tracks added to the scene
  38547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38548. */
  38549. soundTracks: Nullable<Array<SoundTrack>>;
  38550. /**
  38551. * Gets a sound using a given name
  38552. * @param name defines the name to search for
  38553. * @return the found sound or null if not found at all.
  38554. */
  38555. getSoundByName(name: string): Nullable<Sound>;
  38556. /**
  38557. * Gets or sets if audio support is enabled
  38558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38559. */
  38560. audioEnabled: boolean;
  38561. /**
  38562. * Gets or sets if audio will be output to headphones
  38563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38564. */
  38565. headphone: boolean;
  38566. /**
  38567. * Gets or sets custom audio listener position provider
  38568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38569. */
  38570. audioListenerPositionProvider: Nullable<() => Vector3>;
  38571. /**
  38572. * Gets or sets a refresh rate when using 3D audio positioning
  38573. */
  38574. audioPositioningRefreshRate: number;
  38575. }
  38576. }
  38577. /**
  38578. * Defines the sound scene component responsible to manage any sounds
  38579. * in a given scene.
  38580. */
  38581. export class AudioSceneComponent implements ISceneSerializableComponent {
  38582. /**
  38583. * The component name helpfull to identify the component in the list of scene components.
  38584. */
  38585. readonly name: string;
  38586. /**
  38587. * The scene the component belongs to.
  38588. */
  38589. scene: Scene;
  38590. private _audioEnabled;
  38591. /**
  38592. * Gets whether audio is enabled or not.
  38593. * Please use related enable/disable method to switch state.
  38594. */
  38595. get audioEnabled(): boolean;
  38596. private _headphone;
  38597. /**
  38598. * Gets whether audio is outputing to headphone or not.
  38599. * Please use the according Switch methods to change output.
  38600. */
  38601. get headphone(): boolean;
  38602. /**
  38603. * Gets or sets a refresh rate when using 3D audio positioning
  38604. */
  38605. audioPositioningRefreshRate: number;
  38606. private _audioListenerPositionProvider;
  38607. /**
  38608. * Gets the current audio listener position provider
  38609. */
  38610. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38611. /**
  38612. * Sets a custom listener position for all sounds in the scene
  38613. * By default, this is the position of the first active camera
  38614. */
  38615. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38616. /**
  38617. * Creates a new instance of the component for the given scene
  38618. * @param scene Defines the scene to register the component in
  38619. */
  38620. constructor(scene: Scene);
  38621. /**
  38622. * Registers the component in a given scene
  38623. */
  38624. register(): void;
  38625. /**
  38626. * Rebuilds the elements related to this component in case of
  38627. * context lost for instance.
  38628. */
  38629. rebuild(): void;
  38630. /**
  38631. * Serializes the component data to the specified json object
  38632. * @param serializationObject The object to serialize to
  38633. */
  38634. serialize(serializationObject: any): void;
  38635. /**
  38636. * Adds all the elements from the container to the scene
  38637. * @param container the container holding the elements
  38638. */
  38639. addFromContainer(container: AbstractScene): void;
  38640. /**
  38641. * Removes all the elements in the container from the scene
  38642. * @param container contains the elements to remove
  38643. * @param dispose if the removed element should be disposed (default: false)
  38644. */
  38645. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38646. /**
  38647. * Disposes the component and the associated ressources.
  38648. */
  38649. dispose(): void;
  38650. /**
  38651. * Disables audio in the associated scene.
  38652. */
  38653. disableAudio(): void;
  38654. /**
  38655. * Enables audio in the associated scene.
  38656. */
  38657. enableAudio(): void;
  38658. /**
  38659. * Switch audio to headphone output.
  38660. */
  38661. switchAudioModeForHeadphones(): void;
  38662. /**
  38663. * Switch audio to normal speakers.
  38664. */
  38665. switchAudioModeForNormalSpeakers(): void;
  38666. private _cachedCameraDirection;
  38667. private _cachedCameraPosition;
  38668. private _lastCheck;
  38669. private _afterRender;
  38670. }
  38671. }
  38672. declare module "babylonjs/Audio/weightedsound" {
  38673. import { Sound } from "babylonjs/Audio/sound";
  38674. /**
  38675. * Wraps one or more Sound objects and selects one with random weight for playback.
  38676. */
  38677. export class WeightedSound {
  38678. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38679. loop: boolean;
  38680. private _coneInnerAngle;
  38681. private _coneOuterAngle;
  38682. private _volume;
  38683. /** A Sound is currently playing. */
  38684. isPlaying: boolean;
  38685. /** A Sound is currently paused. */
  38686. isPaused: boolean;
  38687. private _sounds;
  38688. private _weights;
  38689. private _currentIndex?;
  38690. /**
  38691. * Creates a new WeightedSound from the list of sounds given.
  38692. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38693. * @param sounds Array of Sounds that will be selected from.
  38694. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38695. */
  38696. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38697. /**
  38698. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38699. */
  38700. get directionalConeInnerAngle(): number;
  38701. /**
  38702. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38703. */
  38704. set directionalConeInnerAngle(value: number);
  38705. /**
  38706. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38707. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38708. */
  38709. get directionalConeOuterAngle(): number;
  38710. /**
  38711. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38712. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38713. */
  38714. set directionalConeOuterAngle(value: number);
  38715. /**
  38716. * Playback volume.
  38717. */
  38718. get volume(): number;
  38719. /**
  38720. * Playback volume.
  38721. */
  38722. set volume(value: number);
  38723. private _onended;
  38724. /**
  38725. * Suspend playback
  38726. */
  38727. pause(): void;
  38728. /**
  38729. * Stop playback
  38730. */
  38731. stop(): void;
  38732. /**
  38733. * Start playback.
  38734. * @param startOffset Position the clip head at a specific time in seconds.
  38735. */
  38736. play(startOffset?: number): void;
  38737. }
  38738. }
  38739. declare module "babylonjs/Audio/index" {
  38740. export * from "babylonjs/Audio/analyser";
  38741. export * from "babylonjs/Audio/audioEngine";
  38742. export * from "babylonjs/Audio/audioSceneComponent";
  38743. export * from "babylonjs/Audio/sound";
  38744. export * from "babylonjs/Audio/soundTrack";
  38745. export * from "babylonjs/Audio/weightedsound";
  38746. }
  38747. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38748. import { Behavior } from "babylonjs/Behaviors/behavior";
  38749. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38750. import { BackEase } from "babylonjs/Animations/easing";
  38751. /**
  38752. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38754. */
  38755. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38756. /**
  38757. * Gets the name of the behavior.
  38758. */
  38759. get name(): string;
  38760. /**
  38761. * The easing function used by animations
  38762. */
  38763. static EasingFunction: BackEase;
  38764. /**
  38765. * The easing mode used by animations
  38766. */
  38767. static EasingMode: number;
  38768. /**
  38769. * The duration of the animation, in milliseconds
  38770. */
  38771. transitionDuration: number;
  38772. /**
  38773. * Length of the distance animated by the transition when lower radius is reached
  38774. */
  38775. lowerRadiusTransitionRange: number;
  38776. /**
  38777. * Length of the distance animated by the transition when upper radius is reached
  38778. */
  38779. upperRadiusTransitionRange: number;
  38780. private _autoTransitionRange;
  38781. /**
  38782. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38783. */
  38784. get autoTransitionRange(): boolean;
  38785. /**
  38786. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38787. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38788. */
  38789. set autoTransitionRange(value: boolean);
  38790. private _attachedCamera;
  38791. private _onAfterCheckInputsObserver;
  38792. private _onMeshTargetChangedObserver;
  38793. /**
  38794. * Initializes the behavior.
  38795. */
  38796. init(): void;
  38797. /**
  38798. * Attaches the behavior to its arc rotate camera.
  38799. * @param camera Defines the camera to attach the behavior to
  38800. */
  38801. attach(camera: ArcRotateCamera): void;
  38802. /**
  38803. * Detaches the behavior from its current arc rotate camera.
  38804. */
  38805. detach(): void;
  38806. private _radiusIsAnimating;
  38807. private _radiusBounceTransition;
  38808. private _animatables;
  38809. private _cachedWheelPrecision;
  38810. /**
  38811. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38812. * @param radiusLimit The limit to check against.
  38813. * @return Bool to indicate if at limit.
  38814. */
  38815. private _isRadiusAtLimit;
  38816. /**
  38817. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38818. * @param radiusDelta The delta by which to animate to. Can be negative.
  38819. */
  38820. private _applyBoundRadiusAnimation;
  38821. /**
  38822. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38823. */
  38824. protected _clearAnimationLocks(): void;
  38825. /**
  38826. * Stops and removes all animations that have been applied to the camera
  38827. */
  38828. stopAllAnimations(): void;
  38829. }
  38830. }
  38831. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38832. import { Behavior } from "babylonjs/Behaviors/behavior";
  38833. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38834. import { ExponentialEase } from "babylonjs/Animations/easing";
  38835. import { Nullable } from "babylonjs/types";
  38836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38837. import { Vector3 } from "babylonjs/Maths/math.vector";
  38838. /**
  38839. * 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.
  38840. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38841. */
  38842. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38843. /**
  38844. * Gets the name of the behavior.
  38845. */
  38846. get name(): string;
  38847. private _mode;
  38848. private _radiusScale;
  38849. private _positionScale;
  38850. private _defaultElevation;
  38851. private _elevationReturnTime;
  38852. private _elevationReturnWaitTime;
  38853. private _zoomStopsAnimation;
  38854. private _framingTime;
  38855. /**
  38856. * The easing function used by animations
  38857. */
  38858. static EasingFunction: ExponentialEase;
  38859. /**
  38860. * The easing mode used by animations
  38861. */
  38862. static EasingMode: number;
  38863. /**
  38864. * Sets the current mode used by the behavior
  38865. */
  38866. set mode(mode: number);
  38867. /**
  38868. * Gets current mode used by the behavior.
  38869. */
  38870. get mode(): number;
  38871. /**
  38872. * Sets the scale applied to the radius (1 by default)
  38873. */
  38874. set radiusScale(radius: number);
  38875. /**
  38876. * Gets the scale applied to the radius
  38877. */
  38878. get radiusScale(): number;
  38879. /**
  38880. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38881. */
  38882. set positionScale(scale: number);
  38883. /**
  38884. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38885. */
  38886. get positionScale(): number;
  38887. /**
  38888. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38889. * behaviour is triggered, in radians.
  38890. */
  38891. set defaultElevation(elevation: number);
  38892. /**
  38893. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38894. * behaviour is triggered, in radians.
  38895. */
  38896. get defaultElevation(): number;
  38897. /**
  38898. * Sets the time (in milliseconds) taken to return to the default beta position.
  38899. * Negative value indicates camera should not return to default.
  38900. */
  38901. set elevationReturnTime(speed: number);
  38902. /**
  38903. * Gets the time (in milliseconds) taken to return to the default beta position.
  38904. * Negative value indicates camera should not return to default.
  38905. */
  38906. get elevationReturnTime(): number;
  38907. /**
  38908. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38909. */
  38910. set elevationReturnWaitTime(time: number);
  38911. /**
  38912. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38913. */
  38914. get elevationReturnWaitTime(): number;
  38915. /**
  38916. * Sets the flag that indicates if user zooming should stop animation.
  38917. */
  38918. set zoomStopsAnimation(flag: boolean);
  38919. /**
  38920. * Gets the flag that indicates if user zooming should stop animation.
  38921. */
  38922. get zoomStopsAnimation(): boolean;
  38923. /**
  38924. * Sets the transition time when framing the mesh, in milliseconds
  38925. */
  38926. set framingTime(time: number);
  38927. /**
  38928. * Gets the transition time when framing the mesh, in milliseconds
  38929. */
  38930. get framingTime(): number;
  38931. /**
  38932. * Define if the behavior should automatically change the configured
  38933. * camera limits and sensibilities.
  38934. */
  38935. autoCorrectCameraLimitsAndSensibility: boolean;
  38936. private _onPrePointerObservableObserver;
  38937. private _onAfterCheckInputsObserver;
  38938. private _onMeshTargetChangedObserver;
  38939. private _attachedCamera;
  38940. private _isPointerDown;
  38941. private _lastInteractionTime;
  38942. /**
  38943. * Initializes the behavior.
  38944. */
  38945. init(): void;
  38946. /**
  38947. * Attaches the behavior to its arc rotate camera.
  38948. * @param camera Defines the camera to attach the behavior to
  38949. */
  38950. attach(camera: ArcRotateCamera): void;
  38951. /**
  38952. * Detaches the behavior from its current arc rotate camera.
  38953. */
  38954. detach(): void;
  38955. private _animatables;
  38956. private _betaIsAnimating;
  38957. private _betaTransition;
  38958. private _radiusTransition;
  38959. private _vectorTransition;
  38960. /**
  38961. * Targets the given mesh and updates zoom level accordingly.
  38962. * @param mesh The mesh to target.
  38963. * @param radius Optional. If a cached radius position already exists, overrides default.
  38964. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38965. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38966. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38967. */
  38968. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38969. /**
  38970. * Targets the given mesh with its children and updates zoom level accordingly.
  38971. * @param mesh The mesh to target.
  38972. * @param radius Optional. If a cached radius position already exists, overrides default.
  38973. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38974. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38975. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38976. */
  38977. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38978. /**
  38979. * Targets the given meshes with their children and updates zoom level accordingly.
  38980. * @param meshes The mesh to target.
  38981. * @param radius Optional. If a cached radius position already exists, overrides default.
  38982. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38983. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38984. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38985. */
  38986. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38987. /**
  38988. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38989. * @param minimumWorld Determines the smaller position of the bounding box extend
  38990. * @param maximumWorld Determines the bigger position of the bounding box extend
  38991. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38992. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38993. */
  38994. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38995. /**
  38996. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38997. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38998. * frustum width.
  38999. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39000. * to fully enclose the mesh in the viewing frustum.
  39001. */
  39002. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39003. /**
  39004. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39005. * is automatically returned to its default position (expected to be above ground plane).
  39006. */
  39007. private _maintainCameraAboveGround;
  39008. /**
  39009. * Returns the frustum slope based on the canvas ratio and camera FOV
  39010. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39011. */
  39012. private _getFrustumSlope;
  39013. /**
  39014. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39015. */
  39016. private _clearAnimationLocks;
  39017. /**
  39018. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39019. */
  39020. private _applyUserInteraction;
  39021. /**
  39022. * Stops and removes all animations that have been applied to the camera
  39023. */
  39024. stopAllAnimations(): void;
  39025. /**
  39026. * Gets a value indicating if the user is moving the camera
  39027. */
  39028. get isUserIsMoving(): boolean;
  39029. /**
  39030. * The camera can move all the way towards the mesh.
  39031. */
  39032. static IgnoreBoundsSizeMode: number;
  39033. /**
  39034. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39035. */
  39036. static FitFrustumSidesMode: number;
  39037. }
  39038. }
  39039. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39040. import { Nullable } from "babylonjs/types";
  39041. import { Camera } from "babylonjs/Cameras/camera";
  39042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39043. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39044. /**
  39045. * Base class for Camera Pointer Inputs.
  39046. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39047. * for example usage.
  39048. */
  39049. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39050. /**
  39051. * Defines the camera the input is attached to.
  39052. */
  39053. abstract camera: Camera;
  39054. /**
  39055. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39056. */
  39057. protected _altKey: boolean;
  39058. protected _ctrlKey: boolean;
  39059. protected _metaKey: boolean;
  39060. protected _shiftKey: boolean;
  39061. /**
  39062. * Which mouse buttons were pressed at time of last mouse event.
  39063. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39064. */
  39065. protected _buttonsPressed: number;
  39066. /**
  39067. * Defines the buttons associated with the input to handle camera move.
  39068. */
  39069. buttons: number[];
  39070. /**
  39071. * Attach the input controls to a specific dom element to get the input from.
  39072. * @param element Defines the element the controls should be listened from
  39073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39074. */
  39075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39076. /**
  39077. * Detach the current controls from the specified dom element.
  39078. * @param element Defines the element to stop listening the inputs from
  39079. */
  39080. detachControl(element: Nullable<HTMLElement>): void;
  39081. /**
  39082. * Gets the class name of the current input.
  39083. * @returns the class name
  39084. */
  39085. getClassName(): string;
  39086. /**
  39087. * Get the friendly name associated with the input class.
  39088. * @returns the input friendly name
  39089. */
  39090. getSimpleName(): string;
  39091. /**
  39092. * Called on pointer POINTERDOUBLETAP event.
  39093. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39094. */
  39095. protected onDoubleTap(type: string): void;
  39096. /**
  39097. * Called on pointer POINTERMOVE event if only a single touch is active.
  39098. * Override this method to provide functionality.
  39099. */
  39100. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39101. /**
  39102. * Called on pointer POINTERMOVE event if multiple touches are active.
  39103. * Override this method to provide functionality.
  39104. */
  39105. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39106. /**
  39107. * Called on JS contextmenu event.
  39108. * Override this method to provide functionality.
  39109. */
  39110. protected onContextMenu(evt: PointerEvent): void;
  39111. /**
  39112. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39113. * press.
  39114. * Override this method to provide functionality.
  39115. */
  39116. protected onButtonDown(evt: PointerEvent): void;
  39117. /**
  39118. * Called each time a new POINTERUP event occurs. Ie, for each button
  39119. * release.
  39120. * Override this method to provide functionality.
  39121. */
  39122. protected onButtonUp(evt: PointerEvent): void;
  39123. /**
  39124. * Called when window becomes inactive.
  39125. * Override this method to provide functionality.
  39126. */
  39127. protected onLostFocus(): void;
  39128. private _pointerInput;
  39129. private _observer;
  39130. private _onLostFocus;
  39131. private pointA;
  39132. private pointB;
  39133. }
  39134. }
  39135. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39136. import { Nullable } from "babylonjs/types";
  39137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39138. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39139. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39140. /**
  39141. * Manage the pointers inputs to control an arc rotate camera.
  39142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39143. */
  39144. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39145. /**
  39146. * Defines the camera the input is attached to.
  39147. */
  39148. camera: ArcRotateCamera;
  39149. /**
  39150. * Gets the class name of the current input.
  39151. * @returns the class name
  39152. */
  39153. getClassName(): string;
  39154. /**
  39155. * Defines the buttons associated with the input to handle camera move.
  39156. */
  39157. buttons: number[];
  39158. /**
  39159. * Defines the pointer angular sensibility along the X axis or how fast is
  39160. * the camera rotating.
  39161. */
  39162. angularSensibilityX: number;
  39163. /**
  39164. * Defines the pointer angular sensibility along the Y axis or how fast is
  39165. * the camera rotating.
  39166. */
  39167. angularSensibilityY: number;
  39168. /**
  39169. * Defines the pointer pinch precision or how fast is the camera zooming.
  39170. */
  39171. pinchPrecision: number;
  39172. /**
  39173. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39174. * from 0.
  39175. * It defines the percentage of current camera.radius to use as delta when
  39176. * pinch zoom is used.
  39177. */
  39178. pinchDeltaPercentage: number;
  39179. /**
  39180. * Defines the pointer panning sensibility or how fast is the camera moving.
  39181. */
  39182. panningSensibility: number;
  39183. /**
  39184. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39185. */
  39186. multiTouchPanning: boolean;
  39187. /**
  39188. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39189. * zoom (pinch) through multitouch.
  39190. */
  39191. multiTouchPanAndZoom: boolean;
  39192. /**
  39193. * Revers pinch action direction.
  39194. */
  39195. pinchInwards: boolean;
  39196. private _isPanClick;
  39197. private _twoFingerActivityCount;
  39198. private _isPinching;
  39199. /**
  39200. * Called on pointer POINTERMOVE event if only a single touch is active.
  39201. */
  39202. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39203. /**
  39204. * Called on pointer POINTERDOUBLETAP event.
  39205. */
  39206. protected onDoubleTap(type: string): void;
  39207. /**
  39208. * Called on pointer POINTERMOVE event if multiple touches are active.
  39209. */
  39210. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39211. /**
  39212. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39213. * press.
  39214. */
  39215. protected onButtonDown(evt: PointerEvent): void;
  39216. /**
  39217. * Called each time a new POINTERUP event occurs. Ie, for each button
  39218. * release.
  39219. */
  39220. protected onButtonUp(evt: PointerEvent): void;
  39221. /**
  39222. * Called when window becomes inactive.
  39223. */
  39224. protected onLostFocus(): void;
  39225. }
  39226. }
  39227. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39228. import { Nullable } from "babylonjs/types";
  39229. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39230. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39231. /**
  39232. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39234. */
  39235. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39236. /**
  39237. * Defines the camera the input is attached to.
  39238. */
  39239. camera: ArcRotateCamera;
  39240. /**
  39241. * Defines the list of key codes associated with the up action (increase alpha)
  39242. */
  39243. keysUp: number[];
  39244. /**
  39245. * Defines the list of key codes associated with the down action (decrease alpha)
  39246. */
  39247. keysDown: number[];
  39248. /**
  39249. * Defines the list of key codes associated with the left action (increase beta)
  39250. */
  39251. keysLeft: number[];
  39252. /**
  39253. * Defines the list of key codes associated with the right action (decrease beta)
  39254. */
  39255. keysRight: number[];
  39256. /**
  39257. * Defines the list of key codes associated with the reset action.
  39258. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39259. */
  39260. keysReset: number[];
  39261. /**
  39262. * Defines the panning sensibility of the inputs.
  39263. * (How fast is the camera paning)
  39264. */
  39265. panningSensibility: number;
  39266. /**
  39267. * Defines the zooming sensibility of the inputs.
  39268. * (How fast is the camera zooming)
  39269. */
  39270. zoomingSensibility: number;
  39271. /**
  39272. * Defines wether maintaining the alt key down switch the movement mode from
  39273. * orientation to zoom.
  39274. */
  39275. useAltToZoom: boolean;
  39276. /**
  39277. * Rotation speed of the camera
  39278. */
  39279. angularSpeed: number;
  39280. private _keys;
  39281. private _ctrlPressed;
  39282. private _altPressed;
  39283. private _onCanvasBlurObserver;
  39284. private _onKeyboardObserver;
  39285. private _engine;
  39286. private _scene;
  39287. /**
  39288. * Attach the input controls to a specific dom element to get the input from.
  39289. * @param element Defines the element the controls should be listened from
  39290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39291. */
  39292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39293. /**
  39294. * Detach the current controls from the specified dom element.
  39295. * @param element Defines the element to stop listening the inputs from
  39296. */
  39297. detachControl(element: Nullable<HTMLElement>): void;
  39298. /**
  39299. * Update the current camera state depending on the inputs that have been used this frame.
  39300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39301. */
  39302. checkInputs(): void;
  39303. /**
  39304. * Gets the class name of the current intput.
  39305. * @returns the class name
  39306. */
  39307. getClassName(): string;
  39308. /**
  39309. * Get the friendly name associated with the input class.
  39310. * @returns the input friendly name
  39311. */
  39312. getSimpleName(): string;
  39313. }
  39314. }
  39315. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39316. import { Nullable } from "babylonjs/types";
  39317. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39318. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39319. /**
  39320. * Manage the mouse wheel inputs to control an arc rotate camera.
  39321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39322. */
  39323. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39324. /**
  39325. * Defines the camera the input is attached to.
  39326. */
  39327. camera: ArcRotateCamera;
  39328. /**
  39329. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39330. */
  39331. wheelPrecision: number;
  39332. /**
  39333. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39334. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39335. */
  39336. wheelDeltaPercentage: number;
  39337. private _wheel;
  39338. private _observer;
  39339. private computeDeltaFromMouseWheelLegacyEvent;
  39340. /**
  39341. * Attach the input controls to a specific dom element to get the input from.
  39342. * @param element Defines the element the controls should be listened from
  39343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39344. */
  39345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39346. /**
  39347. * Detach the current controls from the specified dom element.
  39348. * @param element Defines the element to stop listening the inputs from
  39349. */
  39350. detachControl(element: Nullable<HTMLElement>): void;
  39351. /**
  39352. * Gets the class name of the current intput.
  39353. * @returns the class name
  39354. */
  39355. getClassName(): string;
  39356. /**
  39357. * Get the friendly name associated with the input class.
  39358. * @returns the input friendly name
  39359. */
  39360. getSimpleName(): string;
  39361. }
  39362. }
  39363. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39364. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39365. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39366. /**
  39367. * Default Inputs manager for the ArcRotateCamera.
  39368. * It groups all the default supported inputs for ease of use.
  39369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39370. */
  39371. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39372. /**
  39373. * Instantiates a new ArcRotateCameraInputsManager.
  39374. * @param camera Defines the camera the inputs belong to
  39375. */
  39376. constructor(camera: ArcRotateCamera);
  39377. /**
  39378. * Add mouse wheel input support to the input manager.
  39379. * @returns the current input manager
  39380. */
  39381. addMouseWheel(): ArcRotateCameraInputsManager;
  39382. /**
  39383. * Add pointers input support to the input manager.
  39384. * @returns the current input manager
  39385. */
  39386. addPointers(): ArcRotateCameraInputsManager;
  39387. /**
  39388. * Add keyboard input support to the input manager.
  39389. * @returns the current input manager
  39390. */
  39391. addKeyboard(): ArcRotateCameraInputsManager;
  39392. }
  39393. }
  39394. declare module "babylonjs/Cameras/arcRotateCamera" {
  39395. import { Observable } from "babylonjs/Misc/observable";
  39396. import { Nullable } from "babylonjs/types";
  39397. import { Scene } from "babylonjs/scene";
  39398. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39400. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39401. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39402. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39403. import { Camera } from "babylonjs/Cameras/camera";
  39404. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39405. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39406. import { Collider } from "babylonjs/Collisions/collider";
  39407. /**
  39408. * This represents an orbital type of camera.
  39409. *
  39410. * 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.
  39411. * 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.
  39412. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39413. */
  39414. export class ArcRotateCamera extends TargetCamera {
  39415. /**
  39416. * Defines the rotation angle of the camera along the longitudinal axis.
  39417. */
  39418. alpha: number;
  39419. /**
  39420. * Defines the rotation angle of the camera along the latitudinal axis.
  39421. */
  39422. beta: number;
  39423. /**
  39424. * Defines the radius of the camera from it s target point.
  39425. */
  39426. radius: number;
  39427. protected _target: Vector3;
  39428. protected _targetHost: Nullable<AbstractMesh>;
  39429. /**
  39430. * Defines the target point of the camera.
  39431. * The camera looks towards it form the radius distance.
  39432. */
  39433. get target(): Vector3;
  39434. set target(value: Vector3);
  39435. /**
  39436. * Define the current local position of the camera in the scene
  39437. */
  39438. get position(): Vector3;
  39439. set position(newPosition: Vector3);
  39440. protected _upVector: Vector3;
  39441. protected _upToYMatrix: Matrix;
  39442. protected _YToUpMatrix: Matrix;
  39443. /**
  39444. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39445. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39446. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39447. */
  39448. set upVector(vec: Vector3);
  39449. get upVector(): Vector3;
  39450. /**
  39451. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39452. */
  39453. setMatUp(): void;
  39454. /**
  39455. * Current inertia value on the longitudinal axis.
  39456. * The bigger this number the longer it will take for the camera to stop.
  39457. */
  39458. inertialAlphaOffset: number;
  39459. /**
  39460. * Current inertia value on the latitudinal axis.
  39461. * The bigger this number the longer it will take for the camera to stop.
  39462. */
  39463. inertialBetaOffset: number;
  39464. /**
  39465. * Current inertia value on the radius axis.
  39466. * The bigger this number the longer it will take for the camera to stop.
  39467. */
  39468. inertialRadiusOffset: number;
  39469. /**
  39470. * Minimum allowed angle on the longitudinal axis.
  39471. * This can help limiting how the Camera is able to move in the scene.
  39472. */
  39473. lowerAlphaLimit: Nullable<number>;
  39474. /**
  39475. * Maximum allowed angle on the longitudinal axis.
  39476. * This can help limiting how the Camera is able to move in the scene.
  39477. */
  39478. upperAlphaLimit: Nullable<number>;
  39479. /**
  39480. * Minimum allowed angle on the latitudinal axis.
  39481. * This can help limiting how the Camera is able to move in the scene.
  39482. */
  39483. lowerBetaLimit: number;
  39484. /**
  39485. * Maximum allowed angle on the latitudinal axis.
  39486. * This can help limiting how the Camera is able to move in the scene.
  39487. */
  39488. upperBetaLimit: number;
  39489. /**
  39490. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39491. * This can help limiting how the Camera is able to move in the scene.
  39492. */
  39493. lowerRadiusLimit: Nullable<number>;
  39494. /**
  39495. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39496. * This can help limiting how the Camera is able to move in the scene.
  39497. */
  39498. upperRadiusLimit: Nullable<number>;
  39499. /**
  39500. * Defines the current inertia value used during panning of the camera along the X axis.
  39501. */
  39502. inertialPanningX: number;
  39503. /**
  39504. * Defines the current inertia value used during panning of the camera along the Y axis.
  39505. */
  39506. inertialPanningY: number;
  39507. /**
  39508. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39509. * Basically if your fingers moves away from more than this distance you will be considered
  39510. * in pinch mode.
  39511. */
  39512. pinchToPanMaxDistance: number;
  39513. /**
  39514. * Defines the maximum distance the camera can pan.
  39515. * This could help keeping the cammera always in your scene.
  39516. */
  39517. panningDistanceLimit: Nullable<number>;
  39518. /**
  39519. * Defines the target of the camera before paning.
  39520. */
  39521. panningOriginTarget: Vector3;
  39522. /**
  39523. * Defines the value of the inertia used during panning.
  39524. * 0 would mean stop inertia and one would mean no decelleration at all.
  39525. */
  39526. panningInertia: number;
  39527. /**
  39528. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39529. */
  39530. get angularSensibilityX(): number;
  39531. set angularSensibilityX(value: number);
  39532. /**
  39533. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39534. */
  39535. get angularSensibilityY(): number;
  39536. set angularSensibilityY(value: number);
  39537. /**
  39538. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39539. */
  39540. get pinchPrecision(): number;
  39541. set pinchPrecision(value: number);
  39542. /**
  39543. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39544. * It will be used instead of pinchDeltaPrecision if different from 0.
  39545. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39546. */
  39547. get pinchDeltaPercentage(): number;
  39548. set pinchDeltaPercentage(value: number);
  39549. /**
  39550. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39551. */
  39552. get panningSensibility(): number;
  39553. set panningSensibility(value: number);
  39554. /**
  39555. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39556. */
  39557. get keysUp(): number[];
  39558. set keysUp(value: number[]);
  39559. /**
  39560. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39561. */
  39562. get keysDown(): number[];
  39563. set keysDown(value: number[]);
  39564. /**
  39565. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39566. */
  39567. get keysLeft(): number[];
  39568. set keysLeft(value: number[]);
  39569. /**
  39570. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39571. */
  39572. get keysRight(): number[];
  39573. set keysRight(value: number[]);
  39574. /**
  39575. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39576. */
  39577. get wheelPrecision(): number;
  39578. set wheelPrecision(value: number);
  39579. /**
  39580. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39581. * It will be used instead of pinchDeltaPrecision if different from 0.
  39582. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39583. */
  39584. get wheelDeltaPercentage(): number;
  39585. set wheelDeltaPercentage(value: number);
  39586. /**
  39587. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39588. */
  39589. zoomOnFactor: number;
  39590. /**
  39591. * Defines a screen offset for the camera position.
  39592. */
  39593. targetScreenOffset: Vector2;
  39594. /**
  39595. * Allows the camera to be completely reversed.
  39596. * If false the camera can not arrive upside down.
  39597. */
  39598. allowUpsideDown: boolean;
  39599. /**
  39600. * Define if double tap/click is used to restore the previously saved state of the camera.
  39601. */
  39602. useInputToRestoreState: boolean;
  39603. /** @hidden */
  39604. _viewMatrix: Matrix;
  39605. /** @hidden */
  39606. _useCtrlForPanning: boolean;
  39607. /** @hidden */
  39608. _panningMouseButton: number;
  39609. /**
  39610. * Defines the input associated to the camera.
  39611. */
  39612. inputs: ArcRotateCameraInputsManager;
  39613. /** @hidden */
  39614. _reset: () => void;
  39615. /**
  39616. * Defines the allowed panning axis.
  39617. */
  39618. panningAxis: Vector3;
  39619. protected _localDirection: Vector3;
  39620. protected _transformedDirection: Vector3;
  39621. private _bouncingBehavior;
  39622. /**
  39623. * Gets the bouncing behavior of the camera if it has been enabled.
  39624. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39625. */
  39626. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39627. /**
  39628. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39629. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39630. */
  39631. get useBouncingBehavior(): boolean;
  39632. set useBouncingBehavior(value: boolean);
  39633. private _framingBehavior;
  39634. /**
  39635. * Gets the framing behavior of the camera if it has been enabled.
  39636. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39637. */
  39638. get framingBehavior(): Nullable<FramingBehavior>;
  39639. /**
  39640. * Defines if the framing behavior of the camera is enabled on the camera.
  39641. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39642. */
  39643. get useFramingBehavior(): boolean;
  39644. set useFramingBehavior(value: boolean);
  39645. private _autoRotationBehavior;
  39646. /**
  39647. * Gets the auto rotation behavior of the camera if it has been enabled.
  39648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39649. */
  39650. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39651. /**
  39652. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39653. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39654. */
  39655. get useAutoRotationBehavior(): boolean;
  39656. set useAutoRotationBehavior(value: boolean);
  39657. /**
  39658. * Observable triggered when the mesh target has been changed on the camera.
  39659. */
  39660. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39661. /**
  39662. * Event raised when the camera is colliding with a mesh.
  39663. */
  39664. onCollide: (collidedMesh: AbstractMesh) => void;
  39665. /**
  39666. * Defines whether the camera should check collision with the objects oh the scene.
  39667. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39668. */
  39669. checkCollisions: boolean;
  39670. /**
  39671. * Defines the collision radius of the camera.
  39672. * This simulates a sphere around the camera.
  39673. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39674. */
  39675. collisionRadius: Vector3;
  39676. protected _collider: Collider;
  39677. protected _previousPosition: Vector3;
  39678. protected _collisionVelocity: Vector3;
  39679. protected _newPosition: Vector3;
  39680. protected _previousAlpha: number;
  39681. protected _previousBeta: number;
  39682. protected _previousRadius: number;
  39683. protected _collisionTriggered: boolean;
  39684. protected _targetBoundingCenter: Nullable<Vector3>;
  39685. private _computationVector;
  39686. /**
  39687. * Instantiates a new ArcRotateCamera in a given scene
  39688. * @param name Defines the name of the camera
  39689. * @param alpha Defines the camera rotation along the logitudinal axis
  39690. * @param beta Defines the camera rotation along the latitudinal axis
  39691. * @param radius Defines the camera distance from its target
  39692. * @param target Defines the camera target
  39693. * @param scene Defines the scene the camera belongs to
  39694. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39695. */
  39696. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39697. /** @hidden */
  39698. _initCache(): void;
  39699. /** @hidden */
  39700. _updateCache(ignoreParentClass?: boolean): void;
  39701. protected _getTargetPosition(): Vector3;
  39702. private _storedAlpha;
  39703. private _storedBeta;
  39704. private _storedRadius;
  39705. private _storedTarget;
  39706. private _storedTargetScreenOffset;
  39707. /**
  39708. * Stores the current state of the camera (alpha, beta, radius and target)
  39709. * @returns the camera itself
  39710. */
  39711. storeState(): Camera;
  39712. /**
  39713. * @hidden
  39714. * Restored camera state. You must call storeState() first
  39715. */
  39716. _restoreStateValues(): boolean;
  39717. /** @hidden */
  39718. _isSynchronizedViewMatrix(): boolean;
  39719. /**
  39720. * Attached controls to the current camera.
  39721. * @param element Defines the element the controls should be listened from
  39722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39723. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39724. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39725. */
  39726. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39727. /**
  39728. * Detach the current controls from the camera.
  39729. * The camera will stop reacting to inputs.
  39730. * @param element Defines the element to stop listening the inputs from
  39731. */
  39732. detachControl(element: HTMLElement): void;
  39733. /** @hidden */
  39734. _checkInputs(): void;
  39735. protected _checkLimits(): void;
  39736. /**
  39737. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39738. */
  39739. rebuildAnglesAndRadius(): void;
  39740. /**
  39741. * Use a position to define the current camera related information like alpha, beta and radius
  39742. * @param position Defines the position to set the camera at
  39743. */
  39744. setPosition(position: Vector3): void;
  39745. /**
  39746. * Defines the target the camera should look at.
  39747. * This will automatically adapt alpha beta and radius to fit within the new target.
  39748. * @param target Defines the new target as a Vector or a mesh
  39749. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39750. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39751. */
  39752. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39753. /** @hidden */
  39754. _getViewMatrix(): Matrix;
  39755. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39756. /**
  39757. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39758. * @param meshes Defines the mesh to zoom on
  39759. * @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)
  39760. */
  39761. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39762. /**
  39763. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39764. * The target will be changed but the radius
  39765. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39766. * @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)
  39767. */
  39768. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39769. min: Vector3;
  39770. max: Vector3;
  39771. distance: number;
  39772. }, doNotUpdateMaxZ?: boolean): void;
  39773. /**
  39774. * @override
  39775. * Override Camera.createRigCamera
  39776. */
  39777. createRigCamera(name: string, cameraIndex: number): Camera;
  39778. /**
  39779. * @hidden
  39780. * @override
  39781. * Override Camera._updateRigCameras
  39782. */
  39783. _updateRigCameras(): void;
  39784. /**
  39785. * Destroy the camera and release the current resources hold by it.
  39786. */
  39787. dispose(): void;
  39788. /**
  39789. * Gets the current object class name.
  39790. * @return the class name
  39791. */
  39792. getClassName(): string;
  39793. }
  39794. }
  39795. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39796. import { Behavior } from "babylonjs/Behaviors/behavior";
  39797. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39798. /**
  39799. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39800. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39801. */
  39802. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39803. /**
  39804. * Gets the name of the behavior.
  39805. */
  39806. get name(): string;
  39807. private _zoomStopsAnimation;
  39808. private _idleRotationSpeed;
  39809. private _idleRotationWaitTime;
  39810. private _idleRotationSpinupTime;
  39811. /**
  39812. * Sets the flag that indicates if user zooming should stop animation.
  39813. */
  39814. set zoomStopsAnimation(flag: boolean);
  39815. /**
  39816. * Gets the flag that indicates if user zooming should stop animation.
  39817. */
  39818. get zoomStopsAnimation(): boolean;
  39819. /**
  39820. * Sets the default speed at which the camera rotates around the model.
  39821. */
  39822. set idleRotationSpeed(speed: number);
  39823. /**
  39824. * Gets the default speed at which the camera rotates around the model.
  39825. */
  39826. get idleRotationSpeed(): number;
  39827. /**
  39828. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39829. */
  39830. set idleRotationWaitTime(time: number);
  39831. /**
  39832. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39833. */
  39834. get idleRotationWaitTime(): number;
  39835. /**
  39836. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39837. */
  39838. set idleRotationSpinupTime(time: number);
  39839. /**
  39840. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39841. */
  39842. get idleRotationSpinupTime(): number;
  39843. /**
  39844. * Gets a value indicating if the camera is currently rotating because of this behavior
  39845. */
  39846. get rotationInProgress(): boolean;
  39847. private _onPrePointerObservableObserver;
  39848. private _onAfterCheckInputsObserver;
  39849. private _attachedCamera;
  39850. private _isPointerDown;
  39851. private _lastFrameTime;
  39852. private _lastInteractionTime;
  39853. private _cameraRotationSpeed;
  39854. /**
  39855. * Initializes the behavior.
  39856. */
  39857. init(): void;
  39858. /**
  39859. * Attaches the behavior to its arc rotate camera.
  39860. * @param camera Defines the camera to attach the behavior to
  39861. */
  39862. attach(camera: ArcRotateCamera): void;
  39863. /**
  39864. * Detaches the behavior from its current arc rotate camera.
  39865. */
  39866. detach(): void;
  39867. /**
  39868. * Returns true if user is scrolling.
  39869. * @return true if user is scrolling.
  39870. */
  39871. private _userIsZooming;
  39872. private _lastFrameRadius;
  39873. private _shouldAnimationStopForInteraction;
  39874. /**
  39875. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39876. */
  39877. private _applyUserInteraction;
  39878. private _userIsMoving;
  39879. }
  39880. }
  39881. declare module "babylonjs/Behaviors/Cameras/index" {
  39882. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39883. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39884. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39885. }
  39886. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39887. import { Mesh } from "babylonjs/Meshes/mesh";
  39888. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39889. import { Behavior } from "babylonjs/Behaviors/behavior";
  39890. /**
  39891. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39892. */
  39893. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39894. private ui;
  39895. /**
  39896. * The name of the behavior
  39897. */
  39898. name: string;
  39899. /**
  39900. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39901. */
  39902. distanceAwayFromFace: number;
  39903. /**
  39904. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39905. */
  39906. distanceAwayFromBottomOfFace: number;
  39907. private _faceVectors;
  39908. private _target;
  39909. private _scene;
  39910. private _onRenderObserver;
  39911. private _tmpMatrix;
  39912. private _tmpVector;
  39913. /**
  39914. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39915. * @param ui The transform node that should be attched to the mesh
  39916. */
  39917. constructor(ui: TransformNode);
  39918. /**
  39919. * Initializes the behavior
  39920. */
  39921. init(): void;
  39922. private _closestFace;
  39923. private _zeroVector;
  39924. private _lookAtTmpMatrix;
  39925. private _lookAtToRef;
  39926. /**
  39927. * Attaches the AttachToBoxBehavior to the passed in mesh
  39928. * @param target The mesh that the specified node will be attached to
  39929. */
  39930. attach(target: Mesh): void;
  39931. /**
  39932. * Detaches the behavior from the mesh
  39933. */
  39934. detach(): void;
  39935. }
  39936. }
  39937. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39938. import { Behavior } from "babylonjs/Behaviors/behavior";
  39939. import { Mesh } from "babylonjs/Meshes/mesh";
  39940. /**
  39941. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39942. */
  39943. export class FadeInOutBehavior implements Behavior<Mesh> {
  39944. /**
  39945. * Time in milliseconds to delay before fading in (Default: 0)
  39946. */
  39947. delay: number;
  39948. /**
  39949. * Time in milliseconds for the mesh to fade in (Default: 300)
  39950. */
  39951. fadeInTime: number;
  39952. private _millisecondsPerFrame;
  39953. private _hovered;
  39954. private _hoverValue;
  39955. private _ownerNode;
  39956. /**
  39957. * Instatiates the FadeInOutBehavior
  39958. */
  39959. constructor();
  39960. /**
  39961. * The name of the behavior
  39962. */
  39963. get name(): string;
  39964. /**
  39965. * Initializes the behavior
  39966. */
  39967. init(): void;
  39968. /**
  39969. * Attaches the fade behavior on the passed in mesh
  39970. * @param ownerNode The mesh that will be faded in/out once attached
  39971. */
  39972. attach(ownerNode: Mesh): void;
  39973. /**
  39974. * Detaches the behavior from the mesh
  39975. */
  39976. detach(): void;
  39977. /**
  39978. * Triggers the mesh to begin fading in or out
  39979. * @param value if the object should fade in or out (true to fade in)
  39980. */
  39981. fadeIn(value: boolean): void;
  39982. private _update;
  39983. private _setAllVisibility;
  39984. }
  39985. }
  39986. declare module "babylonjs/Misc/pivotTools" {
  39987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39988. /**
  39989. * Class containing a set of static utilities functions for managing Pivots
  39990. * @hidden
  39991. */
  39992. export class PivotTools {
  39993. private static _PivotCached;
  39994. private static _OldPivotPoint;
  39995. private static _PivotTranslation;
  39996. private static _PivotTmpVector;
  39997. /** @hidden */
  39998. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39999. /** @hidden */
  40000. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40001. }
  40002. }
  40003. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40004. import { Scene } from "babylonjs/scene";
  40005. import { Vector4 } from "babylonjs/Maths/math.vector";
  40006. import { Mesh } from "babylonjs/Meshes/mesh";
  40007. import { Nullable } from "babylonjs/types";
  40008. import { Plane } from "babylonjs/Maths/math.plane";
  40009. /**
  40010. * Class containing static functions to help procedurally build meshes
  40011. */
  40012. export class PlaneBuilder {
  40013. /**
  40014. * Creates a plane mesh
  40015. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40016. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40017. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40021. * @param name defines the name of the mesh
  40022. * @param options defines the options used to create the mesh
  40023. * @param scene defines the hosting scene
  40024. * @returns the plane mesh
  40025. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40026. */
  40027. static CreatePlane(name: string, options: {
  40028. size?: number;
  40029. width?: number;
  40030. height?: number;
  40031. sideOrientation?: number;
  40032. frontUVs?: Vector4;
  40033. backUVs?: Vector4;
  40034. updatable?: boolean;
  40035. sourcePlane?: Plane;
  40036. }, scene?: Nullable<Scene>): Mesh;
  40037. }
  40038. }
  40039. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40040. import { Behavior } from "babylonjs/Behaviors/behavior";
  40041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40042. import { Observable } from "babylonjs/Misc/observable";
  40043. import { Vector3 } from "babylonjs/Maths/math.vector";
  40044. import { Ray } from "babylonjs/Culling/ray";
  40045. import "babylonjs/Meshes/Builders/planeBuilder";
  40046. /**
  40047. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40048. */
  40049. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40050. private static _AnyMouseID;
  40051. /**
  40052. * Abstract mesh the behavior is set on
  40053. */
  40054. attachedNode: AbstractMesh;
  40055. private _dragPlane;
  40056. private _scene;
  40057. private _pointerObserver;
  40058. private _beforeRenderObserver;
  40059. private static _planeScene;
  40060. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40061. /**
  40062. * 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)
  40063. */
  40064. maxDragAngle: number;
  40065. /**
  40066. * @hidden
  40067. */
  40068. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40069. /**
  40070. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40071. */
  40072. currentDraggingPointerID: number;
  40073. /**
  40074. * The last position where the pointer hit the drag plane in world space
  40075. */
  40076. lastDragPosition: Vector3;
  40077. /**
  40078. * If the behavior is currently in a dragging state
  40079. */
  40080. dragging: boolean;
  40081. /**
  40082. * 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)
  40083. */
  40084. dragDeltaRatio: number;
  40085. /**
  40086. * If the drag plane orientation should be updated during the dragging (Default: true)
  40087. */
  40088. updateDragPlane: boolean;
  40089. private _debugMode;
  40090. private _moving;
  40091. /**
  40092. * Fires each time the attached mesh is dragged with the pointer
  40093. * * delta between last drag position and current drag position in world space
  40094. * * dragDistance along the drag axis
  40095. * * dragPlaneNormal normal of the current drag plane used during the drag
  40096. * * dragPlanePoint in world space where the drag intersects the drag plane
  40097. */
  40098. onDragObservable: Observable<{
  40099. delta: Vector3;
  40100. dragPlanePoint: Vector3;
  40101. dragPlaneNormal: Vector3;
  40102. dragDistance: number;
  40103. pointerId: number;
  40104. }>;
  40105. /**
  40106. * Fires each time a drag begins (eg. mouse down on mesh)
  40107. */
  40108. onDragStartObservable: Observable<{
  40109. dragPlanePoint: Vector3;
  40110. pointerId: number;
  40111. }>;
  40112. /**
  40113. * Fires each time a drag ends (eg. mouse release after drag)
  40114. */
  40115. onDragEndObservable: Observable<{
  40116. dragPlanePoint: Vector3;
  40117. pointerId: number;
  40118. }>;
  40119. /**
  40120. * If the attached mesh should be moved when dragged
  40121. */
  40122. moveAttached: boolean;
  40123. /**
  40124. * If the drag behavior will react to drag events (Default: true)
  40125. */
  40126. enabled: boolean;
  40127. /**
  40128. * If pointer events should start and release the drag (Default: true)
  40129. */
  40130. startAndReleaseDragOnPointerEvents: boolean;
  40131. /**
  40132. * If camera controls should be detached during the drag
  40133. */
  40134. detachCameraControls: boolean;
  40135. /**
  40136. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40137. */
  40138. useObjectOrienationForDragging: boolean;
  40139. private _options;
  40140. /**
  40141. * Gets the options used by the behavior
  40142. */
  40143. get options(): {
  40144. dragAxis?: Vector3;
  40145. dragPlaneNormal?: Vector3;
  40146. };
  40147. /**
  40148. * Sets the options used by the behavior
  40149. */
  40150. set options(options: {
  40151. dragAxis?: Vector3;
  40152. dragPlaneNormal?: Vector3;
  40153. });
  40154. /**
  40155. * Creates a pointer drag behavior that can be attached to a mesh
  40156. * @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)
  40157. */
  40158. constructor(options?: {
  40159. dragAxis?: Vector3;
  40160. dragPlaneNormal?: Vector3;
  40161. });
  40162. /**
  40163. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40164. */
  40165. validateDrag: (targetPosition: Vector3) => boolean;
  40166. /**
  40167. * The name of the behavior
  40168. */
  40169. get name(): string;
  40170. /**
  40171. * Initializes the behavior
  40172. */
  40173. init(): void;
  40174. private _tmpVector;
  40175. private _alternatePickedPoint;
  40176. private _worldDragAxis;
  40177. private _targetPosition;
  40178. private _attachedElement;
  40179. /**
  40180. * Attaches the drag behavior the passed in mesh
  40181. * @param ownerNode The mesh that will be dragged around once attached
  40182. * @param predicate Predicate to use for pick filtering
  40183. */
  40184. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40185. /**
  40186. * Force relase the drag action by code.
  40187. */
  40188. releaseDrag(): void;
  40189. private _startDragRay;
  40190. private _lastPointerRay;
  40191. /**
  40192. * Simulates the start of a pointer drag event on the behavior
  40193. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40194. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40195. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40196. */
  40197. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40198. private _startDrag;
  40199. private _dragDelta;
  40200. private _moveDrag;
  40201. private _pickWithRayOnDragPlane;
  40202. private _pointA;
  40203. private _pointB;
  40204. private _pointC;
  40205. private _lineA;
  40206. private _lineB;
  40207. private _localAxis;
  40208. private _lookAt;
  40209. private _updateDragPlanePosition;
  40210. /**
  40211. * Detaches the behavior from the mesh
  40212. */
  40213. detach(): void;
  40214. }
  40215. }
  40216. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40217. import { Mesh } from "babylonjs/Meshes/mesh";
  40218. import { Behavior } from "babylonjs/Behaviors/behavior";
  40219. /**
  40220. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40221. */
  40222. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40223. private _dragBehaviorA;
  40224. private _dragBehaviorB;
  40225. private _startDistance;
  40226. private _initialScale;
  40227. private _targetScale;
  40228. private _ownerNode;
  40229. private _sceneRenderObserver;
  40230. /**
  40231. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40232. */
  40233. constructor();
  40234. /**
  40235. * The name of the behavior
  40236. */
  40237. get name(): string;
  40238. /**
  40239. * Initializes the behavior
  40240. */
  40241. init(): void;
  40242. private _getCurrentDistance;
  40243. /**
  40244. * Attaches the scale behavior the passed in mesh
  40245. * @param ownerNode The mesh that will be scaled around once attached
  40246. */
  40247. attach(ownerNode: Mesh): void;
  40248. /**
  40249. * Detaches the behavior from the mesh
  40250. */
  40251. detach(): void;
  40252. }
  40253. }
  40254. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40255. import { Behavior } from "babylonjs/Behaviors/behavior";
  40256. import { Mesh } from "babylonjs/Meshes/mesh";
  40257. import { Observable } from "babylonjs/Misc/observable";
  40258. /**
  40259. * 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
  40260. */
  40261. export class SixDofDragBehavior implements Behavior<Mesh> {
  40262. private static _virtualScene;
  40263. private _ownerNode;
  40264. private _sceneRenderObserver;
  40265. private _scene;
  40266. private _targetPosition;
  40267. private _virtualOriginMesh;
  40268. private _virtualDragMesh;
  40269. private _pointerObserver;
  40270. private _moving;
  40271. private _startingOrientation;
  40272. /**
  40273. * 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)
  40274. */
  40275. private zDragFactor;
  40276. /**
  40277. * If the object should rotate to face the drag origin
  40278. */
  40279. rotateDraggedObject: boolean;
  40280. /**
  40281. * If the behavior is currently in a dragging state
  40282. */
  40283. dragging: boolean;
  40284. /**
  40285. * 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)
  40286. */
  40287. dragDeltaRatio: number;
  40288. /**
  40289. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40290. */
  40291. currentDraggingPointerID: number;
  40292. /**
  40293. * If camera controls should be detached during the drag
  40294. */
  40295. detachCameraControls: boolean;
  40296. /**
  40297. * Fires each time a drag starts
  40298. */
  40299. onDragStartObservable: Observable<{}>;
  40300. /**
  40301. * Fires each time a drag ends (eg. mouse release after drag)
  40302. */
  40303. onDragEndObservable: Observable<{}>;
  40304. /**
  40305. * 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
  40306. */
  40307. constructor();
  40308. /**
  40309. * The name of the behavior
  40310. */
  40311. get name(): string;
  40312. /**
  40313. * Initializes the behavior
  40314. */
  40315. init(): void;
  40316. /**
  40317. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40318. */
  40319. private get _pointerCamera();
  40320. /**
  40321. * Attaches the scale behavior the passed in mesh
  40322. * @param ownerNode The mesh that will be scaled around once attached
  40323. */
  40324. attach(ownerNode: Mesh): void;
  40325. /**
  40326. * Detaches the behavior from the mesh
  40327. */
  40328. detach(): void;
  40329. }
  40330. }
  40331. declare module "babylonjs/Behaviors/Meshes/index" {
  40332. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40333. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40334. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40335. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40336. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40337. }
  40338. declare module "babylonjs/Behaviors/index" {
  40339. export * from "babylonjs/Behaviors/behavior";
  40340. export * from "babylonjs/Behaviors/Cameras/index";
  40341. export * from "babylonjs/Behaviors/Meshes/index";
  40342. }
  40343. declare module "babylonjs/Bones/boneIKController" {
  40344. import { Bone } from "babylonjs/Bones/bone";
  40345. import { Vector3 } from "babylonjs/Maths/math.vector";
  40346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40347. import { Nullable } from "babylonjs/types";
  40348. /**
  40349. * Class used to apply inverse kinematics to bones
  40350. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40351. */
  40352. export class BoneIKController {
  40353. private static _tmpVecs;
  40354. private static _tmpQuat;
  40355. private static _tmpMats;
  40356. /**
  40357. * Gets or sets the target mesh
  40358. */
  40359. targetMesh: AbstractMesh;
  40360. /** Gets or sets the mesh used as pole */
  40361. poleTargetMesh: AbstractMesh;
  40362. /**
  40363. * Gets or sets the bone used as pole
  40364. */
  40365. poleTargetBone: Nullable<Bone>;
  40366. /**
  40367. * Gets or sets the target position
  40368. */
  40369. targetPosition: Vector3;
  40370. /**
  40371. * Gets or sets the pole target position
  40372. */
  40373. poleTargetPosition: Vector3;
  40374. /**
  40375. * Gets or sets the pole target local offset
  40376. */
  40377. poleTargetLocalOffset: Vector3;
  40378. /**
  40379. * Gets or sets the pole angle
  40380. */
  40381. poleAngle: number;
  40382. /**
  40383. * Gets or sets the mesh associated with the controller
  40384. */
  40385. mesh: AbstractMesh;
  40386. /**
  40387. * 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)
  40388. */
  40389. slerpAmount: number;
  40390. private _bone1Quat;
  40391. private _bone1Mat;
  40392. private _bone2Ang;
  40393. private _bone1;
  40394. private _bone2;
  40395. private _bone1Length;
  40396. private _bone2Length;
  40397. private _maxAngle;
  40398. private _maxReach;
  40399. private _rightHandedSystem;
  40400. private _bendAxis;
  40401. private _slerping;
  40402. private _adjustRoll;
  40403. /**
  40404. * Gets or sets maximum allowed angle
  40405. */
  40406. get maxAngle(): number;
  40407. set maxAngle(value: number);
  40408. /**
  40409. * Creates a new BoneIKController
  40410. * @param mesh defines the mesh to control
  40411. * @param bone defines the bone to control
  40412. * @param options defines options to set up the controller
  40413. */
  40414. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40415. targetMesh?: AbstractMesh;
  40416. poleTargetMesh?: AbstractMesh;
  40417. poleTargetBone?: Bone;
  40418. poleTargetLocalOffset?: Vector3;
  40419. poleAngle?: number;
  40420. bendAxis?: Vector3;
  40421. maxAngle?: number;
  40422. slerpAmount?: number;
  40423. });
  40424. private _setMaxAngle;
  40425. /**
  40426. * Force the controller to update the bones
  40427. */
  40428. update(): void;
  40429. }
  40430. }
  40431. declare module "babylonjs/Bones/boneLookController" {
  40432. import { Vector3 } from "babylonjs/Maths/math.vector";
  40433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40434. import { Bone } from "babylonjs/Bones/bone";
  40435. import { Space } from "babylonjs/Maths/math.axis";
  40436. /**
  40437. * Class used to make a bone look toward a point in space
  40438. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40439. */
  40440. export class BoneLookController {
  40441. private static _tmpVecs;
  40442. private static _tmpQuat;
  40443. private static _tmpMats;
  40444. /**
  40445. * The target Vector3 that the bone will look at
  40446. */
  40447. target: Vector3;
  40448. /**
  40449. * The mesh that the bone is attached to
  40450. */
  40451. mesh: AbstractMesh;
  40452. /**
  40453. * The bone that will be looking to the target
  40454. */
  40455. bone: Bone;
  40456. /**
  40457. * The up axis of the coordinate system that is used when the bone is rotated
  40458. */
  40459. upAxis: Vector3;
  40460. /**
  40461. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40462. */
  40463. upAxisSpace: Space;
  40464. /**
  40465. * Used to make an adjustment to the yaw of the bone
  40466. */
  40467. adjustYaw: number;
  40468. /**
  40469. * Used to make an adjustment to the pitch of the bone
  40470. */
  40471. adjustPitch: number;
  40472. /**
  40473. * Used to make an adjustment to the roll of the bone
  40474. */
  40475. adjustRoll: number;
  40476. /**
  40477. * 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)
  40478. */
  40479. slerpAmount: number;
  40480. private _minYaw;
  40481. private _maxYaw;
  40482. private _minPitch;
  40483. private _maxPitch;
  40484. private _minYawSin;
  40485. private _minYawCos;
  40486. private _maxYawSin;
  40487. private _maxYawCos;
  40488. private _midYawConstraint;
  40489. private _minPitchTan;
  40490. private _maxPitchTan;
  40491. private _boneQuat;
  40492. private _slerping;
  40493. private _transformYawPitch;
  40494. private _transformYawPitchInv;
  40495. private _firstFrameSkipped;
  40496. private _yawRange;
  40497. private _fowardAxis;
  40498. /**
  40499. * Gets or sets the minimum yaw angle that the bone can look to
  40500. */
  40501. get minYaw(): number;
  40502. set minYaw(value: number);
  40503. /**
  40504. * Gets or sets the maximum yaw angle that the bone can look to
  40505. */
  40506. get maxYaw(): number;
  40507. set maxYaw(value: number);
  40508. /**
  40509. * Gets or sets the minimum pitch angle that the bone can look to
  40510. */
  40511. get minPitch(): number;
  40512. set minPitch(value: number);
  40513. /**
  40514. * Gets or sets the maximum pitch angle that the bone can look to
  40515. */
  40516. get maxPitch(): number;
  40517. set maxPitch(value: number);
  40518. /**
  40519. * Create a BoneLookController
  40520. * @param mesh the mesh that the bone belongs to
  40521. * @param bone the bone that will be looking to the target
  40522. * @param target the target Vector3 to look at
  40523. * @param options optional settings:
  40524. * * maxYaw: the maximum angle the bone will yaw to
  40525. * * minYaw: the minimum angle the bone will yaw to
  40526. * * maxPitch: the maximum angle the bone will pitch to
  40527. * * minPitch: the minimum angle the bone will yaw to
  40528. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40529. * * upAxis: the up axis of the coordinate system
  40530. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40531. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40532. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40533. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40534. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40535. * * adjustRoll: used to make an adjustment to the roll of the bone
  40536. **/
  40537. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40538. maxYaw?: number;
  40539. minYaw?: number;
  40540. maxPitch?: number;
  40541. minPitch?: number;
  40542. slerpAmount?: number;
  40543. upAxis?: Vector3;
  40544. upAxisSpace?: Space;
  40545. yawAxis?: Vector3;
  40546. pitchAxis?: Vector3;
  40547. adjustYaw?: number;
  40548. adjustPitch?: number;
  40549. adjustRoll?: number;
  40550. });
  40551. /**
  40552. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40553. */
  40554. update(): void;
  40555. private _getAngleDiff;
  40556. private _getAngleBetween;
  40557. private _isAngleBetween;
  40558. }
  40559. }
  40560. declare module "babylonjs/Bones/index" {
  40561. export * from "babylonjs/Bones/bone";
  40562. export * from "babylonjs/Bones/boneIKController";
  40563. export * from "babylonjs/Bones/boneLookController";
  40564. export * from "babylonjs/Bones/skeleton";
  40565. }
  40566. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40567. import { Nullable } from "babylonjs/types";
  40568. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40569. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40570. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40571. /**
  40572. * Manage the gamepad inputs to control an arc rotate camera.
  40573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40574. */
  40575. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40576. /**
  40577. * Defines the camera the input is attached to.
  40578. */
  40579. camera: ArcRotateCamera;
  40580. /**
  40581. * Defines the gamepad the input is gathering event from.
  40582. */
  40583. gamepad: Nullable<Gamepad>;
  40584. /**
  40585. * Defines the gamepad rotation sensiblity.
  40586. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40587. */
  40588. gamepadRotationSensibility: number;
  40589. /**
  40590. * Defines the gamepad move sensiblity.
  40591. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40592. */
  40593. gamepadMoveSensibility: number;
  40594. private _yAxisScale;
  40595. /**
  40596. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40597. */
  40598. get invertYAxis(): boolean;
  40599. set invertYAxis(value: boolean);
  40600. private _onGamepadConnectedObserver;
  40601. private _onGamepadDisconnectedObserver;
  40602. /**
  40603. * Attach the input controls to a specific dom element to get the input from.
  40604. * @param element Defines the element the controls should be listened from
  40605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40606. */
  40607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40608. /**
  40609. * Detach the current controls from the specified dom element.
  40610. * @param element Defines the element to stop listening the inputs from
  40611. */
  40612. detachControl(element: Nullable<HTMLElement>): void;
  40613. /**
  40614. * Update the current camera state depending on the inputs that have been used this frame.
  40615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40616. */
  40617. checkInputs(): void;
  40618. /**
  40619. * Gets the class name of the current intput.
  40620. * @returns the class name
  40621. */
  40622. getClassName(): string;
  40623. /**
  40624. * Get the friendly name associated with the input class.
  40625. * @returns the input friendly name
  40626. */
  40627. getSimpleName(): string;
  40628. }
  40629. }
  40630. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40631. import { Nullable } from "babylonjs/types";
  40632. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40633. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40634. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40635. interface ArcRotateCameraInputsManager {
  40636. /**
  40637. * Add orientation input support to the input manager.
  40638. * @returns the current input manager
  40639. */
  40640. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40641. }
  40642. }
  40643. /**
  40644. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40646. */
  40647. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40648. /**
  40649. * Defines the camera the input is attached to.
  40650. */
  40651. camera: ArcRotateCamera;
  40652. /**
  40653. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40654. */
  40655. alphaCorrection: number;
  40656. /**
  40657. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40658. */
  40659. gammaCorrection: number;
  40660. private _alpha;
  40661. private _gamma;
  40662. private _dirty;
  40663. private _deviceOrientationHandler;
  40664. /**
  40665. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40666. */
  40667. constructor();
  40668. /**
  40669. * Attach the input controls to a specific dom element to get the input from.
  40670. * @param element Defines the element the controls should be listened from
  40671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40672. */
  40673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40674. /** @hidden */
  40675. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40676. /**
  40677. * Update the current camera state depending on the inputs that have been used this frame.
  40678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40679. */
  40680. checkInputs(): void;
  40681. /**
  40682. * Detach the current controls from the specified dom element.
  40683. * @param element Defines the element to stop listening the inputs from
  40684. */
  40685. detachControl(element: Nullable<HTMLElement>): void;
  40686. /**
  40687. * Gets the class name of the current intput.
  40688. * @returns the class name
  40689. */
  40690. getClassName(): string;
  40691. /**
  40692. * Get the friendly name associated with the input class.
  40693. * @returns the input friendly name
  40694. */
  40695. getSimpleName(): string;
  40696. }
  40697. }
  40698. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40699. import { Nullable } from "babylonjs/types";
  40700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40701. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40702. /**
  40703. * Listen to mouse events to control the camera.
  40704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40705. */
  40706. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40707. /**
  40708. * Defines the camera the input is attached to.
  40709. */
  40710. camera: FlyCamera;
  40711. /**
  40712. * Defines if touch is enabled. (Default is true.)
  40713. */
  40714. touchEnabled: boolean;
  40715. /**
  40716. * Defines the buttons associated with the input to handle camera rotation.
  40717. */
  40718. buttons: number[];
  40719. /**
  40720. * Assign buttons for Yaw control.
  40721. */
  40722. buttonsYaw: number[];
  40723. /**
  40724. * Assign buttons for Pitch control.
  40725. */
  40726. buttonsPitch: number[];
  40727. /**
  40728. * Assign buttons for Roll control.
  40729. */
  40730. buttonsRoll: number[];
  40731. /**
  40732. * Detect if any button is being pressed while mouse is moved.
  40733. * -1 = Mouse locked.
  40734. * 0 = Left button.
  40735. * 1 = Middle Button.
  40736. * 2 = Right Button.
  40737. */
  40738. activeButton: number;
  40739. /**
  40740. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40741. * Higher values reduce its sensitivity.
  40742. */
  40743. angularSensibility: number;
  40744. private _mousemoveCallback;
  40745. private _observer;
  40746. private _rollObserver;
  40747. private previousPosition;
  40748. private noPreventDefault;
  40749. private element;
  40750. /**
  40751. * Listen to mouse events to control the camera.
  40752. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40754. */
  40755. constructor(touchEnabled?: boolean);
  40756. /**
  40757. * Attach the mouse control to the HTML DOM element.
  40758. * @param element Defines the element that listens to the input events.
  40759. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40760. */
  40761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40762. /**
  40763. * Detach the current controls from the specified dom element.
  40764. * @param element Defines the element to stop listening the inputs from
  40765. */
  40766. detachControl(element: Nullable<HTMLElement>): void;
  40767. /**
  40768. * Gets the class name of the current input.
  40769. * @returns the class name.
  40770. */
  40771. getClassName(): string;
  40772. /**
  40773. * Get the friendly name associated with the input class.
  40774. * @returns the input's friendly name.
  40775. */
  40776. getSimpleName(): string;
  40777. private _pointerInput;
  40778. private _onMouseMove;
  40779. /**
  40780. * Rotate camera by mouse offset.
  40781. */
  40782. private rotateCamera;
  40783. }
  40784. }
  40785. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40786. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40787. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40788. /**
  40789. * Default Inputs manager for the FlyCamera.
  40790. * It groups all the default supported inputs for ease of use.
  40791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40792. */
  40793. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40794. /**
  40795. * Instantiates a new FlyCameraInputsManager.
  40796. * @param camera Defines the camera the inputs belong to.
  40797. */
  40798. constructor(camera: FlyCamera);
  40799. /**
  40800. * Add keyboard input support to the input manager.
  40801. * @returns the new FlyCameraKeyboardMoveInput().
  40802. */
  40803. addKeyboard(): FlyCameraInputsManager;
  40804. /**
  40805. * Add mouse input support to the input manager.
  40806. * @param touchEnabled Enable touch screen support.
  40807. * @returns the new FlyCameraMouseInput().
  40808. */
  40809. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40810. }
  40811. }
  40812. declare module "babylonjs/Cameras/flyCamera" {
  40813. import { Scene } from "babylonjs/scene";
  40814. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40816. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40817. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40818. /**
  40819. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40820. * such as in a 3D Space Shooter or a Flight Simulator.
  40821. */
  40822. export class FlyCamera extends TargetCamera {
  40823. /**
  40824. * Define the collision ellipsoid of the camera.
  40825. * This is helpful for simulating a camera body, like a player's body.
  40826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40827. */
  40828. ellipsoid: Vector3;
  40829. /**
  40830. * Define an offset for the position of the ellipsoid around the camera.
  40831. * This can be helpful if the camera is attached away from the player's body center,
  40832. * such as at its head.
  40833. */
  40834. ellipsoidOffset: Vector3;
  40835. /**
  40836. * Enable or disable collisions of the camera with the rest of the scene objects.
  40837. */
  40838. checkCollisions: boolean;
  40839. /**
  40840. * Enable or disable gravity on the camera.
  40841. */
  40842. applyGravity: boolean;
  40843. /**
  40844. * Define the current direction the camera is moving to.
  40845. */
  40846. cameraDirection: Vector3;
  40847. /**
  40848. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40849. * This overrides and empties cameraRotation.
  40850. */
  40851. rotationQuaternion: Quaternion;
  40852. /**
  40853. * Track Roll to maintain the wanted Rolling when looking around.
  40854. */
  40855. _trackRoll: number;
  40856. /**
  40857. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40858. */
  40859. rollCorrect: number;
  40860. /**
  40861. * Mimic a banked turn, Rolling the camera when Yawing.
  40862. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40863. */
  40864. bankedTurn: boolean;
  40865. /**
  40866. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40867. */
  40868. bankedTurnLimit: number;
  40869. /**
  40870. * Value of 0 disables the banked Roll.
  40871. * Value of 1 is equal to the Yaw angle in radians.
  40872. */
  40873. bankedTurnMultiplier: number;
  40874. /**
  40875. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40876. */
  40877. inputs: FlyCameraInputsManager;
  40878. /**
  40879. * Gets the input sensibility for mouse input.
  40880. * Higher values reduce sensitivity.
  40881. */
  40882. get angularSensibility(): number;
  40883. /**
  40884. * Sets the input sensibility for a mouse input.
  40885. * Higher values reduce sensitivity.
  40886. */
  40887. set angularSensibility(value: number);
  40888. /**
  40889. * Get the keys for camera movement forward.
  40890. */
  40891. get keysForward(): number[];
  40892. /**
  40893. * Set the keys for camera movement forward.
  40894. */
  40895. set keysForward(value: number[]);
  40896. /**
  40897. * Get the keys for camera movement backward.
  40898. */
  40899. get keysBackward(): number[];
  40900. set keysBackward(value: number[]);
  40901. /**
  40902. * Get the keys for camera movement up.
  40903. */
  40904. get keysUp(): number[];
  40905. /**
  40906. * Set the keys for camera movement up.
  40907. */
  40908. set keysUp(value: number[]);
  40909. /**
  40910. * Get the keys for camera movement down.
  40911. */
  40912. get keysDown(): number[];
  40913. /**
  40914. * Set the keys for camera movement down.
  40915. */
  40916. set keysDown(value: number[]);
  40917. /**
  40918. * Get the keys for camera movement left.
  40919. */
  40920. get keysLeft(): number[];
  40921. /**
  40922. * Set the keys for camera movement left.
  40923. */
  40924. set keysLeft(value: number[]);
  40925. /**
  40926. * Set the keys for camera movement right.
  40927. */
  40928. get keysRight(): number[];
  40929. /**
  40930. * Set the keys for camera movement right.
  40931. */
  40932. set keysRight(value: number[]);
  40933. /**
  40934. * Event raised when the camera collides with a mesh in the scene.
  40935. */
  40936. onCollide: (collidedMesh: AbstractMesh) => void;
  40937. private _collider;
  40938. private _needMoveForGravity;
  40939. private _oldPosition;
  40940. private _diffPosition;
  40941. private _newPosition;
  40942. /** @hidden */
  40943. _localDirection: Vector3;
  40944. /** @hidden */
  40945. _transformedDirection: Vector3;
  40946. /**
  40947. * Instantiates a FlyCamera.
  40948. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40949. * such as in a 3D Space Shooter or a Flight Simulator.
  40950. * @param name Define the name of the camera in the scene.
  40951. * @param position Define the starting position of the camera in the scene.
  40952. * @param scene Define the scene the camera belongs to.
  40953. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40954. */
  40955. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40956. /**
  40957. * Attach a control to the HTML DOM element.
  40958. * @param element Defines the element that listens to the input events.
  40959. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40960. */
  40961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40962. /**
  40963. * Detach a control from the HTML DOM element.
  40964. * The camera will stop reacting to that input.
  40965. * @param element Defines the element that listens to the input events.
  40966. */
  40967. detachControl(element: HTMLElement): void;
  40968. private _collisionMask;
  40969. /**
  40970. * Get the mask that the camera ignores in collision events.
  40971. */
  40972. get collisionMask(): number;
  40973. /**
  40974. * Set the mask that the camera ignores in collision events.
  40975. */
  40976. set collisionMask(mask: number);
  40977. /** @hidden */
  40978. _collideWithWorld(displacement: Vector3): void;
  40979. /** @hidden */
  40980. private _onCollisionPositionChange;
  40981. /** @hidden */
  40982. _checkInputs(): void;
  40983. /** @hidden */
  40984. _decideIfNeedsToMove(): boolean;
  40985. /** @hidden */
  40986. _updatePosition(): void;
  40987. /**
  40988. * Restore the Roll to its target value at the rate specified.
  40989. * @param rate - Higher means slower restoring.
  40990. * @hidden
  40991. */
  40992. restoreRoll(rate: number): void;
  40993. /**
  40994. * Destroy the camera and release the current resources held by it.
  40995. */
  40996. dispose(): void;
  40997. /**
  40998. * Get the current object class name.
  40999. * @returns the class name.
  41000. */
  41001. getClassName(): string;
  41002. }
  41003. }
  41004. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41005. import { Nullable } from "babylonjs/types";
  41006. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41007. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41008. /**
  41009. * Listen to keyboard events to control the camera.
  41010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41011. */
  41012. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41013. /**
  41014. * Defines the camera the input is attached to.
  41015. */
  41016. camera: FlyCamera;
  41017. /**
  41018. * The list of keyboard keys used to control the forward move of the camera.
  41019. */
  41020. keysForward: number[];
  41021. /**
  41022. * The list of keyboard keys used to control the backward move of the camera.
  41023. */
  41024. keysBackward: number[];
  41025. /**
  41026. * The list of keyboard keys used to control the forward move of the camera.
  41027. */
  41028. keysUp: number[];
  41029. /**
  41030. * The list of keyboard keys used to control the backward move of the camera.
  41031. */
  41032. keysDown: number[];
  41033. /**
  41034. * The list of keyboard keys used to control the right strafe move of the camera.
  41035. */
  41036. keysRight: number[];
  41037. /**
  41038. * The list of keyboard keys used to control the left strafe move of the camera.
  41039. */
  41040. keysLeft: number[];
  41041. private _keys;
  41042. private _onCanvasBlurObserver;
  41043. private _onKeyboardObserver;
  41044. private _engine;
  41045. private _scene;
  41046. /**
  41047. * Attach the input controls to a specific dom element to get the input from.
  41048. * @param element Defines the element the controls should be listened from
  41049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41050. */
  41051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41052. /**
  41053. * Detach the current controls from the specified dom element.
  41054. * @param element Defines the element to stop listening the inputs from
  41055. */
  41056. detachControl(element: Nullable<HTMLElement>): void;
  41057. /**
  41058. * Gets the class name of the current intput.
  41059. * @returns the class name
  41060. */
  41061. getClassName(): string;
  41062. /** @hidden */
  41063. _onLostFocus(e: FocusEvent): void;
  41064. /**
  41065. * Get the friendly name associated with the input class.
  41066. * @returns the input friendly name
  41067. */
  41068. getSimpleName(): string;
  41069. /**
  41070. * Update the current camera state depending on the inputs that have been used this frame.
  41071. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41072. */
  41073. checkInputs(): void;
  41074. }
  41075. }
  41076. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41077. import { Nullable } from "babylonjs/types";
  41078. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41079. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41080. /**
  41081. * Manage the mouse wheel inputs to control a follow camera.
  41082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41083. */
  41084. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41085. /**
  41086. * Defines the camera the input is attached to.
  41087. */
  41088. camera: FollowCamera;
  41089. /**
  41090. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41091. */
  41092. axisControlRadius: boolean;
  41093. /**
  41094. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41095. */
  41096. axisControlHeight: boolean;
  41097. /**
  41098. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41099. */
  41100. axisControlRotation: boolean;
  41101. /**
  41102. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41103. * relation to mouseWheel events.
  41104. */
  41105. wheelPrecision: number;
  41106. /**
  41107. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41108. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41109. */
  41110. wheelDeltaPercentage: number;
  41111. private _wheel;
  41112. private _observer;
  41113. /**
  41114. * Attach the input controls to a specific dom element to get the input from.
  41115. * @param element Defines the element the controls should be listened from
  41116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41117. */
  41118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41119. /**
  41120. * Detach the current controls from the specified dom element.
  41121. * @param element Defines the element to stop listening the inputs from
  41122. */
  41123. detachControl(element: Nullable<HTMLElement>): void;
  41124. /**
  41125. * Gets the class name of the current intput.
  41126. * @returns the class name
  41127. */
  41128. getClassName(): string;
  41129. /**
  41130. * Get the friendly name associated with the input class.
  41131. * @returns the input friendly name
  41132. */
  41133. getSimpleName(): string;
  41134. }
  41135. }
  41136. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41137. import { Nullable } from "babylonjs/types";
  41138. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41139. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41140. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41141. /**
  41142. * Manage the pointers inputs to control an follow camera.
  41143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41144. */
  41145. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41146. /**
  41147. * Defines the camera the input is attached to.
  41148. */
  41149. camera: FollowCamera;
  41150. /**
  41151. * Gets the class name of the current input.
  41152. * @returns the class name
  41153. */
  41154. getClassName(): string;
  41155. /**
  41156. * Defines the pointer angular sensibility along the X axis or how fast is
  41157. * the camera rotating.
  41158. * A negative number will reverse the axis direction.
  41159. */
  41160. angularSensibilityX: number;
  41161. /**
  41162. * Defines the pointer angular sensibility along the Y axis or how fast is
  41163. * the camera rotating.
  41164. * A negative number will reverse the axis direction.
  41165. */
  41166. angularSensibilityY: number;
  41167. /**
  41168. * Defines the pointer pinch precision or how fast is the camera zooming.
  41169. * A negative number will reverse the axis direction.
  41170. */
  41171. pinchPrecision: number;
  41172. /**
  41173. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41174. * from 0.
  41175. * It defines the percentage of current camera.radius to use as delta when
  41176. * pinch zoom is used.
  41177. */
  41178. pinchDeltaPercentage: number;
  41179. /**
  41180. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41181. */
  41182. axisXControlRadius: boolean;
  41183. /**
  41184. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41185. */
  41186. axisXControlHeight: boolean;
  41187. /**
  41188. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41189. */
  41190. axisXControlRotation: boolean;
  41191. /**
  41192. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41193. */
  41194. axisYControlRadius: boolean;
  41195. /**
  41196. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41197. */
  41198. axisYControlHeight: boolean;
  41199. /**
  41200. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41201. */
  41202. axisYControlRotation: boolean;
  41203. /**
  41204. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41205. */
  41206. axisPinchControlRadius: boolean;
  41207. /**
  41208. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41209. */
  41210. axisPinchControlHeight: boolean;
  41211. /**
  41212. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41213. */
  41214. axisPinchControlRotation: boolean;
  41215. /**
  41216. * Log error messages if basic misconfiguration has occurred.
  41217. */
  41218. warningEnable: boolean;
  41219. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41220. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41221. private _warningCounter;
  41222. private _warning;
  41223. }
  41224. }
  41225. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41226. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41227. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41228. /**
  41229. * Default Inputs manager for the FollowCamera.
  41230. * It groups all the default supported inputs for ease of use.
  41231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41232. */
  41233. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41234. /**
  41235. * Instantiates a new FollowCameraInputsManager.
  41236. * @param camera Defines the camera the inputs belong to
  41237. */
  41238. constructor(camera: FollowCamera);
  41239. /**
  41240. * Add keyboard input support to the input manager.
  41241. * @returns the current input manager
  41242. */
  41243. addKeyboard(): FollowCameraInputsManager;
  41244. /**
  41245. * Add mouse wheel input support to the input manager.
  41246. * @returns the current input manager
  41247. */
  41248. addMouseWheel(): FollowCameraInputsManager;
  41249. /**
  41250. * Add pointers input support to the input manager.
  41251. * @returns the current input manager
  41252. */
  41253. addPointers(): FollowCameraInputsManager;
  41254. /**
  41255. * Add orientation input support to the input manager.
  41256. * @returns the current input manager
  41257. */
  41258. addVRDeviceOrientation(): FollowCameraInputsManager;
  41259. }
  41260. }
  41261. declare module "babylonjs/Cameras/followCamera" {
  41262. import { Nullable } from "babylonjs/types";
  41263. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41264. import { Scene } from "babylonjs/scene";
  41265. import { Vector3 } from "babylonjs/Maths/math.vector";
  41266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41267. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41268. /**
  41269. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41270. * an arc rotate version arcFollowCamera are available.
  41271. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41272. */
  41273. export class FollowCamera extends TargetCamera {
  41274. /**
  41275. * Distance the follow camera should follow an object at
  41276. */
  41277. radius: number;
  41278. /**
  41279. * Minimum allowed distance of the camera to the axis of rotation
  41280. * (The camera can not get closer).
  41281. * This can help limiting how the Camera is able to move in the scene.
  41282. */
  41283. lowerRadiusLimit: Nullable<number>;
  41284. /**
  41285. * Maximum allowed distance of the camera to the axis of rotation
  41286. * (The camera can not get further).
  41287. * This can help limiting how the Camera is able to move in the scene.
  41288. */
  41289. upperRadiusLimit: Nullable<number>;
  41290. /**
  41291. * Define a rotation offset between the camera and the object it follows
  41292. */
  41293. rotationOffset: number;
  41294. /**
  41295. * Minimum allowed angle to camera position relative to target object.
  41296. * This can help limiting how the Camera is able to move in the scene.
  41297. */
  41298. lowerRotationOffsetLimit: Nullable<number>;
  41299. /**
  41300. * Maximum allowed angle to camera position relative to target object.
  41301. * This can help limiting how the Camera is able to move in the scene.
  41302. */
  41303. upperRotationOffsetLimit: Nullable<number>;
  41304. /**
  41305. * Define a height offset between the camera and the object it follows.
  41306. * It can help following an object from the top (like a car chaing a plane)
  41307. */
  41308. heightOffset: number;
  41309. /**
  41310. * Minimum allowed height of camera position relative to target object.
  41311. * This can help limiting how the Camera is able to move in the scene.
  41312. */
  41313. lowerHeightOffsetLimit: Nullable<number>;
  41314. /**
  41315. * Maximum allowed height of camera position relative to target object.
  41316. * This can help limiting how the Camera is able to move in the scene.
  41317. */
  41318. upperHeightOffsetLimit: Nullable<number>;
  41319. /**
  41320. * Define how fast the camera can accelerate to follow it s target.
  41321. */
  41322. cameraAcceleration: number;
  41323. /**
  41324. * Define the speed limit of the camera following an object.
  41325. */
  41326. maxCameraSpeed: number;
  41327. /**
  41328. * Define the target of the camera.
  41329. */
  41330. lockedTarget: Nullable<AbstractMesh>;
  41331. /**
  41332. * Defines the input associated with the camera.
  41333. */
  41334. inputs: FollowCameraInputsManager;
  41335. /**
  41336. * Instantiates the follow camera.
  41337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41338. * @param name Define the name of the camera in the scene
  41339. * @param position Define the position of the camera
  41340. * @param scene Define the scene the camera belong to
  41341. * @param lockedTarget Define the target of the camera
  41342. */
  41343. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41344. private _follow;
  41345. /**
  41346. * Attached controls to the current camera.
  41347. * @param element Defines the element the controls should be listened from
  41348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41349. */
  41350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41351. /**
  41352. * Detach the current controls from the camera.
  41353. * The camera will stop reacting to inputs.
  41354. * @param element Defines the element to stop listening the inputs from
  41355. */
  41356. detachControl(element: HTMLElement): void;
  41357. /** @hidden */
  41358. _checkInputs(): void;
  41359. private _checkLimits;
  41360. /**
  41361. * Gets the camera class name.
  41362. * @returns the class name
  41363. */
  41364. getClassName(): string;
  41365. }
  41366. /**
  41367. * Arc Rotate version of the follow camera.
  41368. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41369. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41370. */
  41371. export class ArcFollowCamera extends TargetCamera {
  41372. /** The longitudinal angle of the camera */
  41373. alpha: number;
  41374. /** The latitudinal angle of the camera */
  41375. beta: number;
  41376. /** The radius of the camera from its target */
  41377. radius: number;
  41378. /** Define the camera target (the messh it should follow) */
  41379. target: Nullable<AbstractMesh>;
  41380. private _cartesianCoordinates;
  41381. /**
  41382. * Instantiates a new ArcFollowCamera
  41383. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41384. * @param name Define the name of the camera
  41385. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41386. * @param beta Define the rotation angle of the camera around the elevation axis
  41387. * @param radius Define the radius of the camera from its target point
  41388. * @param target Define the target of the camera
  41389. * @param scene Define the scene the camera belongs to
  41390. */
  41391. constructor(name: string,
  41392. /** The longitudinal angle of the camera */
  41393. alpha: number,
  41394. /** The latitudinal angle of the camera */
  41395. beta: number,
  41396. /** The radius of the camera from its target */
  41397. radius: number,
  41398. /** Define the camera target (the messh it should follow) */
  41399. target: Nullable<AbstractMesh>, scene: Scene);
  41400. private _follow;
  41401. /** @hidden */
  41402. _checkInputs(): void;
  41403. /**
  41404. * Returns the class name of the object.
  41405. * It is mostly used internally for serialization purposes.
  41406. */
  41407. getClassName(): string;
  41408. }
  41409. }
  41410. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41411. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41412. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41413. import { Nullable } from "babylonjs/types";
  41414. /**
  41415. * Manage the keyboard inputs to control the movement of a follow camera.
  41416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41417. */
  41418. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41419. /**
  41420. * Defines the camera the input is attached to.
  41421. */
  41422. camera: FollowCamera;
  41423. /**
  41424. * Defines the list of key codes associated with the up action (increase heightOffset)
  41425. */
  41426. keysHeightOffsetIncr: number[];
  41427. /**
  41428. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41429. */
  41430. keysHeightOffsetDecr: number[];
  41431. /**
  41432. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41433. */
  41434. keysHeightOffsetModifierAlt: boolean;
  41435. /**
  41436. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41437. */
  41438. keysHeightOffsetModifierCtrl: boolean;
  41439. /**
  41440. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41441. */
  41442. keysHeightOffsetModifierShift: boolean;
  41443. /**
  41444. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41445. */
  41446. keysRotationOffsetIncr: number[];
  41447. /**
  41448. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41449. */
  41450. keysRotationOffsetDecr: number[];
  41451. /**
  41452. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41453. */
  41454. keysRotationOffsetModifierAlt: boolean;
  41455. /**
  41456. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41457. */
  41458. keysRotationOffsetModifierCtrl: boolean;
  41459. /**
  41460. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41461. */
  41462. keysRotationOffsetModifierShift: boolean;
  41463. /**
  41464. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41465. */
  41466. keysRadiusIncr: number[];
  41467. /**
  41468. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41469. */
  41470. keysRadiusDecr: number[];
  41471. /**
  41472. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41473. */
  41474. keysRadiusModifierAlt: boolean;
  41475. /**
  41476. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41477. */
  41478. keysRadiusModifierCtrl: boolean;
  41479. /**
  41480. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41481. */
  41482. keysRadiusModifierShift: boolean;
  41483. /**
  41484. * Defines the rate of change of heightOffset.
  41485. */
  41486. heightSensibility: number;
  41487. /**
  41488. * Defines the rate of change of rotationOffset.
  41489. */
  41490. rotationSensibility: number;
  41491. /**
  41492. * Defines the rate of change of radius.
  41493. */
  41494. radiusSensibility: number;
  41495. private _keys;
  41496. private _ctrlPressed;
  41497. private _altPressed;
  41498. private _shiftPressed;
  41499. private _onCanvasBlurObserver;
  41500. private _onKeyboardObserver;
  41501. private _engine;
  41502. private _scene;
  41503. /**
  41504. * Attach the input controls to a specific dom element to get the input from.
  41505. * @param element Defines the element the controls should be listened from
  41506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41507. */
  41508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41509. /**
  41510. * Detach the current controls from the specified dom element.
  41511. * @param element Defines the element to stop listening the inputs from
  41512. */
  41513. detachControl(element: Nullable<HTMLElement>): void;
  41514. /**
  41515. * Update the current camera state depending on the inputs that have been used this frame.
  41516. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41517. */
  41518. checkInputs(): void;
  41519. /**
  41520. * Gets the class name of the current input.
  41521. * @returns the class name
  41522. */
  41523. getClassName(): string;
  41524. /**
  41525. * Get the friendly name associated with the input class.
  41526. * @returns the input friendly name
  41527. */
  41528. getSimpleName(): string;
  41529. /**
  41530. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41531. * allow modification of the heightOffset value.
  41532. */
  41533. private _modifierHeightOffset;
  41534. /**
  41535. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41536. * allow modification of the rotationOffset value.
  41537. */
  41538. private _modifierRotationOffset;
  41539. /**
  41540. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41541. * allow modification of the radius value.
  41542. */
  41543. private _modifierRadius;
  41544. }
  41545. }
  41546. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41547. import { Nullable } from "babylonjs/types";
  41548. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41549. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41550. import { Observable } from "babylonjs/Misc/observable";
  41551. module "babylonjs/Cameras/freeCameraInputsManager" {
  41552. interface FreeCameraInputsManager {
  41553. /**
  41554. * @hidden
  41555. */
  41556. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41557. /**
  41558. * Add orientation input support to the input manager.
  41559. * @returns the current input manager
  41560. */
  41561. addDeviceOrientation(): FreeCameraInputsManager;
  41562. }
  41563. }
  41564. /**
  41565. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41566. * Screen rotation is taken into account.
  41567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41568. */
  41569. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41570. private _camera;
  41571. private _screenOrientationAngle;
  41572. private _constantTranform;
  41573. private _screenQuaternion;
  41574. private _alpha;
  41575. private _beta;
  41576. private _gamma;
  41577. /**
  41578. * Can be used to detect if a device orientation sensor is available on a device
  41579. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41580. * @returns a promise that will resolve on orientation change
  41581. */
  41582. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41583. /**
  41584. * @hidden
  41585. */
  41586. _onDeviceOrientationChangedObservable: Observable<void>;
  41587. /**
  41588. * Instantiates a new input
  41589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41590. */
  41591. constructor();
  41592. /**
  41593. * Define the camera controlled by the input.
  41594. */
  41595. get camera(): FreeCamera;
  41596. set camera(camera: FreeCamera);
  41597. /**
  41598. * Attach the input controls to a specific dom element to get the input from.
  41599. * @param element Defines the element the controls should be listened from
  41600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41601. */
  41602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41603. private _orientationChanged;
  41604. private _deviceOrientation;
  41605. /**
  41606. * Detach the current controls from the specified dom element.
  41607. * @param element Defines the element to stop listening the inputs from
  41608. */
  41609. detachControl(element: Nullable<HTMLElement>): void;
  41610. /**
  41611. * Update the current camera state depending on the inputs that have been used this frame.
  41612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41613. */
  41614. checkInputs(): void;
  41615. /**
  41616. * Gets the class name of the current intput.
  41617. * @returns the class name
  41618. */
  41619. getClassName(): string;
  41620. /**
  41621. * Get the friendly name associated with the input class.
  41622. * @returns the input friendly name
  41623. */
  41624. getSimpleName(): string;
  41625. }
  41626. }
  41627. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41628. import { Nullable } from "babylonjs/types";
  41629. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41630. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41631. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41632. /**
  41633. * Manage the gamepad inputs to control a free camera.
  41634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41635. */
  41636. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41637. /**
  41638. * Define the camera the input is attached to.
  41639. */
  41640. camera: FreeCamera;
  41641. /**
  41642. * Define the Gamepad controlling the input
  41643. */
  41644. gamepad: Nullable<Gamepad>;
  41645. /**
  41646. * Defines the gamepad rotation sensiblity.
  41647. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41648. */
  41649. gamepadAngularSensibility: number;
  41650. /**
  41651. * Defines the gamepad move sensiblity.
  41652. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41653. */
  41654. gamepadMoveSensibility: number;
  41655. private _yAxisScale;
  41656. /**
  41657. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41658. */
  41659. get invertYAxis(): boolean;
  41660. set invertYAxis(value: boolean);
  41661. private _onGamepadConnectedObserver;
  41662. private _onGamepadDisconnectedObserver;
  41663. private _cameraTransform;
  41664. private _deltaTransform;
  41665. private _vector3;
  41666. private _vector2;
  41667. /**
  41668. * Attach the input controls to a specific dom element to get the input from.
  41669. * @param element Defines the element the controls should be listened from
  41670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41671. */
  41672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41673. /**
  41674. * Detach the current controls from the specified dom element.
  41675. * @param element Defines the element to stop listening the inputs from
  41676. */
  41677. detachControl(element: Nullable<HTMLElement>): void;
  41678. /**
  41679. * Update the current camera state depending on the inputs that have been used this frame.
  41680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41681. */
  41682. checkInputs(): void;
  41683. /**
  41684. * Gets the class name of the current intput.
  41685. * @returns the class name
  41686. */
  41687. getClassName(): string;
  41688. /**
  41689. * Get the friendly name associated with the input class.
  41690. * @returns the input friendly name
  41691. */
  41692. getSimpleName(): string;
  41693. }
  41694. }
  41695. declare module "babylonjs/Misc/virtualJoystick" {
  41696. import { Nullable } from "babylonjs/types";
  41697. import { Vector3 } from "babylonjs/Maths/math.vector";
  41698. /**
  41699. * Defines the potential axis of a Joystick
  41700. */
  41701. export enum JoystickAxis {
  41702. /** X axis */
  41703. X = 0,
  41704. /** Y axis */
  41705. Y = 1,
  41706. /** Z axis */
  41707. Z = 2
  41708. }
  41709. /**
  41710. * Class used to define virtual joystick (used in touch mode)
  41711. */
  41712. export class VirtualJoystick {
  41713. /**
  41714. * Gets or sets a boolean indicating that left and right values must be inverted
  41715. */
  41716. reverseLeftRight: boolean;
  41717. /**
  41718. * Gets or sets a boolean indicating that up and down values must be inverted
  41719. */
  41720. reverseUpDown: boolean;
  41721. /**
  41722. * Gets the offset value for the position (ie. the change of the position value)
  41723. */
  41724. deltaPosition: Vector3;
  41725. /**
  41726. * Gets a boolean indicating if the virtual joystick was pressed
  41727. */
  41728. pressed: boolean;
  41729. /**
  41730. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41731. */
  41732. static Canvas: Nullable<HTMLCanvasElement>;
  41733. private static _globalJoystickIndex;
  41734. private static vjCanvasContext;
  41735. private static vjCanvasWidth;
  41736. private static vjCanvasHeight;
  41737. private static halfWidth;
  41738. private _action;
  41739. private _axisTargetedByLeftAndRight;
  41740. private _axisTargetedByUpAndDown;
  41741. private _joystickSensibility;
  41742. private _inversedSensibility;
  41743. private _joystickPointerID;
  41744. private _joystickColor;
  41745. private _joystickPointerPos;
  41746. private _joystickPreviousPointerPos;
  41747. private _joystickPointerStartPos;
  41748. private _deltaJoystickVector;
  41749. private _leftJoystick;
  41750. private _touches;
  41751. private _onPointerDownHandlerRef;
  41752. private _onPointerMoveHandlerRef;
  41753. private _onPointerUpHandlerRef;
  41754. private _onResize;
  41755. /**
  41756. * Creates a new virtual joystick
  41757. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41758. */
  41759. constructor(leftJoystick?: boolean);
  41760. /**
  41761. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41762. * @param newJoystickSensibility defines the new sensibility
  41763. */
  41764. setJoystickSensibility(newJoystickSensibility: number): void;
  41765. private _onPointerDown;
  41766. private _onPointerMove;
  41767. private _onPointerUp;
  41768. /**
  41769. * Change the color of the virtual joystick
  41770. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41771. */
  41772. setJoystickColor(newColor: string): void;
  41773. /**
  41774. * Defines a callback to call when the joystick is touched
  41775. * @param action defines the callback
  41776. */
  41777. setActionOnTouch(action: () => any): void;
  41778. /**
  41779. * Defines which axis you'd like to control for left & right
  41780. * @param axis defines the axis to use
  41781. */
  41782. setAxisForLeftRight(axis: JoystickAxis): void;
  41783. /**
  41784. * Defines which axis you'd like to control for up & down
  41785. * @param axis defines the axis to use
  41786. */
  41787. setAxisForUpDown(axis: JoystickAxis): void;
  41788. private _drawVirtualJoystick;
  41789. /**
  41790. * Release internal HTML canvas
  41791. */
  41792. releaseCanvas(): void;
  41793. }
  41794. }
  41795. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41796. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41797. import { Nullable } from "babylonjs/types";
  41798. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41799. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41800. module "babylonjs/Cameras/freeCameraInputsManager" {
  41801. interface FreeCameraInputsManager {
  41802. /**
  41803. * Add virtual joystick input support to the input manager.
  41804. * @returns the current input manager
  41805. */
  41806. addVirtualJoystick(): FreeCameraInputsManager;
  41807. }
  41808. }
  41809. /**
  41810. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41812. */
  41813. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41814. /**
  41815. * Defines the camera the input is attached to.
  41816. */
  41817. camera: FreeCamera;
  41818. private _leftjoystick;
  41819. private _rightjoystick;
  41820. /**
  41821. * Gets the left stick of the virtual joystick.
  41822. * @returns The virtual Joystick
  41823. */
  41824. getLeftJoystick(): VirtualJoystick;
  41825. /**
  41826. * Gets the right stick of the virtual joystick.
  41827. * @returns The virtual Joystick
  41828. */
  41829. getRightJoystick(): VirtualJoystick;
  41830. /**
  41831. * Update the current camera state depending on the inputs that have been used this frame.
  41832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41833. */
  41834. checkInputs(): void;
  41835. /**
  41836. * Attach the input controls to a specific dom element to get the input from.
  41837. * @param element Defines the element the controls should be listened from
  41838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41839. */
  41840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41841. /**
  41842. * Detach the current controls from the specified dom element.
  41843. * @param element Defines the element to stop listening the inputs from
  41844. */
  41845. detachControl(element: Nullable<HTMLElement>): void;
  41846. /**
  41847. * Gets the class name of the current intput.
  41848. * @returns the class name
  41849. */
  41850. getClassName(): string;
  41851. /**
  41852. * Get the friendly name associated with the input class.
  41853. * @returns the input friendly name
  41854. */
  41855. getSimpleName(): string;
  41856. }
  41857. }
  41858. declare module "babylonjs/Cameras/Inputs/index" {
  41859. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41860. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41861. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41862. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41863. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41864. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41865. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41866. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41867. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41868. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41869. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41870. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41871. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41872. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41873. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41874. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41875. }
  41876. declare module "babylonjs/Cameras/touchCamera" {
  41877. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41878. import { Scene } from "babylonjs/scene";
  41879. import { Vector3 } from "babylonjs/Maths/math.vector";
  41880. /**
  41881. * This represents a FPS type of camera controlled by touch.
  41882. * This is like a universal camera minus the Gamepad controls.
  41883. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41884. */
  41885. export class TouchCamera extends FreeCamera {
  41886. /**
  41887. * Defines the touch sensibility for rotation.
  41888. * The higher the faster.
  41889. */
  41890. get touchAngularSensibility(): number;
  41891. set touchAngularSensibility(value: number);
  41892. /**
  41893. * Defines the touch sensibility for move.
  41894. * The higher the faster.
  41895. */
  41896. get touchMoveSensibility(): number;
  41897. set touchMoveSensibility(value: number);
  41898. /**
  41899. * Instantiates a new touch camera.
  41900. * This represents a FPS type of camera controlled by touch.
  41901. * This is like a universal camera minus the Gamepad controls.
  41902. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41903. * @param name Define the name of the camera in the scene
  41904. * @param position Define the start position of the camera in the scene
  41905. * @param scene Define the scene the camera belongs to
  41906. */
  41907. constructor(name: string, position: Vector3, scene: Scene);
  41908. /**
  41909. * Gets the current object class name.
  41910. * @return the class name
  41911. */
  41912. getClassName(): string;
  41913. /** @hidden */
  41914. _setupInputs(): void;
  41915. }
  41916. }
  41917. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41918. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41919. import { Scene } from "babylonjs/scene";
  41920. import { Vector3 } from "babylonjs/Maths/math.vector";
  41921. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41922. import { Axis } from "babylonjs/Maths/math.axis";
  41923. /**
  41924. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41925. * being tilted forward or back and left or right.
  41926. */
  41927. export class DeviceOrientationCamera extends FreeCamera {
  41928. private _initialQuaternion;
  41929. private _quaternionCache;
  41930. private _tmpDragQuaternion;
  41931. private _disablePointerInputWhenUsingDeviceOrientation;
  41932. /**
  41933. * Creates a new device orientation camera
  41934. * @param name The name of the camera
  41935. * @param position The start position camera
  41936. * @param scene The scene the camera belongs to
  41937. */
  41938. constructor(name: string, position: Vector3, scene: Scene);
  41939. /**
  41940. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41941. */
  41942. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41943. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41944. private _dragFactor;
  41945. /**
  41946. * Enabled turning on the y axis when the orientation sensor is active
  41947. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41948. */
  41949. enableHorizontalDragging(dragFactor?: number): void;
  41950. /**
  41951. * Gets the current instance class name ("DeviceOrientationCamera").
  41952. * This helps avoiding instanceof at run time.
  41953. * @returns the class name
  41954. */
  41955. getClassName(): string;
  41956. /**
  41957. * @hidden
  41958. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41959. */
  41960. _checkInputs(): void;
  41961. /**
  41962. * Reset the camera to its default orientation on the specified axis only.
  41963. * @param axis The axis to reset
  41964. */
  41965. resetToCurrentRotation(axis?: Axis): void;
  41966. }
  41967. }
  41968. declare module "babylonjs/Gamepads/xboxGamepad" {
  41969. import { Observable } from "babylonjs/Misc/observable";
  41970. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41971. /**
  41972. * Defines supported buttons for XBox360 compatible gamepads
  41973. */
  41974. export enum Xbox360Button {
  41975. /** A */
  41976. A = 0,
  41977. /** B */
  41978. B = 1,
  41979. /** X */
  41980. X = 2,
  41981. /** Y */
  41982. Y = 3,
  41983. /** Start */
  41984. Start = 4,
  41985. /** Back */
  41986. Back = 5,
  41987. /** Left button */
  41988. LB = 6,
  41989. /** Right button */
  41990. RB = 7,
  41991. /** Left stick */
  41992. LeftStick = 8,
  41993. /** Right stick */
  41994. RightStick = 9
  41995. }
  41996. /** Defines values for XBox360 DPad */
  41997. export enum Xbox360Dpad {
  41998. /** Up */
  41999. Up = 0,
  42000. /** Down */
  42001. Down = 1,
  42002. /** Left */
  42003. Left = 2,
  42004. /** Right */
  42005. Right = 3
  42006. }
  42007. /**
  42008. * Defines a XBox360 gamepad
  42009. */
  42010. export class Xbox360Pad extends Gamepad {
  42011. private _leftTrigger;
  42012. private _rightTrigger;
  42013. private _onlefttriggerchanged;
  42014. private _onrighttriggerchanged;
  42015. private _onbuttondown;
  42016. private _onbuttonup;
  42017. private _ondpaddown;
  42018. private _ondpadup;
  42019. /** Observable raised when a button is pressed */
  42020. onButtonDownObservable: Observable<Xbox360Button>;
  42021. /** Observable raised when a button is released */
  42022. onButtonUpObservable: Observable<Xbox360Button>;
  42023. /** Observable raised when a pad is pressed */
  42024. onPadDownObservable: Observable<Xbox360Dpad>;
  42025. /** Observable raised when a pad is released */
  42026. onPadUpObservable: Observable<Xbox360Dpad>;
  42027. private _buttonA;
  42028. private _buttonB;
  42029. private _buttonX;
  42030. private _buttonY;
  42031. private _buttonBack;
  42032. private _buttonStart;
  42033. private _buttonLB;
  42034. private _buttonRB;
  42035. private _buttonLeftStick;
  42036. private _buttonRightStick;
  42037. private _dPadUp;
  42038. private _dPadDown;
  42039. private _dPadLeft;
  42040. private _dPadRight;
  42041. private _isXboxOnePad;
  42042. /**
  42043. * Creates a new XBox360 gamepad object
  42044. * @param id defines the id of this gamepad
  42045. * @param index defines its index
  42046. * @param gamepad defines the internal HTML gamepad object
  42047. * @param xboxOne defines if it is a XBox One gamepad
  42048. */
  42049. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42050. /**
  42051. * Defines the callback to call when left trigger is pressed
  42052. * @param callback defines the callback to use
  42053. */
  42054. onlefttriggerchanged(callback: (value: number) => void): void;
  42055. /**
  42056. * Defines the callback to call when right trigger is pressed
  42057. * @param callback defines the callback to use
  42058. */
  42059. onrighttriggerchanged(callback: (value: number) => void): void;
  42060. /**
  42061. * Gets the left trigger value
  42062. */
  42063. get leftTrigger(): number;
  42064. /**
  42065. * Sets the left trigger value
  42066. */
  42067. set leftTrigger(newValue: number);
  42068. /**
  42069. * Gets the right trigger value
  42070. */
  42071. get rightTrigger(): number;
  42072. /**
  42073. * Sets the right trigger value
  42074. */
  42075. set rightTrigger(newValue: number);
  42076. /**
  42077. * Defines the callback to call when a button is pressed
  42078. * @param callback defines the callback to use
  42079. */
  42080. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42081. /**
  42082. * Defines the callback to call when a button is released
  42083. * @param callback defines the callback to use
  42084. */
  42085. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42086. /**
  42087. * Defines the callback to call when a pad is pressed
  42088. * @param callback defines the callback to use
  42089. */
  42090. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42091. /**
  42092. * Defines the callback to call when a pad is released
  42093. * @param callback defines the callback to use
  42094. */
  42095. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42096. private _setButtonValue;
  42097. private _setDPadValue;
  42098. /**
  42099. * Gets the value of the `A` button
  42100. */
  42101. get buttonA(): number;
  42102. /**
  42103. * Sets the value of the `A` button
  42104. */
  42105. set buttonA(value: number);
  42106. /**
  42107. * Gets the value of the `B` button
  42108. */
  42109. get buttonB(): number;
  42110. /**
  42111. * Sets the value of the `B` button
  42112. */
  42113. set buttonB(value: number);
  42114. /**
  42115. * Gets the value of the `X` button
  42116. */
  42117. get buttonX(): number;
  42118. /**
  42119. * Sets the value of the `X` button
  42120. */
  42121. set buttonX(value: number);
  42122. /**
  42123. * Gets the value of the `Y` button
  42124. */
  42125. get buttonY(): number;
  42126. /**
  42127. * Sets the value of the `Y` button
  42128. */
  42129. set buttonY(value: number);
  42130. /**
  42131. * Gets the value of the `Start` button
  42132. */
  42133. get buttonStart(): number;
  42134. /**
  42135. * Sets the value of the `Start` button
  42136. */
  42137. set buttonStart(value: number);
  42138. /**
  42139. * Gets the value of the `Back` button
  42140. */
  42141. get buttonBack(): number;
  42142. /**
  42143. * Sets the value of the `Back` button
  42144. */
  42145. set buttonBack(value: number);
  42146. /**
  42147. * Gets the value of the `Left` button
  42148. */
  42149. get buttonLB(): number;
  42150. /**
  42151. * Sets the value of the `Left` button
  42152. */
  42153. set buttonLB(value: number);
  42154. /**
  42155. * Gets the value of the `Right` button
  42156. */
  42157. get buttonRB(): number;
  42158. /**
  42159. * Sets the value of the `Right` button
  42160. */
  42161. set buttonRB(value: number);
  42162. /**
  42163. * Gets the value of the Left joystick
  42164. */
  42165. get buttonLeftStick(): number;
  42166. /**
  42167. * Sets the value of the Left joystick
  42168. */
  42169. set buttonLeftStick(value: number);
  42170. /**
  42171. * Gets the value of the Right joystick
  42172. */
  42173. get buttonRightStick(): number;
  42174. /**
  42175. * Sets the value of the Right joystick
  42176. */
  42177. set buttonRightStick(value: number);
  42178. /**
  42179. * Gets the value of D-pad up
  42180. */
  42181. get dPadUp(): number;
  42182. /**
  42183. * Sets the value of D-pad up
  42184. */
  42185. set dPadUp(value: number);
  42186. /**
  42187. * Gets the value of D-pad down
  42188. */
  42189. get dPadDown(): number;
  42190. /**
  42191. * Sets the value of D-pad down
  42192. */
  42193. set dPadDown(value: number);
  42194. /**
  42195. * Gets the value of D-pad left
  42196. */
  42197. get dPadLeft(): number;
  42198. /**
  42199. * Sets the value of D-pad left
  42200. */
  42201. set dPadLeft(value: number);
  42202. /**
  42203. * Gets the value of D-pad right
  42204. */
  42205. get dPadRight(): number;
  42206. /**
  42207. * Sets the value of D-pad right
  42208. */
  42209. set dPadRight(value: number);
  42210. /**
  42211. * Force the gamepad to synchronize with device values
  42212. */
  42213. update(): void;
  42214. /**
  42215. * Disposes the gamepad
  42216. */
  42217. dispose(): void;
  42218. }
  42219. }
  42220. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42221. import { Observable } from "babylonjs/Misc/observable";
  42222. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42223. /**
  42224. * Defines supported buttons for DualShock compatible gamepads
  42225. */
  42226. export enum DualShockButton {
  42227. /** Cross */
  42228. Cross = 0,
  42229. /** Circle */
  42230. Circle = 1,
  42231. /** Square */
  42232. Square = 2,
  42233. /** Triangle */
  42234. Triangle = 3,
  42235. /** Options */
  42236. Options = 4,
  42237. /** Share */
  42238. Share = 5,
  42239. /** L1 */
  42240. L1 = 6,
  42241. /** R1 */
  42242. R1 = 7,
  42243. /** Left stick */
  42244. LeftStick = 8,
  42245. /** Right stick */
  42246. RightStick = 9
  42247. }
  42248. /** Defines values for DualShock DPad */
  42249. export enum DualShockDpad {
  42250. /** Up */
  42251. Up = 0,
  42252. /** Down */
  42253. Down = 1,
  42254. /** Left */
  42255. Left = 2,
  42256. /** Right */
  42257. Right = 3
  42258. }
  42259. /**
  42260. * Defines a DualShock gamepad
  42261. */
  42262. export class DualShockPad extends Gamepad {
  42263. private _leftTrigger;
  42264. private _rightTrigger;
  42265. private _onlefttriggerchanged;
  42266. private _onrighttriggerchanged;
  42267. private _onbuttondown;
  42268. private _onbuttonup;
  42269. private _ondpaddown;
  42270. private _ondpadup;
  42271. /** Observable raised when a button is pressed */
  42272. onButtonDownObservable: Observable<DualShockButton>;
  42273. /** Observable raised when a button is released */
  42274. onButtonUpObservable: Observable<DualShockButton>;
  42275. /** Observable raised when a pad is pressed */
  42276. onPadDownObservable: Observable<DualShockDpad>;
  42277. /** Observable raised when a pad is released */
  42278. onPadUpObservable: Observable<DualShockDpad>;
  42279. private _buttonCross;
  42280. private _buttonCircle;
  42281. private _buttonSquare;
  42282. private _buttonTriangle;
  42283. private _buttonShare;
  42284. private _buttonOptions;
  42285. private _buttonL1;
  42286. private _buttonR1;
  42287. private _buttonLeftStick;
  42288. private _buttonRightStick;
  42289. private _dPadUp;
  42290. private _dPadDown;
  42291. private _dPadLeft;
  42292. private _dPadRight;
  42293. /**
  42294. * Creates a new DualShock gamepad object
  42295. * @param id defines the id of this gamepad
  42296. * @param index defines its index
  42297. * @param gamepad defines the internal HTML gamepad object
  42298. */
  42299. constructor(id: string, index: number, gamepad: any);
  42300. /**
  42301. * Defines the callback to call when left trigger is pressed
  42302. * @param callback defines the callback to use
  42303. */
  42304. onlefttriggerchanged(callback: (value: number) => void): void;
  42305. /**
  42306. * Defines the callback to call when right trigger is pressed
  42307. * @param callback defines the callback to use
  42308. */
  42309. onrighttriggerchanged(callback: (value: number) => void): void;
  42310. /**
  42311. * Gets the left trigger value
  42312. */
  42313. get leftTrigger(): number;
  42314. /**
  42315. * Sets the left trigger value
  42316. */
  42317. set leftTrigger(newValue: number);
  42318. /**
  42319. * Gets the right trigger value
  42320. */
  42321. get rightTrigger(): number;
  42322. /**
  42323. * Sets the right trigger value
  42324. */
  42325. set rightTrigger(newValue: number);
  42326. /**
  42327. * Defines the callback to call when a button is pressed
  42328. * @param callback defines the callback to use
  42329. */
  42330. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42331. /**
  42332. * Defines the callback to call when a button is released
  42333. * @param callback defines the callback to use
  42334. */
  42335. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42336. /**
  42337. * Defines the callback to call when a pad is pressed
  42338. * @param callback defines the callback to use
  42339. */
  42340. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42341. /**
  42342. * Defines the callback to call when a pad is released
  42343. * @param callback defines the callback to use
  42344. */
  42345. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42346. private _setButtonValue;
  42347. private _setDPadValue;
  42348. /**
  42349. * Gets the value of the `Cross` button
  42350. */
  42351. get buttonCross(): number;
  42352. /**
  42353. * Sets the value of the `Cross` button
  42354. */
  42355. set buttonCross(value: number);
  42356. /**
  42357. * Gets the value of the `Circle` button
  42358. */
  42359. get buttonCircle(): number;
  42360. /**
  42361. * Sets the value of the `Circle` button
  42362. */
  42363. set buttonCircle(value: number);
  42364. /**
  42365. * Gets the value of the `Square` button
  42366. */
  42367. get buttonSquare(): number;
  42368. /**
  42369. * Sets the value of the `Square` button
  42370. */
  42371. set buttonSquare(value: number);
  42372. /**
  42373. * Gets the value of the `Triangle` button
  42374. */
  42375. get buttonTriangle(): number;
  42376. /**
  42377. * Sets the value of the `Triangle` button
  42378. */
  42379. set buttonTriangle(value: number);
  42380. /**
  42381. * Gets the value of the `Options` button
  42382. */
  42383. get buttonOptions(): number;
  42384. /**
  42385. * Sets the value of the `Options` button
  42386. */
  42387. set buttonOptions(value: number);
  42388. /**
  42389. * Gets the value of the `Share` button
  42390. */
  42391. get buttonShare(): number;
  42392. /**
  42393. * Sets the value of the `Share` button
  42394. */
  42395. set buttonShare(value: number);
  42396. /**
  42397. * Gets the value of the `L1` button
  42398. */
  42399. get buttonL1(): number;
  42400. /**
  42401. * Sets the value of the `L1` button
  42402. */
  42403. set buttonL1(value: number);
  42404. /**
  42405. * Gets the value of the `R1` button
  42406. */
  42407. get buttonR1(): number;
  42408. /**
  42409. * Sets the value of the `R1` button
  42410. */
  42411. set buttonR1(value: number);
  42412. /**
  42413. * Gets the value of the Left joystick
  42414. */
  42415. get buttonLeftStick(): number;
  42416. /**
  42417. * Sets the value of the Left joystick
  42418. */
  42419. set buttonLeftStick(value: number);
  42420. /**
  42421. * Gets the value of the Right joystick
  42422. */
  42423. get buttonRightStick(): number;
  42424. /**
  42425. * Sets the value of the Right joystick
  42426. */
  42427. set buttonRightStick(value: number);
  42428. /**
  42429. * Gets the value of D-pad up
  42430. */
  42431. get dPadUp(): number;
  42432. /**
  42433. * Sets the value of D-pad up
  42434. */
  42435. set dPadUp(value: number);
  42436. /**
  42437. * Gets the value of D-pad down
  42438. */
  42439. get dPadDown(): number;
  42440. /**
  42441. * Sets the value of D-pad down
  42442. */
  42443. set dPadDown(value: number);
  42444. /**
  42445. * Gets the value of D-pad left
  42446. */
  42447. get dPadLeft(): number;
  42448. /**
  42449. * Sets the value of D-pad left
  42450. */
  42451. set dPadLeft(value: number);
  42452. /**
  42453. * Gets the value of D-pad right
  42454. */
  42455. get dPadRight(): number;
  42456. /**
  42457. * Sets the value of D-pad right
  42458. */
  42459. set dPadRight(value: number);
  42460. /**
  42461. * Force the gamepad to synchronize with device values
  42462. */
  42463. update(): void;
  42464. /**
  42465. * Disposes the gamepad
  42466. */
  42467. dispose(): void;
  42468. }
  42469. }
  42470. declare module "babylonjs/Gamepads/gamepadManager" {
  42471. import { Observable } from "babylonjs/Misc/observable";
  42472. import { Nullable } from "babylonjs/types";
  42473. import { Scene } from "babylonjs/scene";
  42474. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42475. /**
  42476. * Manager for handling gamepads
  42477. */
  42478. export class GamepadManager {
  42479. private _scene?;
  42480. private _babylonGamepads;
  42481. private _oneGamepadConnected;
  42482. /** @hidden */
  42483. _isMonitoring: boolean;
  42484. private _gamepadEventSupported;
  42485. private _gamepadSupport?;
  42486. /**
  42487. * observable to be triggered when the gamepad controller has been connected
  42488. */
  42489. onGamepadConnectedObservable: Observable<Gamepad>;
  42490. /**
  42491. * observable to be triggered when the gamepad controller has been disconnected
  42492. */
  42493. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42494. private _onGamepadConnectedEvent;
  42495. private _onGamepadDisconnectedEvent;
  42496. /**
  42497. * Initializes the gamepad manager
  42498. * @param _scene BabylonJS scene
  42499. */
  42500. constructor(_scene?: Scene | undefined);
  42501. /**
  42502. * The gamepads in the game pad manager
  42503. */
  42504. get gamepads(): Gamepad[];
  42505. /**
  42506. * Get the gamepad controllers based on type
  42507. * @param type The type of gamepad controller
  42508. * @returns Nullable gamepad
  42509. */
  42510. getGamepadByType(type?: number): Nullable<Gamepad>;
  42511. /**
  42512. * Disposes the gamepad manager
  42513. */
  42514. dispose(): void;
  42515. private _addNewGamepad;
  42516. private _startMonitoringGamepads;
  42517. private _stopMonitoringGamepads;
  42518. /** @hidden */
  42519. _checkGamepadsStatus(): void;
  42520. private _updateGamepadObjects;
  42521. }
  42522. }
  42523. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42524. import { Nullable } from "babylonjs/types";
  42525. import { Scene } from "babylonjs/scene";
  42526. import { ISceneComponent } from "babylonjs/sceneComponent";
  42527. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42528. module "babylonjs/scene" {
  42529. interface Scene {
  42530. /** @hidden */
  42531. _gamepadManager: Nullable<GamepadManager>;
  42532. /**
  42533. * Gets the gamepad manager associated with the scene
  42534. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42535. */
  42536. gamepadManager: GamepadManager;
  42537. }
  42538. }
  42539. module "babylonjs/Cameras/freeCameraInputsManager" {
  42540. /**
  42541. * Interface representing a free camera inputs manager
  42542. */
  42543. interface FreeCameraInputsManager {
  42544. /**
  42545. * Adds gamepad input support to the FreeCameraInputsManager.
  42546. * @returns the FreeCameraInputsManager
  42547. */
  42548. addGamepad(): FreeCameraInputsManager;
  42549. }
  42550. }
  42551. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42552. /**
  42553. * Interface representing an arc rotate camera inputs manager
  42554. */
  42555. interface ArcRotateCameraInputsManager {
  42556. /**
  42557. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42558. * @returns the camera inputs manager
  42559. */
  42560. addGamepad(): ArcRotateCameraInputsManager;
  42561. }
  42562. }
  42563. /**
  42564. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42565. */
  42566. export class GamepadSystemSceneComponent implements ISceneComponent {
  42567. /**
  42568. * The component name helpfull to identify the component in the list of scene components.
  42569. */
  42570. readonly name: string;
  42571. /**
  42572. * The scene the component belongs to.
  42573. */
  42574. scene: Scene;
  42575. /**
  42576. * Creates a new instance of the component for the given scene
  42577. * @param scene Defines the scene to register the component in
  42578. */
  42579. constructor(scene: Scene);
  42580. /**
  42581. * Registers the component in a given scene
  42582. */
  42583. register(): void;
  42584. /**
  42585. * Rebuilds the elements related to this component in case of
  42586. * context lost for instance.
  42587. */
  42588. rebuild(): void;
  42589. /**
  42590. * Disposes the component and the associated ressources
  42591. */
  42592. dispose(): void;
  42593. private _beforeCameraUpdate;
  42594. }
  42595. }
  42596. declare module "babylonjs/Cameras/universalCamera" {
  42597. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42598. import { Scene } from "babylonjs/scene";
  42599. import { Vector3 } from "babylonjs/Maths/math.vector";
  42600. import "babylonjs/Gamepads/gamepadSceneComponent";
  42601. /**
  42602. * 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,
  42603. * which still works and will still be found in many Playgrounds.
  42604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42605. */
  42606. export class UniversalCamera extends TouchCamera {
  42607. /**
  42608. * Defines the gamepad rotation sensiblity.
  42609. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42610. */
  42611. get gamepadAngularSensibility(): number;
  42612. set gamepadAngularSensibility(value: number);
  42613. /**
  42614. * Defines the gamepad move sensiblity.
  42615. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42616. */
  42617. get gamepadMoveSensibility(): number;
  42618. set gamepadMoveSensibility(value: number);
  42619. /**
  42620. * 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,
  42621. * which still works and will still be found in many Playgrounds.
  42622. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42623. * @param name Define the name of the camera in the scene
  42624. * @param position Define the start position of the camera in the scene
  42625. * @param scene Define the scene the camera belongs to
  42626. */
  42627. constructor(name: string, position: Vector3, scene: Scene);
  42628. /**
  42629. * Gets the current object class name.
  42630. * @return the class name
  42631. */
  42632. getClassName(): string;
  42633. }
  42634. }
  42635. declare module "babylonjs/Cameras/gamepadCamera" {
  42636. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42637. import { Scene } from "babylonjs/scene";
  42638. import { Vector3 } from "babylonjs/Maths/math.vector";
  42639. /**
  42640. * This represents a FPS type of camera. This is only here for back compat purpose.
  42641. * Please use the UniversalCamera instead as both are identical.
  42642. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42643. */
  42644. export class GamepadCamera extends UniversalCamera {
  42645. /**
  42646. * Instantiates a new Gamepad Camera
  42647. * This represents a FPS type of camera. This is only here for back compat purpose.
  42648. * Please use the UniversalCamera instead as both are identical.
  42649. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42650. * @param name Define the name of the camera in the scene
  42651. * @param position Define the start position of the camera in the scene
  42652. * @param scene Define the scene the camera belongs to
  42653. */
  42654. constructor(name: string, position: Vector3, scene: Scene);
  42655. /**
  42656. * Gets the current object class name.
  42657. * @return the class name
  42658. */
  42659. getClassName(): string;
  42660. }
  42661. }
  42662. declare module "babylonjs/Shaders/pass.fragment" {
  42663. /** @hidden */
  42664. export var passPixelShader: {
  42665. name: string;
  42666. shader: string;
  42667. };
  42668. }
  42669. declare module "babylonjs/Shaders/passCube.fragment" {
  42670. /** @hidden */
  42671. export var passCubePixelShader: {
  42672. name: string;
  42673. shader: string;
  42674. };
  42675. }
  42676. declare module "babylonjs/PostProcesses/passPostProcess" {
  42677. import { Nullable } from "babylonjs/types";
  42678. import { Camera } from "babylonjs/Cameras/camera";
  42679. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42680. import { Engine } from "babylonjs/Engines/engine";
  42681. import "babylonjs/Shaders/pass.fragment";
  42682. import "babylonjs/Shaders/passCube.fragment";
  42683. /**
  42684. * PassPostProcess which produces an output the same as it's input
  42685. */
  42686. export class PassPostProcess extends PostProcess {
  42687. /**
  42688. * Creates the PassPostProcess
  42689. * @param name The name of the effect.
  42690. * @param options The required width/height ratio to downsize to before computing the render pass.
  42691. * @param camera The camera to apply the render pass to.
  42692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42693. * @param engine The engine which the post process will be applied. (default: current engine)
  42694. * @param reusable If the post process can be reused on the same frame. (default: false)
  42695. * @param textureType The type of texture to be used when performing the post processing.
  42696. * @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)
  42697. */
  42698. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42699. }
  42700. /**
  42701. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42702. */
  42703. export class PassCubePostProcess extends PostProcess {
  42704. private _face;
  42705. /**
  42706. * Gets or sets the cube face to display.
  42707. * * 0 is +X
  42708. * * 1 is -X
  42709. * * 2 is +Y
  42710. * * 3 is -Y
  42711. * * 4 is +Z
  42712. * * 5 is -Z
  42713. */
  42714. get face(): number;
  42715. set face(value: number);
  42716. /**
  42717. * Creates the PassCubePostProcess
  42718. * @param name The name of the effect.
  42719. * @param options The required width/height ratio to downsize to before computing the render pass.
  42720. * @param camera The camera to apply the render pass to.
  42721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42722. * @param engine The engine which the post process will be applied. (default: current engine)
  42723. * @param reusable If the post process can be reused on the same frame. (default: false)
  42724. * @param textureType The type of texture to be used when performing the post processing.
  42725. * @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)
  42726. */
  42727. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42728. }
  42729. }
  42730. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42731. /** @hidden */
  42732. export var anaglyphPixelShader: {
  42733. name: string;
  42734. shader: string;
  42735. };
  42736. }
  42737. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42738. import { Engine } from "babylonjs/Engines/engine";
  42739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42740. import { Camera } from "babylonjs/Cameras/camera";
  42741. import "babylonjs/Shaders/anaglyph.fragment";
  42742. /**
  42743. * Postprocess used to generate anaglyphic rendering
  42744. */
  42745. export class AnaglyphPostProcess extends PostProcess {
  42746. private _passedProcess;
  42747. /**
  42748. * Creates a new AnaglyphPostProcess
  42749. * @param name defines postprocess name
  42750. * @param options defines creation options or target ratio scale
  42751. * @param rigCameras defines cameras using this postprocess
  42752. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42753. * @param engine defines hosting engine
  42754. * @param reusable defines if the postprocess will be reused multiple times per frame
  42755. */
  42756. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42757. }
  42758. }
  42759. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42760. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42761. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42762. import { Scene } from "babylonjs/scene";
  42763. import { Vector3 } from "babylonjs/Maths/math.vector";
  42764. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42765. /**
  42766. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42767. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42768. */
  42769. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42770. /**
  42771. * Creates a new AnaglyphArcRotateCamera
  42772. * @param name defines camera name
  42773. * @param alpha defines alpha angle (in radians)
  42774. * @param beta defines beta angle (in radians)
  42775. * @param radius defines radius
  42776. * @param target defines camera target
  42777. * @param interaxialDistance defines distance between each color axis
  42778. * @param scene defines the hosting scene
  42779. */
  42780. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42781. /**
  42782. * Gets camera class name
  42783. * @returns AnaglyphArcRotateCamera
  42784. */
  42785. getClassName(): string;
  42786. }
  42787. }
  42788. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42789. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42790. import { Scene } from "babylonjs/scene";
  42791. import { Vector3 } from "babylonjs/Maths/math.vector";
  42792. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42793. /**
  42794. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42795. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42796. */
  42797. export class AnaglyphFreeCamera extends FreeCamera {
  42798. /**
  42799. * Creates a new AnaglyphFreeCamera
  42800. * @param name defines camera name
  42801. * @param position defines initial position
  42802. * @param interaxialDistance defines distance between each color axis
  42803. * @param scene defines the hosting scene
  42804. */
  42805. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42806. /**
  42807. * Gets camera class name
  42808. * @returns AnaglyphFreeCamera
  42809. */
  42810. getClassName(): string;
  42811. }
  42812. }
  42813. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42814. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42815. import { Scene } from "babylonjs/scene";
  42816. import { Vector3 } from "babylonjs/Maths/math.vector";
  42817. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42818. /**
  42819. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42820. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42821. */
  42822. export class AnaglyphGamepadCamera extends GamepadCamera {
  42823. /**
  42824. * Creates a new AnaglyphGamepadCamera
  42825. * @param name defines camera name
  42826. * @param position defines initial position
  42827. * @param interaxialDistance defines distance between each color axis
  42828. * @param scene defines the hosting scene
  42829. */
  42830. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42831. /**
  42832. * Gets camera class name
  42833. * @returns AnaglyphGamepadCamera
  42834. */
  42835. getClassName(): string;
  42836. }
  42837. }
  42838. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42839. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42840. import { Scene } from "babylonjs/scene";
  42841. import { Vector3 } from "babylonjs/Maths/math.vector";
  42842. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42843. /**
  42844. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42845. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42846. */
  42847. export class AnaglyphUniversalCamera extends UniversalCamera {
  42848. /**
  42849. * Creates a new AnaglyphUniversalCamera
  42850. * @param name defines camera name
  42851. * @param position defines initial position
  42852. * @param interaxialDistance defines distance between each color axis
  42853. * @param scene defines the hosting scene
  42854. */
  42855. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42856. /**
  42857. * Gets camera class name
  42858. * @returns AnaglyphUniversalCamera
  42859. */
  42860. getClassName(): string;
  42861. }
  42862. }
  42863. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42864. /** @hidden */
  42865. export var stereoscopicInterlacePixelShader: {
  42866. name: string;
  42867. shader: string;
  42868. };
  42869. }
  42870. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42871. import { Camera } from "babylonjs/Cameras/camera";
  42872. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42873. import { Engine } from "babylonjs/Engines/engine";
  42874. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42875. /**
  42876. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42877. */
  42878. export class StereoscopicInterlacePostProcess extends PostProcess {
  42879. private _stepSize;
  42880. private _passedProcess;
  42881. /**
  42882. * Initializes a StereoscopicInterlacePostProcess
  42883. * @param name The name of the effect.
  42884. * @param rigCameras The rig cameras to be appled to the post process
  42885. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42887. * @param engine The engine which the post process will be applied. (default: current engine)
  42888. * @param reusable If the post process can be reused on the same frame. (default: false)
  42889. */
  42890. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42891. }
  42892. }
  42893. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42894. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42895. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42896. import { Scene } from "babylonjs/scene";
  42897. import { Vector3 } from "babylonjs/Maths/math.vector";
  42898. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42899. /**
  42900. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42901. * @see http://doc.babylonjs.com/features/cameras
  42902. */
  42903. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42904. /**
  42905. * Creates a new StereoscopicArcRotateCamera
  42906. * @param name defines camera name
  42907. * @param alpha defines alpha angle (in radians)
  42908. * @param beta defines beta angle (in radians)
  42909. * @param radius defines radius
  42910. * @param target defines camera target
  42911. * @param interaxialDistance defines distance between each color axis
  42912. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42913. * @param scene defines the hosting scene
  42914. */
  42915. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42916. /**
  42917. * Gets camera class name
  42918. * @returns StereoscopicArcRotateCamera
  42919. */
  42920. getClassName(): string;
  42921. }
  42922. }
  42923. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42924. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42925. import { Scene } from "babylonjs/scene";
  42926. import { Vector3 } from "babylonjs/Maths/math.vector";
  42927. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42928. /**
  42929. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42930. * @see http://doc.babylonjs.com/features/cameras
  42931. */
  42932. export class StereoscopicFreeCamera extends FreeCamera {
  42933. /**
  42934. * Creates a new StereoscopicFreeCamera
  42935. * @param name defines camera name
  42936. * @param position defines initial position
  42937. * @param interaxialDistance defines distance between each color axis
  42938. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42939. * @param scene defines the hosting scene
  42940. */
  42941. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42942. /**
  42943. * Gets camera class name
  42944. * @returns StereoscopicFreeCamera
  42945. */
  42946. getClassName(): string;
  42947. }
  42948. }
  42949. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42950. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42951. import { Scene } from "babylonjs/scene";
  42952. import { Vector3 } from "babylonjs/Maths/math.vector";
  42953. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42954. /**
  42955. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42956. * @see http://doc.babylonjs.com/features/cameras
  42957. */
  42958. export class StereoscopicGamepadCamera extends GamepadCamera {
  42959. /**
  42960. * Creates a new StereoscopicGamepadCamera
  42961. * @param name defines camera name
  42962. * @param position defines initial position
  42963. * @param interaxialDistance defines distance between each color axis
  42964. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42965. * @param scene defines the hosting scene
  42966. */
  42967. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42968. /**
  42969. * Gets camera class name
  42970. * @returns StereoscopicGamepadCamera
  42971. */
  42972. getClassName(): string;
  42973. }
  42974. }
  42975. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42976. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42977. import { Scene } from "babylonjs/scene";
  42978. import { Vector3 } from "babylonjs/Maths/math.vector";
  42979. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42980. /**
  42981. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42982. * @see http://doc.babylonjs.com/features/cameras
  42983. */
  42984. export class StereoscopicUniversalCamera extends UniversalCamera {
  42985. /**
  42986. * Creates a new StereoscopicUniversalCamera
  42987. * @param name defines camera name
  42988. * @param position defines initial position
  42989. * @param interaxialDistance defines distance between each color axis
  42990. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42991. * @param scene defines the hosting scene
  42992. */
  42993. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42994. /**
  42995. * Gets camera class name
  42996. * @returns StereoscopicUniversalCamera
  42997. */
  42998. getClassName(): string;
  42999. }
  43000. }
  43001. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43002. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43003. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43004. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43005. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43006. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43007. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43008. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43009. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43010. }
  43011. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43012. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43013. import { Scene } from "babylonjs/scene";
  43014. import { Vector3 } from "babylonjs/Maths/math.vector";
  43015. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43016. /**
  43017. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43018. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43019. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43020. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43021. */
  43022. export class VirtualJoysticksCamera extends FreeCamera {
  43023. /**
  43024. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43025. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43026. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43027. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43028. * @param name Define the name of the camera in the scene
  43029. * @param position Define the start position of the camera in the scene
  43030. * @param scene Define the scene the camera belongs to
  43031. */
  43032. constructor(name: string, position: Vector3, scene: Scene);
  43033. /**
  43034. * Gets the current object class name.
  43035. * @return the class name
  43036. */
  43037. getClassName(): string;
  43038. }
  43039. }
  43040. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43041. import { Matrix } from "babylonjs/Maths/math.vector";
  43042. /**
  43043. * This represents all the required metrics to create a VR camera.
  43044. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43045. */
  43046. export class VRCameraMetrics {
  43047. /**
  43048. * Define the horizontal resolution off the screen.
  43049. */
  43050. hResolution: number;
  43051. /**
  43052. * Define the vertical resolution off the screen.
  43053. */
  43054. vResolution: number;
  43055. /**
  43056. * Define the horizontal screen size.
  43057. */
  43058. hScreenSize: number;
  43059. /**
  43060. * Define the vertical screen size.
  43061. */
  43062. vScreenSize: number;
  43063. /**
  43064. * Define the vertical screen center position.
  43065. */
  43066. vScreenCenter: number;
  43067. /**
  43068. * Define the distance of the eyes to the screen.
  43069. */
  43070. eyeToScreenDistance: number;
  43071. /**
  43072. * Define the distance between both lenses
  43073. */
  43074. lensSeparationDistance: number;
  43075. /**
  43076. * Define the distance between both viewer's eyes.
  43077. */
  43078. interpupillaryDistance: number;
  43079. /**
  43080. * Define the distortion factor of the VR postprocess.
  43081. * Please, touch with care.
  43082. */
  43083. distortionK: number[];
  43084. /**
  43085. * Define the chromatic aberration correction factors for the VR post process.
  43086. */
  43087. chromaAbCorrection: number[];
  43088. /**
  43089. * Define the scale factor of the post process.
  43090. * The smaller the better but the slower.
  43091. */
  43092. postProcessScaleFactor: number;
  43093. /**
  43094. * Define an offset for the lens center.
  43095. */
  43096. lensCenterOffset: number;
  43097. /**
  43098. * Define if the current vr camera should compensate the distortion of the lense or not.
  43099. */
  43100. compensateDistortion: boolean;
  43101. /**
  43102. * Defines if multiview should be enabled when rendering (Default: false)
  43103. */
  43104. multiviewEnabled: boolean;
  43105. /**
  43106. * Gets the rendering aspect ratio based on the provided resolutions.
  43107. */
  43108. get aspectRatio(): number;
  43109. /**
  43110. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43111. */
  43112. get aspectRatioFov(): number;
  43113. /**
  43114. * @hidden
  43115. */
  43116. get leftHMatrix(): Matrix;
  43117. /**
  43118. * @hidden
  43119. */
  43120. get rightHMatrix(): Matrix;
  43121. /**
  43122. * @hidden
  43123. */
  43124. get leftPreViewMatrix(): Matrix;
  43125. /**
  43126. * @hidden
  43127. */
  43128. get rightPreViewMatrix(): Matrix;
  43129. /**
  43130. * Get the default VRMetrics based on the most generic setup.
  43131. * @returns the default vr metrics
  43132. */
  43133. static GetDefault(): VRCameraMetrics;
  43134. }
  43135. }
  43136. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43137. /** @hidden */
  43138. export var vrDistortionCorrectionPixelShader: {
  43139. name: string;
  43140. shader: string;
  43141. };
  43142. }
  43143. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43144. import { Camera } from "babylonjs/Cameras/camera";
  43145. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43146. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43147. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43148. /**
  43149. * VRDistortionCorrectionPostProcess used for mobile VR
  43150. */
  43151. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43152. private _isRightEye;
  43153. private _distortionFactors;
  43154. private _postProcessScaleFactor;
  43155. private _lensCenterOffset;
  43156. private _scaleIn;
  43157. private _scaleFactor;
  43158. private _lensCenter;
  43159. /**
  43160. * Initializes the VRDistortionCorrectionPostProcess
  43161. * @param name The name of the effect.
  43162. * @param camera The camera to apply the render pass to.
  43163. * @param isRightEye If this is for the right eye distortion
  43164. * @param vrMetrics All the required metrics for the VR camera
  43165. */
  43166. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43167. }
  43168. }
  43169. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43170. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43171. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43172. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43173. import { Scene } from "babylonjs/scene";
  43174. import { Vector3 } from "babylonjs/Maths/math.vector";
  43175. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43176. import "babylonjs/Cameras/RigModes/vrRigMode";
  43177. /**
  43178. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43179. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43180. */
  43181. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43182. /**
  43183. * Creates a new VRDeviceOrientationArcRotateCamera
  43184. * @param name defines camera name
  43185. * @param alpha defines the camera rotation along the logitudinal axis
  43186. * @param beta defines the camera rotation along the latitudinal axis
  43187. * @param radius defines the camera distance from its target
  43188. * @param target defines the camera target
  43189. * @param scene defines the scene the camera belongs to
  43190. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43191. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43192. */
  43193. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43194. /**
  43195. * Gets camera class name
  43196. * @returns VRDeviceOrientationArcRotateCamera
  43197. */
  43198. getClassName(): string;
  43199. }
  43200. }
  43201. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43202. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43203. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43204. import { Scene } from "babylonjs/scene";
  43205. import { Vector3 } from "babylonjs/Maths/math.vector";
  43206. import "babylonjs/Cameras/RigModes/vrRigMode";
  43207. /**
  43208. * Camera used to simulate VR rendering (based on FreeCamera)
  43209. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43210. */
  43211. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43212. /**
  43213. * Creates a new VRDeviceOrientationFreeCamera
  43214. * @param name defines camera name
  43215. * @param position defines the start position of the camera
  43216. * @param scene defines the scene the camera belongs to
  43217. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43218. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43219. */
  43220. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43221. /**
  43222. * Gets camera class name
  43223. * @returns VRDeviceOrientationFreeCamera
  43224. */
  43225. getClassName(): string;
  43226. }
  43227. }
  43228. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43229. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43230. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43231. import { Scene } from "babylonjs/scene";
  43232. import { Vector3 } from "babylonjs/Maths/math.vector";
  43233. import "babylonjs/Gamepads/gamepadSceneComponent";
  43234. /**
  43235. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43236. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43237. */
  43238. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43239. /**
  43240. * Creates a new VRDeviceOrientationGamepadCamera
  43241. * @param name defines camera name
  43242. * @param position defines the start position of the camera
  43243. * @param scene defines the scene the camera belongs to
  43244. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43245. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43246. */
  43247. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43248. /**
  43249. * Gets camera class name
  43250. * @returns VRDeviceOrientationGamepadCamera
  43251. */
  43252. getClassName(): string;
  43253. }
  43254. }
  43255. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43256. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43257. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43258. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43259. /** @hidden */
  43260. export var imageProcessingPixelShader: {
  43261. name: string;
  43262. shader: string;
  43263. };
  43264. }
  43265. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43266. import { Nullable } from "babylonjs/types";
  43267. import { Color4 } from "babylonjs/Maths/math.color";
  43268. import { Camera } from "babylonjs/Cameras/camera";
  43269. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43270. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43271. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43272. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43273. import { Engine } from "babylonjs/Engines/engine";
  43274. import "babylonjs/Shaders/imageProcessing.fragment";
  43275. import "babylonjs/Shaders/postprocess.vertex";
  43276. /**
  43277. * ImageProcessingPostProcess
  43278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43279. */
  43280. export class ImageProcessingPostProcess extends PostProcess {
  43281. /**
  43282. * Default configuration related to image processing available in the PBR Material.
  43283. */
  43284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43285. /**
  43286. * Gets the image processing configuration used either in this material.
  43287. */
  43288. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43289. /**
  43290. * Sets the Default image processing configuration used either in the this material.
  43291. *
  43292. * If sets to null, the scene one is in use.
  43293. */
  43294. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43295. /**
  43296. * Keep track of the image processing observer to allow dispose and replace.
  43297. */
  43298. private _imageProcessingObserver;
  43299. /**
  43300. * Attaches a new image processing configuration to the PBR Material.
  43301. * @param configuration
  43302. */
  43303. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43304. /**
  43305. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43306. */
  43307. get colorCurves(): Nullable<ColorCurves>;
  43308. /**
  43309. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43310. */
  43311. set colorCurves(value: Nullable<ColorCurves>);
  43312. /**
  43313. * Gets wether the color curves effect is enabled.
  43314. */
  43315. get colorCurvesEnabled(): boolean;
  43316. /**
  43317. * Sets wether the color curves effect is enabled.
  43318. */
  43319. set colorCurvesEnabled(value: boolean);
  43320. /**
  43321. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43322. */
  43323. get colorGradingTexture(): Nullable<BaseTexture>;
  43324. /**
  43325. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43326. */
  43327. set colorGradingTexture(value: Nullable<BaseTexture>);
  43328. /**
  43329. * Gets wether the color grading effect is enabled.
  43330. */
  43331. get colorGradingEnabled(): boolean;
  43332. /**
  43333. * Gets wether the color grading effect is enabled.
  43334. */
  43335. set colorGradingEnabled(value: boolean);
  43336. /**
  43337. * Gets exposure used in the effect.
  43338. */
  43339. get exposure(): number;
  43340. /**
  43341. * Sets exposure used in the effect.
  43342. */
  43343. set exposure(value: number);
  43344. /**
  43345. * Gets wether tonemapping is enabled or not.
  43346. */
  43347. get toneMappingEnabled(): boolean;
  43348. /**
  43349. * Sets wether tonemapping is enabled or not
  43350. */
  43351. set toneMappingEnabled(value: boolean);
  43352. /**
  43353. * Gets the type of tone mapping effect.
  43354. */
  43355. get toneMappingType(): number;
  43356. /**
  43357. * Sets the type of tone mapping effect.
  43358. */
  43359. set toneMappingType(value: number);
  43360. /**
  43361. * Gets contrast used in the effect.
  43362. */
  43363. get contrast(): number;
  43364. /**
  43365. * Sets contrast used in the effect.
  43366. */
  43367. set contrast(value: number);
  43368. /**
  43369. * Gets Vignette stretch size.
  43370. */
  43371. get vignetteStretch(): number;
  43372. /**
  43373. * Sets Vignette stretch size.
  43374. */
  43375. set vignetteStretch(value: number);
  43376. /**
  43377. * Gets Vignette centre X Offset.
  43378. */
  43379. get vignetteCentreX(): number;
  43380. /**
  43381. * Sets Vignette centre X Offset.
  43382. */
  43383. set vignetteCentreX(value: number);
  43384. /**
  43385. * Gets Vignette centre Y Offset.
  43386. */
  43387. get vignetteCentreY(): number;
  43388. /**
  43389. * Sets Vignette centre Y Offset.
  43390. */
  43391. set vignetteCentreY(value: number);
  43392. /**
  43393. * Gets Vignette weight or intensity of the vignette effect.
  43394. */
  43395. get vignetteWeight(): number;
  43396. /**
  43397. * Sets Vignette weight or intensity of the vignette effect.
  43398. */
  43399. set vignetteWeight(value: number);
  43400. /**
  43401. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43402. * if vignetteEnabled is set to true.
  43403. */
  43404. get vignetteColor(): Color4;
  43405. /**
  43406. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43407. * if vignetteEnabled is set to true.
  43408. */
  43409. set vignetteColor(value: Color4);
  43410. /**
  43411. * Gets Camera field of view used by the Vignette effect.
  43412. */
  43413. get vignetteCameraFov(): number;
  43414. /**
  43415. * Sets Camera field of view used by the Vignette effect.
  43416. */
  43417. set vignetteCameraFov(value: number);
  43418. /**
  43419. * Gets the vignette blend mode allowing different kind of effect.
  43420. */
  43421. get vignetteBlendMode(): number;
  43422. /**
  43423. * Sets the vignette blend mode allowing different kind of effect.
  43424. */
  43425. set vignetteBlendMode(value: number);
  43426. /**
  43427. * Gets wether the vignette effect is enabled.
  43428. */
  43429. get vignetteEnabled(): boolean;
  43430. /**
  43431. * Sets wether the vignette effect is enabled.
  43432. */
  43433. set vignetteEnabled(value: boolean);
  43434. private _fromLinearSpace;
  43435. /**
  43436. * Gets wether the input of the processing is in Gamma or Linear Space.
  43437. */
  43438. get fromLinearSpace(): boolean;
  43439. /**
  43440. * Sets wether the input of the processing is in Gamma or Linear Space.
  43441. */
  43442. set fromLinearSpace(value: boolean);
  43443. /**
  43444. * Defines cache preventing GC.
  43445. */
  43446. private _defines;
  43447. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43448. /**
  43449. * "ImageProcessingPostProcess"
  43450. * @returns "ImageProcessingPostProcess"
  43451. */
  43452. getClassName(): string;
  43453. protected _updateParameters(): void;
  43454. dispose(camera?: Camera): void;
  43455. }
  43456. }
  43457. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43458. import { Scene } from "babylonjs/scene";
  43459. import { Color3 } from "babylonjs/Maths/math.color";
  43460. import { Mesh } from "babylonjs/Meshes/mesh";
  43461. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43462. import { Nullable } from "babylonjs/types";
  43463. /**
  43464. * Class containing static functions to help procedurally build meshes
  43465. */
  43466. export class GroundBuilder {
  43467. /**
  43468. * Creates a ground mesh
  43469. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43470. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43472. * @param name defines the name of the mesh
  43473. * @param options defines the options used to create the mesh
  43474. * @param scene defines the hosting scene
  43475. * @returns the ground mesh
  43476. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43477. */
  43478. static CreateGround(name: string, options: {
  43479. width?: number;
  43480. height?: number;
  43481. subdivisions?: number;
  43482. subdivisionsX?: number;
  43483. subdivisionsY?: number;
  43484. updatable?: boolean;
  43485. }, scene: any): Mesh;
  43486. /**
  43487. * Creates a tiled ground mesh
  43488. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43489. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43490. * * 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
  43491. * * 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
  43492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43493. * @param name defines the name of the mesh
  43494. * @param options defines the options used to create the mesh
  43495. * @param scene defines the hosting scene
  43496. * @returns the tiled ground mesh
  43497. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43498. */
  43499. static CreateTiledGround(name: string, options: {
  43500. xmin: number;
  43501. zmin: number;
  43502. xmax: number;
  43503. zmax: number;
  43504. subdivisions?: {
  43505. w: number;
  43506. h: number;
  43507. };
  43508. precision?: {
  43509. w: number;
  43510. h: number;
  43511. };
  43512. updatable?: boolean;
  43513. }, scene?: Nullable<Scene>): Mesh;
  43514. /**
  43515. * Creates a ground mesh from a height map
  43516. * * The parameter `url` sets the URL of the height map image resource.
  43517. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43518. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43519. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43520. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43521. * * 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.
  43522. * * 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).
  43523. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43525. * @param name defines the name of the mesh
  43526. * @param url defines the url to the height map
  43527. * @param options defines the options used to create the mesh
  43528. * @param scene defines the hosting scene
  43529. * @returns the ground mesh
  43530. * @see https://doc.babylonjs.com/babylon101/height_map
  43531. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43532. */
  43533. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43534. width?: number;
  43535. height?: number;
  43536. subdivisions?: number;
  43537. minHeight?: number;
  43538. maxHeight?: number;
  43539. colorFilter?: Color3;
  43540. alphaFilter?: number;
  43541. updatable?: boolean;
  43542. onReady?: (mesh: GroundMesh) => void;
  43543. }, scene?: Nullable<Scene>): GroundMesh;
  43544. }
  43545. }
  43546. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43547. import { Vector4 } from "babylonjs/Maths/math.vector";
  43548. import { Mesh } from "babylonjs/Meshes/mesh";
  43549. /**
  43550. * Class containing static functions to help procedurally build meshes
  43551. */
  43552. export class TorusBuilder {
  43553. /**
  43554. * Creates a torus mesh
  43555. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43556. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43557. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43561. * @param name defines the name of the mesh
  43562. * @param options defines the options used to create the mesh
  43563. * @param scene defines the hosting scene
  43564. * @returns the torus mesh
  43565. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43566. */
  43567. static CreateTorus(name: string, options: {
  43568. diameter?: number;
  43569. thickness?: number;
  43570. tessellation?: number;
  43571. updatable?: boolean;
  43572. sideOrientation?: number;
  43573. frontUVs?: Vector4;
  43574. backUVs?: Vector4;
  43575. }, scene: any): Mesh;
  43576. }
  43577. }
  43578. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43579. import { Vector4 } from "babylonjs/Maths/math.vector";
  43580. import { Color4 } from "babylonjs/Maths/math.color";
  43581. import { Mesh } from "babylonjs/Meshes/mesh";
  43582. /**
  43583. * Class containing static functions to help procedurally build meshes
  43584. */
  43585. export class CylinderBuilder {
  43586. /**
  43587. * Creates a cylinder or a cone mesh
  43588. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43589. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43590. * * 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.
  43591. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43592. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43593. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43594. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43595. * * 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).
  43596. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43597. * * 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).
  43598. * * 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
  43599. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43600. * * 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
  43601. * * 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.
  43602. * * If `enclose` is false, a ring surface is one element.
  43603. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43604. * * 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
  43605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43608. * @param name defines the name of the mesh
  43609. * @param options defines the options used to create the mesh
  43610. * @param scene defines the hosting scene
  43611. * @returns the cylinder mesh
  43612. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43613. */
  43614. static CreateCylinder(name: string, options: {
  43615. height?: number;
  43616. diameterTop?: number;
  43617. diameterBottom?: number;
  43618. diameter?: number;
  43619. tessellation?: number;
  43620. subdivisions?: number;
  43621. arc?: number;
  43622. faceColors?: Color4[];
  43623. faceUV?: Vector4[];
  43624. updatable?: boolean;
  43625. hasRings?: boolean;
  43626. enclose?: boolean;
  43627. cap?: number;
  43628. sideOrientation?: number;
  43629. frontUVs?: Vector4;
  43630. backUVs?: Vector4;
  43631. }, scene: any): Mesh;
  43632. }
  43633. }
  43634. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43635. import { Nullable } from "babylonjs/types";
  43636. import { IDisposable } from "babylonjs/scene";
  43637. /**
  43638. * States of the webXR experience
  43639. */
  43640. export enum WebXRState {
  43641. /**
  43642. * Transitioning to being in XR mode
  43643. */
  43644. ENTERING_XR = 0,
  43645. /**
  43646. * Transitioning to non XR mode
  43647. */
  43648. EXITING_XR = 1,
  43649. /**
  43650. * In XR mode and presenting
  43651. */
  43652. IN_XR = 2,
  43653. /**
  43654. * Not entered XR mode
  43655. */
  43656. NOT_IN_XR = 3
  43657. }
  43658. /**
  43659. * Abstraction of the XR render target
  43660. */
  43661. export interface WebXRRenderTarget extends IDisposable {
  43662. /**
  43663. * xrpresent context of the canvas which can be used to display/mirror xr content
  43664. */
  43665. canvasContext: WebGLRenderingContext;
  43666. /**
  43667. * xr layer for the canvas
  43668. */
  43669. xrLayer: Nullable<XRWebGLLayer>;
  43670. /**
  43671. * Initializes the xr layer for the session
  43672. * @param xrSession xr session
  43673. * @returns a promise that will resolve once the XR Layer has been created
  43674. */
  43675. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43676. }
  43677. }
  43678. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43679. import { Nullable } from "babylonjs/types";
  43680. import { Observable } from "babylonjs/Misc/observable";
  43681. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43682. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43683. /**
  43684. * COnfiguration object for WebXR output canvas
  43685. */
  43686. export class WebXRManagedOutputCanvasOptions {
  43687. /**
  43688. * Options for this XR Layer output
  43689. */
  43690. canvasOptions: XRWebGLLayerOptions;
  43691. /**
  43692. * CSS styling for a newly created canvas (if not provided)
  43693. */
  43694. newCanvasCssStyle?: string;
  43695. /**
  43696. * Get the default values of the configuration object
  43697. * @returns default values of this configuration object
  43698. */
  43699. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43700. }
  43701. /**
  43702. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43703. */
  43704. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43705. private configuration;
  43706. private _engine;
  43707. private _canvas;
  43708. /**
  43709. * xrpresent context of the canvas which can be used to display/mirror xr content
  43710. */
  43711. canvasContext: WebGLRenderingContext;
  43712. /**
  43713. * xr layer for the canvas
  43714. */
  43715. xrLayer: Nullable<XRWebGLLayer>;
  43716. /**
  43717. * Initializes the xr layer for the session
  43718. * @param xrSession xr session
  43719. * @returns a promise that will resolve once the XR Layer has been created
  43720. */
  43721. initializeXRLayerAsync(xrSession: any): any;
  43722. /**
  43723. * Initializes the canvas to be added/removed upon entering/exiting xr
  43724. * @param engine the Babylon engine
  43725. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43726. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43727. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43728. */
  43729. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43730. /**
  43731. * Disposes of the object
  43732. */
  43733. dispose(): void;
  43734. private _setManagedOutputCanvas;
  43735. private _addCanvas;
  43736. private _removeCanvas;
  43737. }
  43738. }
  43739. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43740. import { Observable } from "babylonjs/Misc/observable";
  43741. import { Nullable } from "babylonjs/types";
  43742. import { IDisposable, Scene } from "babylonjs/scene";
  43743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43744. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43745. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43746. /**
  43747. * Manages an XRSession to work with Babylon's engine
  43748. * @see https://doc.babylonjs.com/how_to/webxr
  43749. */
  43750. export class WebXRSessionManager implements IDisposable {
  43751. /** The scene which the session should be created for */
  43752. scene: Scene;
  43753. /**
  43754. * Fires every time a new xrFrame arrives which can be used to update the camera
  43755. */
  43756. onXRFrameObservable: Observable<XRFrame>;
  43757. /**
  43758. * Fires when the xr session is ended either by the device or manually done
  43759. */
  43760. onXRSessionEnded: Observable<any>;
  43761. /**
  43762. * Fires when the xr session is ended either by the device or manually done
  43763. */
  43764. onXRSessionInit: Observable<XRSession>;
  43765. /**
  43766. * Underlying xr session
  43767. */
  43768. session: XRSession;
  43769. /**
  43770. * Type of reference space used when creating the session
  43771. */
  43772. referenceSpace: XRReferenceSpace;
  43773. /**
  43774. * Current XR frame
  43775. */
  43776. currentFrame: Nullable<XRFrame>;
  43777. /** WebXR timestamp updated every frame */
  43778. currentTimestamp: number;
  43779. private _xrNavigator;
  43780. private baseLayer;
  43781. private _rttProvider;
  43782. private _sessionEnded;
  43783. /**
  43784. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43785. * @param scene The scene which the session should be created for
  43786. */
  43787. constructor(
  43788. /** The scene which the session should be created for */
  43789. scene: Scene);
  43790. /**
  43791. * Initializes the manager
  43792. * After initialization enterXR can be called to start an XR session
  43793. * @returns Promise which resolves after it is initialized
  43794. */
  43795. initializeAsync(): Promise<void>;
  43796. /**
  43797. * Initializes an xr session
  43798. * @param xrSessionMode mode to initialize
  43799. * @param optionalFeatures defines optional values to pass to the session builder
  43800. * @returns a promise which will resolve once the session has been initialized
  43801. */
  43802. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43803. /**
  43804. * Sets the reference space on the xr session
  43805. * @param referenceSpace space to set
  43806. * @returns a promise that will resolve once the reference space has been set
  43807. */
  43808. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43809. /**
  43810. * Updates the render state of the session
  43811. * @param state state to set
  43812. * @returns a promise that resolves once the render state has been updated
  43813. */
  43814. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43815. /**
  43816. * Starts rendering to the xr layer
  43817. * @returns a promise that will resolve once rendering has started
  43818. */
  43819. startRenderingToXRAsync(): Promise<void>;
  43820. /**
  43821. * Gets the correct render target texture to be rendered this frame for this eye
  43822. * @param eye the eye for which to get the render target
  43823. * @returns the render target for the specified eye
  43824. */
  43825. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43826. /**
  43827. * Stops the xrSession and restores the renderloop
  43828. * @returns Promise which resolves after it exits XR
  43829. */
  43830. exitXRAsync(): Promise<void>;
  43831. /**
  43832. * Checks if a session would be supported for the creation options specified
  43833. * @param sessionMode session mode to check if supported eg. immersive-vr
  43834. * @returns true if supported
  43835. */
  43836. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43837. /**
  43838. * Creates a WebXRRenderTarget object for the XR session
  43839. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43840. * @param options optional options to provide when creating a new render target
  43841. * @returns a WebXR render target to which the session can render
  43842. */
  43843. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43844. /**
  43845. * @hidden
  43846. * Converts the render layer of xrSession to a render target
  43847. * @param session session to create render target for
  43848. * @param scene scene the new render target should be created for
  43849. * @param baseLayer the webgl layer to create the render target for
  43850. */
  43851. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43852. /**
  43853. * Disposes of the session manager
  43854. */
  43855. dispose(): void;
  43856. /**
  43857. * Gets a promise returning true when fullfiled if the given session mode is supported
  43858. * @param sessionMode defines the session to test
  43859. * @returns a promise
  43860. */
  43861. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43862. }
  43863. }
  43864. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43865. import { Scene } from "babylonjs/scene";
  43866. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43867. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43868. /**
  43869. * WebXR Camera which holds the views for the xrSession
  43870. * @see https://doc.babylonjs.com/how_to/webxr
  43871. */
  43872. export class WebXRCamera extends FreeCamera {
  43873. /**
  43874. * Is the camera in debug mode. Used when using an emulator
  43875. */
  43876. debugMode: boolean;
  43877. /**
  43878. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43879. * @param name the name of the camera
  43880. * @param scene the scene to add the camera to
  43881. */
  43882. constructor(name: string, scene: Scene);
  43883. private _updateNumberOfRigCameras;
  43884. /** @hidden */
  43885. _updateForDualEyeDebugging(): void;
  43886. /**
  43887. * Updates the cameras position from the current pose information of the XR session
  43888. * @param xrSessionManager the session containing pose information
  43889. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43890. */
  43891. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43892. }
  43893. }
  43894. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43895. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43896. import { IDisposable } from "babylonjs/scene";
  43897. /**
  43898. * Defining the interface required for a (webxr) feature
  43899. */
  43900. export interface IWebXRFeature extends IDisposable {
  43901. /**
  43902. * Attach the feature to the session
  43903. * Will usually be called by the features manager
  43904. *
  43905. * @returns true if successful.
  43906. */
  43907. attach(): boolean;
  43908. /**
  43909. * Detach the feature from the session
  43910. * Will usually be called by the features manager
  43911. *
  43912. * @returns true if successful.
  43913. */
  43914. detach(): boolean;
  43915. }
  43916. /**
  43917. * Defining the constructor of a feature. Used to register the modules.
  43918. */
  43919. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43920. /**
  43921. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43922. * It is mainly used in AR sessions.
  43923. *
  43924. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43925. */
  43926. export class WebXRFeaturesManager implements IDisposable {
  43927. private _xrSessionManager;
  43928. private static readonly _AvailableFeatures;
  43929. /**
  43930. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43931. * Mainly used internally.
  43932. *
  43933. * @param featureName the name of the feature to register
  43934. * @param constructorFunction the function used to construct the module
  43935. * @param version the (babylon) version of the module
  43936. * @param stable is that a stable version of this module
  43937. */
  43938. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43939. /**
  43940. * Returns a constructor of a specific feature.
  43941. *
  43942. * @param featureName the name of the feature to construct
  43943. * @param version the version of the feature to load
  43944. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43945. * @param options optional options provided to the module.
  43946. * @returns a function that, when called, will return a new instance of this feature
  43947. */
  43948. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43949. /**
  43950. * Return the latest unstable 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 GetLatestVersionOfFeature(featureName: string): number;
  43955. /**
  43956. * Return the latest stable version of this feature
  43957. * @param featureName the name of the feature to search
  43958. * @returns the version number. if not found will return -1
  43959. */
  43960. static GetStableVersionOfFeature(featureName: string): number;
  43961. /**
  43962. * Can be used to return the list of features currently registered
  43963. *
  43964. * @returns an Array of available features
  43965. */
  43966. static GetAvailableFeatures(): string[];
  43967. /**
  43968. * Gets the versions available for a specific feature
  43969. * @param featureName the name of the feature
  43970. * @returns an array with the available versions
  43971. */
  43972. static GetAvailableVersions(featureName: string): string[];
  43973. private _features;
  43974. /**
  43975. * constructs a new features manages.
  43976. *
  43977. * @param _xrSessionManager an instance of WebXRSessionManager
  43978. */
  43979. constructor(_xrSessionManager: WebXRSessionManager);
  43980. /**
  43981. * 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.
  43982. *
  43983. * @param featureName the name of the feature to load or the class of the feature
  43984. * @param version optional version to load. if not provided the latest version will be enabled
  43985. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43986. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43987. * @returns a new constructed feature or throws an error if feature not found.
  43988. */
  43989. enableFeature(featureName: string | {
  43990. Name: string;
  43991. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43992. /**
  43993. * Used to disable an already-enabled feature
  43994. * @param featureName the feature to disable
  43995. * @returns true if disable was successful
  43996. */
  43997. disableFeature(featureName: string | {
  43998. Name: string;
  43999. }): boolean;
  44000. /**
  44001. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44002. * Can be used during a session to start a feature
  44003. * @param featureName the name of feature to attach
  44004. */
  44005. attachFeature(featureName: string): void;
  44006. /**
  44007. * Can be used inside a session or when the session ends to detach a specific feature
  44008. * @param featureName the name of the feature to detach
  44009. */
  44010. detachFeature(featureName: string): void;
  44011. /**
  44012. * Get the list of enabled features
  44013. * @returns an array of enabled features
  44014. */
  44015. getEnabledFeatures(): string[];
  44016. /**
  44017. * get the implementation of an enabled feature.
  44018. * @param featureName the name of the feature to load
  44019. * @returns the feature class, if found
  44020. */
  44021. getEnabledFeature(featureName: string): IWebXRFeature;
  44022. /**
  44023. * dispose this features manager
  44024. */
  44025. dispose(): void;
  44026. }
  44027. }
  44028. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44029. import { Observable } from "babylonjs/Misc/observable";
  44030. import { IDisposable, Scene } from "babylonjs/scene";
  44031. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  44032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44033. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44034. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44035. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44036. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44037. /**
  44038. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44039. * @see https://doc.babylonjs.com/how_to/webxr
  44040. */
  44041. export class WebXRExperienceHelper implements IDisposable {
  44042. private scene;
  44043. /**
  44044. * 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
  44045. */
  44046. container: AbstractMesh;
  44047. /**
  44048. * Camera used to render xr content
  44049. */
  44050. camera: WebXRCamera;
  44051. /**
  44052. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44053. */
  44054. state: WebXRState;
  44055. private _setState;
  44056. private static _TmpVector;
  44057. /**
  44058. * Fires when the state of the experience helper has changed
  44059. */
  44060. onStateChangedObservable: Observable<WebXRState>;
  44061. /** Session manager used to keep track of xr session */
  44062. sessionManager: WebXRSessionManager;
  44063. /** A features manager for this xr session */
  44064. featuresManager: WebXRFeaturesManager;
  44065. private _nonVRCamera;
  44066. private _originalSceneAutoClear;
  44067. private _supported;
  44068. /**
  44069. * Creates the experience helper
  44070. * @param scene the scene to attach the experience helper to
  44071. * @returns a promise for the experience helper
  44072. */
  44073. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44074. /**
  44075. * Creates a WebXRExperienceHelper
  44076. * @param scene The scene the helper should be created in
  44077. */
  44078. private constructor();
  44079. /**
  44080. * Exits XR mode and returns the scene to its original state
  44081. * @returns promise that resolves after xr mode has exited
  44082. */
  44083. exitXRAsync(): Promise<void>;
  44084. /**
  44085. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44086. * @param sessionMode options for the XR session
  44087. * @param referenceSpaceType frame of reference of the XR session
  44088. * @param renderTarget the output canvas that will be used to enter XR mode
  44089. * @returns promise that resolves after xr mode has entered
  44090. */
  44091. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44092. /**
  44093. * Updates the global position of the camera by moving the camera's container
  44094. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  44095. * @param position The desired global position of the camera
  44096. */
  44097. setPositionOfCameraUsingContainer(position: Vector3): void;
  44098. /**
  44099. * Rotates the xr camera by rotating the camera's container around the camera's position
  44100. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  44101. * @param rotation the desired quaternion rotation to apply to the camera
  44102. */
  44103. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  44104. /**
  44105. * Disposes of the experience helper
  44106. */
  44107. dispose(): void;
  44108. }
  44109. }
  44110. declare module "babylonjs/Cameras/XR/webXRController" {
  44111. import { Nullable } from "babylonjs/types";
  44112. import { Observable } from "babylonjs/Misc/observable";
  44113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44114. import { Ray } from "babylonjs/Culling/ray";
  44115. import { Scene } from "babylonjs/scene";
  44116. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44117. /**
  44118. * Represents an XR input
  44119. */
  44120. export class WebXRController {
  44121. private scene;
  44122. /** The underlying input source for the controller */
  44123. inputSource: XRInputSource;
  44124. private parentContainer;
  44125. /**
  44126. * 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
  44127. */
  44128. grip?: AbstractMesh;
  44129. /**
  44130. * Pointer which can be used to select objects or attach a visible laser to
  44131. */
  44132. pointer: AbstractMesh;
  44133. private _gamepadMode;
  44134. /**
  44135. * If available, this is the gamepad object related to this controller.
  44136. * Using this object it is possible to get click events and trackpad changes of the
  44137. * webxr controller that is currently being used.
  44138. */
  44139. gamepadController?: WebVRController;
  44140. /**
  44141. * Event that fires when the controller is removed/disposed
  44142. */
  44143. onDisposeObservable: Observable<{}>;
  44144. private _tmpQuaternion;
  44145. private _tmpVector;
  44146. /**
  44147. * Creates the controller
  44148. * @see https://doc.babylonjs.com/how_to/webxr
  44149. * @param scene the scene which the controller should be associated to
  44150. * @param inputSource the underlying input source for the controller
  44151. * @param parentContainer parent that the controller meshes should be children of
  44152. */
  44153. constructor(scene: Scene,
  44154. /** The underlying input source for the controller */
  44155. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  44156. /**
  44157. * Updates the controller pose based on the given XRFrame
  44158. * @param xrFrame xr frame to update the pose with
  44159. * @param referenceSpace reference space to use
  44160. */
  44161. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44162. /**
  44163. * Gets a world space ray coming from the controller
  44164. * @param result the resulting ray
  44165. */
  44166. getWorldPointerRayToRef(result: Ray): void;
  44167. /**
  44168. * Get the scene associated with this controller
  44169. * @returns the scene object
  44170. */
  44171. getScene(): Scene;
  44172. /**
  44173. * Disposes of the object
  44174. */
  44175. dispose(): void;
  44176. }
  44177. }
  44178. declare module "babylonjs/Cameras/XR/webXRInput" {
  44179. import { Observable } from "babylonjs/Misc/observable";
  44180. import { IDisposable } from "babylonjs/scene";
  44181. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44182. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44183. /**
  44184. * XR input used to track XR inputs such as controllers/rays
  44185. */
  44186. export class WebXRInput implements IDisposable {
  44187. /**
  44188. * Base experience the input listens to
  44189. */
  44190. baseExperience: WebXRExperienceHelper;
  44191. /**
  44192. * XR controllers being tracked
  44193. */
  44194. controllers: Array<WebXRController>;
  44195. private _frameObserver;
  44196. private _stateObserver;
  44197. /**
  44198. * Event when a controller has been connected/added
  44199. */
  44200. onControllerAddedObservable: Observable<WebXRController>;
  44201. /**
  44202. * Event when a controller has been removed/disconnected
  44203. */
  44204. onControllerRemovedObservable: Observable<WebXRController>;
  44205. /**
  44206. * Initializes the WebXRInput
  44207. * @param baseExperience experience helper which the input should be created for
  44208. */
  44209. constructor(
  44210. /**
  44211. * Base experience the input listens to
  44212. */
  44213. baseExperience: WebXRExperienceHelper);
  44214. private _onInputSourcesChange;
  44215. private _addAndRemoveControllers;
  44216. /**
  44217. * Disposes of the object
  44218. */
  44219. dispose(): void;
  44220. }
  44221. }
  44222. declare module "babylonjs/Loading/sceneLoader" {
  44223. import { Observable } from "babylonjs/Misc/observable";
  44224. import { Nullable } from "babylonjs/types";
  44225. import { Scene } from "babylonjs/scene";
  44226. import { Engine } from "babylonjs/Engines/engine";
  44227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44228. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44229. import { AssetContainer } from "babylonjs/assetContainer";
  44230. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44231. import { Skeleton } from "babylonjs/Bones/skeleton";
  44232. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44233. import { WebRequest } from "babylonjs/Misc/webRequest";
  44234. /**
  44235. * Class used to represent data loading progression
  44236. */
  44237. export class SceneLoaderProgressEvent {
  44238. /** defines if data length to load can be evaluated */
  44239. readonly lengthComputable: boolean;
  44240. /** defines the loaded data length */
  44241. readonly loaded: number;
  44242. /** defines the data length to load */
  44243. readonly total: number;
  44244. /**
  44245. * Create a new progress event
  44246. * @param lengthComputable defines if data length to load can be evaluated
  44247. * @param loaded defines the loaded data length
  44248. * @param total defines the data length to load
  44249. */
  44250. constructor(
  44251. /** defines if data length to load can be evaluated */
  44252. lengthComputable: boolean,
  44253. /** defines the loaded data length */
  44254. loaded: number,
  44255. /** defines the data length to load */
  44256. total: number);
  44257. /**
  44258. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44259. * @param event defines the source event
  44260. * @returns a new SceneLoaderProgressEvent
  44261. */
  44262. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44263. }
  44264. /**
  44265. * Interface used by SceneLoader plugins to define supported file extensions
  44266. */
  44267. export interface ISceneLoaderPluginExtensions {
  44268. /**
  44269. * Defines the list of supported extensions
  44270. */
  44271. [extension: string]: {
  44272. isBinary: boolean;
  44273. };
  44274. }
  44275. /**
  44276. * Interface used by SceneLoader plugin factory
  44277. */
  44278. export interface ISceneLoaderPluginFactory {
  44279. /**
  44280. * Defines the name of the factory
  44281. */
  44282. name: string;
  44283. /**
  44284. * Function called to create a new plugin
  44285. * @return the new plugin
  44286. */
  44287. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44288. /**
  44289. * The callback that returns true if the data can be directly loaded.
  44290. * @param data string containing the file data
  44291. * @returns if the data can be loaded directly
  44292. */
  44293. canDirectLoad?(data: string): boolean;
  44294. }
  44295. /**
  44296. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44297. */
  44298. export interface ISceneLoaderPluginBase {
  44299. /**
  44300. * The friendly name of this plugin.
  44301. */
  44302. name: string;
  44303. /**
  44304. * The file extensions supported by this plugin.
  44305. */
  44306. extensions: string | ISceneLoaderPluginExtensions;
  44307. /**
  44308. * The callback called when loading from a url.
  44309. * @param scene scene loading this url
  44310. * @param url url to load
  44311. * @param onSuccess callback called when the file successfully loads
  44312. * @param onProgress callback called while file is loading (if the server supports this mode)
  44313. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44314. * @param onError callback called when the file fails to load
  44315. * @returns a file request object
  44316. */
  44317. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44318. /**
  44319. * The callback called when loading from a file object.
  44320. * @param scene scene loading this file
  44321. * @param file defines the file to load
  44322. * @param onSuccess defines the callback to call when data is loaded
  44323. * @param onProgress defines the callback to call during loading process
  44324. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44325. * @param onError defines the callback to call when an error occurs
  44326. * @returns a file request object
  44327. */
  44328. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44329. /**
  44330. * The callback that returns true if the data can be directly loaded.
  44331. * @param data string containing the file data
  44332. * @returns if the data can be loaded directly
  44333. */
  44334. canDirectLoad?(data: string): boolean;
  44335. /**
  44336. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44337. * @param scene scene loading this data
  44338. * @param data string containing the data
  44339. * @returns data to pass to the plugin
  44340. */
  44341. directLoad?(scene: Scene, data: string): any;
  44342. /**
  44343. * The callback that allows custom handling of the root url based on the response url.
  44344. * @param rootUrl the original root url
  44345. * @param responseURL the response url if available
  44346. * @returns the new root url
  44347. */
  44348. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44349. }
  44350. /**
  44351. * Interface used to define a SceneLoader plugin
  44352. */
  44353. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44354. /**
  44355. * Import meshes into a scene.
  44356. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44357. * @param scene The scene to import into
  44358. * @param data The data to import
  44359. * @param rootUrl The root url for scene and resources
  44360. * @param meshes The meshes array to import into
  44361. * @param particleSystems The particle systems array to import into
  44362. * @param skeletons The skeletons array to import into
  44363. * @param onError The callback when import fails
  44364. * @returns True if successful or false otherwise
  44365. */
  44366. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44367. /**
  44368. * Load into a scene.
  44369. * @param scene The scene to load into
  44370. * @param data The data to import
  44371. * @param rootUrl The root url for scene and resources
  44372. * @param onError The callback when import fails
  44373. * @returns True if successful or false otherwise
  44374. */
  44375. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44376. /**
  44377. * Load into an asset container.
  44378. * @param scene The scene to load into
  44379. * @param data The data to import
  44380. * @param rootUrl The root url for scene and resources
  44381. * @param onError The callback when import fails
  44382. * @returns The loaded asset container
  44383. */
  44384. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44385. }
  44386. /**
  44387. * Interface used to define an async SceneLoader plugin
  44388. */
  44389. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44390. /**
  44391. * Import meshes into a scene.
  44392. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44393. * @param scene The scene to import into
  44394. * @param data The data to import
  44395. * @param rootUrl The root url for scene and resources
  44396. * @param onProgress The callback when the load progresses
  44397. * @param fileName Defines the name of the file to load
  44398. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44399. */
  44400. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44401. meshes: AbstractMesh[];
  44402. particleSystems: IParticleSystem[];
  44403. skeletons: Skeleton[];
  44404. animationGroups: AnimationGroup[];
  44405. }>;
  44406. /**
  44407. * Load into a scene.
  44408. * @param scene The scene to load into
  44409. * @param data The data to import
  44410. * @param rootUrl The root url for scene and resources
  44411. * @param onProgress The callback when the load progresses
  44412. * @param fileName Defines the name of the file to load
  44413. * @returns Nothing
  44414. */
  44415. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44416. /**
  44417. * Load into an asset container.
  44418. * @param scene The scene to load into
  44419. * @param data The data to import
  44420. * @param rootUrl The root url for scene and resources
  44421. * @param onProgress The callback when the load progresses
  44422. * @param fileName Defines the name of the file to load
  44423. * @returns The loaded asset container
  44424. */
  44425. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44426. }
  44427. /**
  44428. * Mode that determines how to handle old animation groups before loading new ones.
  44429. */
  44430. export enum SceneLoaderAnimationGroupLoadingMode {
  44431. /**
  44432. * Reset all old animations to initial state then dispose them.
  44433. */
  44434. Clean = 0,
  44435. /**
  44436. * Stop all old animations.
  44437. */
  44438. Stop = 1,
  44439. /**
  44440. * Restart old animations from first frame.
  44441. */
  44442. Sync = 2,
  44443. /**
  44444. * Old animations remains untouched.
  44445. */
  44446. NoSync = 3
  44447. }
  44448. /**
  44449. * Class used to load scene from various file formats using registered plugins
  44450. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44451. */
  44452. export class SceneLoader {
  44453. /**
  44454. * No logging while loading
  44455. */
  44456. static readonly NO_LOGGING: number;
  44457. /**
  44458. * Minimal logging while loading
  44459. */
  44460. static readonly MINIMAL_LOGGING: number;
  44461. /**
  44462. * Summary logging while loading
  44463. */
  44464. static readonly SUMMARY_LOGGING: number;
  44465. /**
  44466. * Detailled logging while loading
  44467. */
  44468. static readonly DETAILED_LOGGING: number;
  44469. /**
  44470. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44471. */
  44472. static get ForceFullSceneLoadingForIncremental(): boolean;
  44473. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44474. /**
  44475. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44476. */
  44477. static get ShowLoadingScreen(): boolean;
  44478. static set ShowLoadingScreen(value: boolean);
  44479. /**
  44480. * Defines the current logging level (while loading the scene)
  44481. * @ignorenaming
  44482. */
  44483. static get loggingLevel(): number;
  44484. static set loggingLevel(value: number);
  44485. /**
  44486. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44487. */
  44488. static get CleanBoneMatrixWeights(): boolean;
  44489. static set CleanBoneMatrixWeights(value: boolean);
  44490. /**
  44491. * Event raised when a plugin is used to load a scene
  44492. */
  44493. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44494. private static _registeredPlugins;
  44495. private static _getDefaultPlugin;
  44496. private static _getPluginForExtension;
  44497. private static _getPluginForDirectLoad;
  44498. private static _getPluginForFilename;
  44499. private static _getDirectLoad;
  44500. private static _loadData;
  44501. private static _getFileInfo;
  44502. /**
  44503. * Gets a plugin that can load the given extension
  44504. * @param extension defines the extension to load
  44505. * @returns a plugin or null if none works
  44506. */
  44507. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44508. /**
  44509. * Gets a boolean indicating that the given extension can be loaded
  44510. * @param extension defines the extension to load
  44511. * @returns true if the extension is supported
  44512. */
  44513. static IsPluginForExtensionAvailable(extension: string): boolean;
  44514. /**
  44515. * Adds a new plugin to the list of registered plugins
  44516. * @param plugin defines the plugin to add
  44517. */
  44518. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44519. /**
  44520. * Import meshes into a scene
  44521. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44522. * @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)
  44523. * @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)
  44524. * @param scene the instance of BABYLON.Scene to append to
  44525. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44526. * @param onProgress a callback with a progress event for each file being loaded
  44527. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44528. * @param pluginExtension the extension used to determine the plugin
  44529. * @returns The loaded plugin
  44530. */
  44531. 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>;
  44532. /**
  44533. * Import meshes into a scene
  44534. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44535. * @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)
  44536. * @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)
  44537. * @param scene the instance of BABYLON.Scene to append to
  44538. * @param onProgress a callback with a progress event for each file being loaded
  44539. * @param pluginExtension the extension used to determine the plugin
  44540. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44541. */
  44542. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44543. meshes: AbstractMesh[];
  44544. particleSystems: IParticleSystem[];
  44545. skeletons: Skeleton[];
  44546. animationGroups: AnimationGroup[];
  44547. }>;
  44548. /**
  44549. * Load a scene
  44550. * @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)
  44551. * @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)
  44552. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44553. * @param onSuccess a callback with the scene when import succeeds
  44554. * @param onProgress a callback with a progress event for each file being loaded
  44555. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44556. * @param pluginExtension the extension used to determine the plugin
  44557. * @returns The loaded plugin
  44558. */
  44559. 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>;
  44560. /**
  44561. * Load a scene
  44562. * @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)
  44563. * @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)
  44564. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44565. * @param onProgress a callback with a progress event for each file being loaded
  44566. * @param pluginExtension the extension used to determine the plugin
  44567. * @returns The loaded scene
  44568. */
  44569. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44570. /**
  44571. * Append a scene
  44572. * @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)
  44573. * @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)
  44574. * @param scene is the instance of BABYLON.Scene to append to
  44575. * @param onSuccess a callback with the scene when import succeeds
  44576. * @param onProgress a callback with a progress event for each file being loaded
  44577. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44578. * @param pluginExtension the extension used to determine the plugin
  44579. * @returns The loaded plugin
  44580. */
  44581. 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>;
  44582. /**
  44583. * Append a scene
  44584. * @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)
  44585. * @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)
  44586. * @param scene is the instance of BABYLON.Scene to append to
  44587. * @param onProgress a callback with a progress event for each file being loaded
  44588. * @param pluginExtension the extension used to determine the plugin
  44589. * @returns The given scene
  44590. */
  44591. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44592. /**
  44593. * Load a scene into an asset container
  44594. * @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)
  44595. * @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)
  44596. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44597. * @param onSuccess a callback with the scene when import succeeds
  44598. * @param onProgress a callback with a progress event for each file being loaded
  44599. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44600. * @param pluginExtension the extension used to determine the plugin
  44601. * @returns The loaded plugin
  44602. */
  44603. 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>;
  44604. /**
  44605. * Load a scene into an asset container
  44606. * @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)
  44607. * @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)
  44608. * @param scene is the instance of Scene to append to
  44609. * @param onProgress a callback with a progress event for each file being loaded
  44610. * @param pluginExtension the extension used to determine the plugin
  44611. * @returns The loaded asset container
  44612. */
  44613. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44614. /**
  44615. * Import animations from a file into a scene
  44616. * @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)
  44617. * @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)
  44618. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44619. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44620. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44621. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44622. * @param onSuccess a callback with the scene when import succeeds
  44623. * @param onProgress a callback with a progress event for each file being loaded
  44624. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44625. */
  44626. 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;
  44627. /**
  44628. * Import animations from a file into a scene
  44629. * @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)
  44630. * @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)
  44631. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44632. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44633. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44634. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44635. * @param onSuccess a callback with the scene when import succeeds
  44636. * @param onProgress a callback with a progress event for each file being loaded
  44637. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44638. * @returns the updated scene with imported animations
  44639. */
  44640. 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>;
  44641. }
  44642. }
  44643. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44644. import { Scene } from "babylonjs/scene";
  44645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44646. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44647. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44648. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44649. /**
  44650. * Generic Controller
  44651. */
  44652. export class GenericController extends WebVRController {
  44653. /**
  44654. * Base Url for the controller model.
  44655. */
  44656. static readonly MODEL_BASE_URL: string;
  44657. /**
  44658. * File name for the controller model.
  44659. */
  44660. static readonly MODEL_FILENAME: string;
  44661. /**
  44662. * Creates a new GenericController from a gamepad
  44663. * @param vrGamepad the gamepad that the controller should be created from
  44664. */
  44665. constructor(vrGamepad: any);
  44666. /**
  44667. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44668. * @param scene scene in which to add meshes
  44669. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44670. */
  44671. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44672. /**
  44673. * Called once for each button that changed state since the last frame
  44674. * @param buttonIdx Which button index changed
  44675. * @param state New state of the button
  44676. * @param changes Which properties on the state changed since last frame
  44677. */
  44678. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44679. }
  44680. }
  44681. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44682. import { Observable } from "babylonjs/Misc/observable";
  44683. import { Scene } from "babylonjs/scene";
  44684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44685. import { Ray } from "babylonjs/Culling/ray";
  44686. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44687. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44688. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44689. /**
  44690. * Defines the WindowsMotionController object that the state of the windows motion controller
  44691. */
  44692. export class WindowsMotionController extends WebVRController {
  44693. /**
  44694. * The base url used to load the left and right controller models
  44695. */
  44696. static MODEL_BASE_URL: string;
  44697. /**
  44698. * The name of the left controller model file
  44699. */
  44700. static MODEL_LEFT_FILENAME: string;
  44701. /**
  44702. * The name of the right controller model file
  44703. */
  44704. static MODEL_RIGHT_FILENAME: string;
  44705. /**
  44706. * The controller name prefix for this controller type
  44707. */
  44708. static readonly GAMEPAD_ID_PREFIX: string;
  44709. /**
  44710. * The controller id pattern for this controller type
  44711. */
  44712. private static readonly GAMEPAD_ID_PATTERN;
  44713. private _loadedMeshInfo;
  44714. protected readonly _mapping: {
  44715. buttons: string[];
  44716. buttonMeshNames: {
  44717. 'trigger': string;
  44718. 'menu': string;
  44719. 'grip': string;
  44720. 'thumbstick': string;
  44721. 'trackpad': string;
  44722. };
  44723. buttonObservableNames: {
  44724. 'trigger': string;
  44725. 'menu': string;
  44726. 'grip': string;
  44727. 'thumbstick': string;
  44728. 'trackpad': string;
  44729. };
  44730. axisMeshNames: string[];
  44731. pointingPoseMeshName: string;
  44732. };
  44733. /**
  44734. * Fired when the trackpad on this controller is clicked
  44735. */
  44736. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44737. /**
  44738. * Fired when the trackpad on this controller is modified
  44739. */
  44740. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44741. /**
  44742. * The current x and y values of this controller's trackpad
  44743. */
  44744. trackpad: StickValues;
  44745. /**
  44746. * Creates a new WindowsMotionController from a gamepad
  44747. * @param vrGamepad the gamepad that the controller should be created from
  44748. */
  44749. constructor(vrGamepad: any);
  44750. /**
  44751. * Fired when the trigger on this controller is modified
  44752. */
  44753. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44754. /**
  44755. * Fired when the menu button on this controller is modified
  44756. */
  44757. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44758. /**
  44759. * Fired when the grip button on this controller is modified
  44760. */
  44761. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44762. /**
  44763. * Fired when the thumbstick button on this controller is modified
  44764. */
  44765. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44766. /**
  44767. * Fired when the touchpad button on this controller is modified
  44768. */
  44769. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44770. /**
  44771. * Fired when the touchpad values on this controller are modified
  44772. */
  44773. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  44774. protected _updateTrackpad(): void;
  44775. /**
  44776. * Called once per frame by the engine.
  44777. */
  44778. update(): void;
  44779. /**
  44780. * Called once for each button that changed state since the last frame
  44781. * @param buttonIdx Which button index changed
  44782. * @param state New state of the button
  44783. * @param changes Which properties on the state changed since last frame
  44784. */
  44785. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44786. /**
  44787. * Moves the buttons on the controller mesh based on their current state
  44788. * @param buttonName the name of the button to move
  44789. * @param buttonValue the value of the button which determines the buttons new position
  44790. */
  44791. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44792. /**
  44793. * Moves the axis on the controller mesh based on its current state
  44794. * @param axis the index of the axis
  44795. * @param axisValue the value of the axis which determines the meshes new position
  44796. * @hidden
  44797. */
  44798. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44799. /**
  44800. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44801. * @param scene scene in which to add meshes
  44802. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44803. */
  44804. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44805. /**
  44806. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44807. * can be transformed by button presses and axes values, based on this._mapping.
  44808. *
  44809. * @param scene scene in which the meshes exist
  44810. * @param meshes list of meshes that make up the controller model to process
  44811. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44812. */
  44813. private processModel;
  44814. private createMeshInfo;
  44815. /**
  44816. * Gets the ray of the controller in the direction the controller is pointing
  44817. * @param length the length the resulting ray should be
  44818. * @returns a ray in the direction the controller is pointing
  44819. */
  44820. getForwardRay(length?: number): Ray;
  44821. /**
  44822. * Disposes of the controller
  44823. */
  44824. dispose(): void;
  44825. }
  44826. /**
  44827. * This class represents a new windows motion controller in XR.
  44828. */
  44829. export class XRWindowsMotionController extends WindowsMotionController {
  44830. /**
  44831. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44832. */
  44833. protected readonly _mapping: {
  44834. buttons: string[];
  44835. buttonMeshNames: {
  44836. 'trigger': string;
  44837. 'menu': string;
  44838. 'grip': string;
  44839. 'thumbstick': string;
  44840. 'trackpad': string;
  44841. };
  44842. buttonObservableNames: {
  44843. 'trigger': string;
  44844. 'menu': string;
  44845. 'grip': string;
  44846. 'thumbstick': string;
  44847. 'trackpad': string;
  44848. };
  44849. axisMeshNames: string[];
  44850. pointingPoseMeshName: string;
  44851. };
  44852. /**
  44853. * Construct a new XR-Based windows motion controller
  44854. *
  44855. * @param gamepadInfo the gamepad object from the browser
  44856. */
  44857. constructor(gamepadInfo: any);
  44858. /**
  44859. * holds the thumbstick values (X,Y)
  44860. */
  44861. thumbstickValues: StickValues;
  44862. /**
  44863. * Fired when the thumbstick on this controller is clicked
  44864. */
  44865. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44866. /**
  44867. * Fired when the thumbstick on this controller is modified
  44868. */
  44869. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44870. /**
  44871. * Fired when the touchpad button on this controller is modified
  44872. */
  44873. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44874. /**
  44875. * Fired when the touchpad values on this controller are modified
  44876. */
  44877. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44878. /**
  44879. * Fired when the thumbstick button on this controller is modified
  44880. * here to prevent breaking changes
  44881. */
  44882. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44883. /**
  44884. * updating the thumbstick(!) and not the trackpad.
  44885. * This is named this way due to the difference between WebVR and XR and to avoid
  44886. * changing the parent class.
  44887. */
  44888. protected _updateTrackpad(): void;
  44889. /**
  44890. * Disposes the class with joy
  44891. */
  44892. dispose(): void;
  44893. }
  44894. }
  44895. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44896. import { Observable } from "babylonjs/Misc/observable";
  44897. import { Scene } from "babylonjs/scene";
  44898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44899. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44900. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44901. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44902. /**
  44903. * Oculus Touch Controller
  44904. */
  44905. export class OculusTouchController extends WebVRController {
  44906. /**
  44907. * Base Url for the controller model.
  44908. */
  44909. static MODEL_BASE_URL: string;
  44910. /**
  44911. * File name for the left controller model.
  44912. */
  44913. static MODEL_LEFT_FILENAME: string;
  44914. /**
  44915. * File name for the right controller model.
  44916. */
  44917. static MODEL_RIGHT_FILENAME: string;
  44918. /**
  44919. * Base Url for the Quest controller model.
  44920. */
  44921. static QUEST_MODEL_BASE_URL: string;
  44922. /**
  44923. * @hidden
  44924. * If the controllers are running on a device that needs the updated Quest controller models
  44925. */
  44926. static _IsQuest: boolean;
  44927. /**
  44928. * Fired when the secondary trigger on this controller is modified
  44929. */
  44930. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44931. /**
  44932. * Fired when the thumb rest on this controller is modified
  44933. */
  44934. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44935. /**
  44936. * Creates a new OculusTouchController from a gamepad
  44937. * @param vrGamepad the gamepad that the controller should be created from
  44938. */
  44939. constructor(vrGamepad: any);
  44940. /**
  44941. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44942. * @param scene scene in which to add meshes
  44943. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44944. */
  44945. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44946. /**
  44947. * Fired when the A button on this controller is modified
  44948. */
  44949. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44950. /**
  44951. * Fired when the B button on this controller is modified
  44952. */
  44953. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44954. /**
  44955. * Fired when the X button on this controller is modified
  44956. */
  44957. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44958. /**
  44959. * Fired when the Y button on this controller is modified
  44960. */
  44961. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44962. /**
  44963. * Called once for each button that changed state since the last frame
  44964. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44965. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44966. * 2) secondary trigger (same)
  44967. * 3) A (right) X (left), touch, pressed = value
  44968. * 4) B / Y
  44969. * 5) thumb rest
  44970. * @param buttonIdx Which button index changed
  44971. * @param state New state of the button
  44972. * @param changes Which properties on the state changed since last frame
  44973. */
  44974. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44975. }
  44976. }
  44977. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44978. import { Scene } from "babylonjs/scene";
  44979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44980. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44981. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44982. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44983. import { Observable } from "babylonjs/Misc/observable";
  44984. /**
  44985. * Vive Controller
  44986. */
  44987. export class ViveController extends WebVRController {
  44988. /**
  44989. * Base Url for the controller model.
  44990. */
  44991. static MODEL_BASE_URL: string;
  44992. /**
  44993. * File name for the controller model.
  44994. */
  44995. static MODEL_FILENAME: string;
  44996. /**
  44997. * Creates a new ViveController from a gamepad
  44998. * @param vrGamepad the gamepad that the controller should be created from
  44999. */
  45000. constructor(vrGamepad: any);
  45001. /**
  45002. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45003. * @param scene scene in which to add meshes
  45004. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45005. */
  45006. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45007. /**
  45008. * Fired when the left button on this controller is modified
  45009. */
  45010. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45011. /**
  45012. * Fired when the right button on this controller is modified
  45013. */
  45014. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45015. /**
  45016. * Fired when the menu button on this controller is modified
  45017. */
  45018. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45019. /**
  45020. * Called once for each button that changed state since the last frame
  45021. * Vive mapping:
  45022. * 0: touchpad
  45023. * 1: trigger
  45024. * 2: left AND right buttons
  45025. * 3: menu button
  45026. * @param buttonIdx Which button index changed
  45027. * @param state New state of the button
  45028. * @param changes Which properties on the state changed since last frame
  45029. */
  45030. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45031. }
  45032. }
  45033. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  45034. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45035. import { Observable } from "babylonjs/Misc/observable";
  45036. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45037. /**
  45038. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  45039. */
  45040. export class WebXRControllerModelLoader {
  45041. /**
  45042. * an observable that triggers when a new model (the mesh itself) was initialized.
  45043. * To know when the mesh was loaded use the controller's own modelLoaded() method
  45044. */
  45045. onControllerModelLoaded: Observable<WebXRController>;
  45046. /**
  45047. * Creates the WebXRControllerModelLoader
  45048. * @param input xr input that creates the controllers
  45049. */
  45050. constructor(input: WebXRInput);
  45051. }
  45052. }
  45053. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45054. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45055. /**
  45056. * Handles pointer input automatically for the pointer of XR controllers
  45057. */
  45058. export class WebXRControllerPointerSelection {
  45059. private static _idCounter;
  45060. private _tmpRay;
  45061. /**
  45062. * Creates a WebXRControllerPointerSelection
  45063. * @param input input manager to setup pointer selection
  45064. */
  45065. constructor(input: WebXRInput);
  45066. private _convertNormalToDirectionOfRay;
  45067. private _updatePointerDistance;
  45068. }
  45069. }
  45070. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45072. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45073. /**
  45074. * Enables teleportation
  45075. */
  45076. export class WebXRControllerTeleportation {
  45077. private _teleportationFillColor;
  45078. private _teleportationBorderColor;
  45079. private _tmpRay;
  45080. private _tmpVector;
  45081. /**
  45082. * when set to true (default) teleportation will wait for thumbstick changes.
  45083. * When set to false teleportation will be disabled.
  45084. *
  45085. * If set to false while teleporting results can be unexpected.
  45086. */
  45087. enabled: boolean;
  45088. /**
  45089. * Creates a WebXRControllerTeleportation
  45090. * @param input input manager to add teleportation to
  45091. * @param floorMeshes floormeshes which can be teleported to
  45092. */
  45093. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45094. }
  45095. }
  45096. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45097. import { Nullable } from "babylonjs/types";
  45098. import { Observable } from "babylonjs/Misc/observable";
  45099. import { IDisposable, Scene } from "babylonjs/scene";
  45100. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45101. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45102. /**
  45103. * Button which can be used to enter a different mode of XR
  45104. */
  45105. export class WebXREnterExitUIButton {
  45106. /** button element */
  45107. element: HTMLElement;
  45108. /** XR initialization options for the button */
  45109. sessionMode: XRSessionMode;
  45110. /** Reference space type */
  45111. referenceSpaceType: XRReferenceSpaceType;
  45112. /**
  45113. * Creates a WebXREnterExitUIButton
  45114. * @param element button element
  45115. * @param sessionMode XR initialization session mode
  45116. * @param referenceSpaceType the type of reference space to be used
  45117. */
  45118. constructor(
  45119. /** button element */
  45120. element: HTMLElement,
  45121. /** XR initialization options for the button */
  45122. sessionMode: XRSessionMode,
  45123. /** Reference space type */
  45124. referenceSpaceType: XRReferenceSpaceType);
  45125. /**
  45126. * Overwritable function which can be used to update the button's visuals when the state changes
  45127. * @param activeButton the current active button in the UI
  45128. */
  45129. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45130. }
  45131. /**
  45132. * Options to create the webXR UI
  45133. */
  45134. export class WebXREnterExitUIOptions {
  45135. /**
  45136. * Context to enter xr with
  45137. */
  45138. renderTarget?: Nullable<WebXRRenderTarget>;
  45139. /**
  45140. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45141. */
  45142. customButtons?: Array<WebXREnterExitUIButton>;
  45143. /**
  45144. * A session mode to use when creating the default button.
  45145. * Default is immersive-vr
  45146. */
  45147. sessionMode?: XRSessionMode;
  45148. /**
  45149. * A reference space type to use when creating the default button.
  45150. * Default is local-floor
  45151. */
  45152. referenceSpaceType?: XRReferenceSpaceType;
  45153. }
  45154. /**
  45155. * UI to allow the user to enter/exit XR mode
  45156. */
  45157. export class WebXREnterExitUI implements IDisposable {
  45158. private scene;
  45159. /** version of the options passed to this UI */
  45160. options: WebXREnterExitUIOptions;
  45161. private _overlay;
  45162. private _buttons;
  45163. private _activeButton;
  45164. /**
  45165. * Fired every time the active button is changed.
  45166. *
  45167. * When xr is entered via a button that launches xr that button will be the callback parameter
  45168. *
  45169. * When exiting xr the callback parameter will be null)
  45170. */
  45171. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45172. /**
  45173. * Creates UI to allow the user to enter/exit XR mode
  45174. * @param scene the scene to add the ui to
  45175. * @param helper the xr experience helper to enter/exit xr with
  45176. * @param options options to configure the UI
  45177. * @returns the created ui
  45178. */
  45179. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45180. /**
  45181. *
  45182. * @param scene babylon scene object to use
  45183. * @param options (read-only) version of the options passed to this UI
  45184. */
  45185. private constructor();
  45186. private _updateButtons;
  45187. /**
  45188. * Disposes of the object
  45189. */
  45190. dispose(): void;
  45191. }
  45192. }
  45193. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45194. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45195. import { Scene } from "babylonjs/scene";
  45196. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45197. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45198. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45199. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45200. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45201. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45203. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45204. /**
  45205. * Options for the default xr helper
  45206. */
  45207. export class WebXRDefaultExperienceOptions {
  45208. /**
  45209. * Floor meshes that should be used for teleporting
  45210. */
  45211. floorMeshes: Array<AbstractMesh>;
  45212. /**
  45213. * Enable or disable default UI to enter XR
  45214. */
  45215. disableDefaultUI?: boolean;
  45216. /**
  45217. * optional configuration for the output canvas
  45218. */
  45219. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45220. /**
  45221. * optional UI options. This can be used among other to change session mode and reference space type
  45222. */
  45223. uiOptions?: WebXREnterExitUIOptions;
  45224. }
  45225. /**
  45226. * Default experience which provides a similar setup to the previous webVRExperience
  45227. */
  45228. export class WebXRDefaultExperience {
  45229. /**
  45230. * Base experience
  45231. */
  45232. baseExperience: WebXRExperienceHelper;
  45233. /**
  45234. * Input experience extension
  45235. */
  45236. input: WebXRInput;
  45237. /**
  45238. * Loads the controller models
  45239. */
  45240. controllerModelLoader: WebXRControllerModelLoader;
  45241. /**
  45242. * Enables laser pointer and selection
  45243. */
  45244. pointerSelection: WebXRControllerPointerSelection;
  45245. /**
  45246. * Enables teleportation
  45247. */
  45248. teleportation: WebXRControllerTeleportation;
  45249. /**
  45250. * Enables ui for entering/exiting xr
  45251. */
  45252. enterExitUI: WebXREnterExitUI;
  45253. /**
  45254. * Default target xr should render to
  45255. */
  45256. renderTarget: WebXRRenderTarget;
  45257. /**
  45258. * Creates the default xr experience
  45259. * @param scene scene
  45260. * @param options options for basic configuration
  45261. * @returns resulting WebXRDefaultExperience
  45262. */
  45263. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45264. private constructor();
  45265. /**
  45266. * DIsposes of the experience helper
  45267. */
  45268. dispose(): void;
  45269. }
  45270. }
  45271. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45272. import { Observable } from "babylonjs/Misc/observable";
  45273. import { Nullable } from "babylonjs/types";
  45274. import { Camera } from "babylonjs/Cameras/camera";
  45275. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45276. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45277. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45278. import { Scene } from "babylonjs/scene";
  45279. import { Vector3 } from "babylonjs/Maths/math.vector";
  45280. import { Color3 } from "babylonjs/Maths/math.color";
  45281. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45283. import { Mesh } from "babylonjs/Meshes/mesh";
  45284. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45285. import { EasingFunction } from "babylonjs/Animations/easing";
  45286. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45287. import "babylonjs/Meshes/Builders/groundBuilder";
  45288. import "babylonjs/Meshes/Builders/torusBuilder";
  45289. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45290. import "babylonjs/Gamepads/gamepadSceneComponent";
  45291. import "babylonjs/Animations/animatable";
  45292. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45293. /**
  45294. * Options to modify the vr teleportation behavior.
  45295. */
  45296. export interface VRTeleportationOptions {
  45297. /**
  45298. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45299. */
  45300. floorMeshName?: string;
  45301. /**
  45302. * A list of meshes to be used as the teleportation floor. (default: empty)
  45303. */
  45304. floorMeshes?: Mesh[];
  45305. /**
  45306. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45307. */
  45308. teleportationMode?: number;
  45309. /**
  45310. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45311. */
  45312. teleportationTime?: number;
  45313. /**
  45314. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45315. */
  45316. teleportationSpeed?: number;
  45317. /**
  45318. * The easing function used in the animation or null for Linear. (default CircleEase)
  45319. */
  45320. easingFunction?: EasingFunction;
  45321. }
  45322. /**
  45323. * Options to modify the vr experience helper's behavior.
  45324. */
  45325. export interface VRExperienceHelperOptions extends WebVROptions {
  45326. /**
  45327. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45328. */
  45329. createDeviceOrientationCamera?: boolean;
  45330. /**
  45331. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45332. */
  45333. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45334. /**
  45335. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45336. */
  45337. laserToggle?: boolean;
  45338. /**
  45339. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45340. */
  45341. floorMeshes?: Mesh[];
  45342. /**
  45343. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45344. */
  45345. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45346. /**
  45347. * Defines if WebXR should be used instead of WebVR (if available)
  45348. */
  45349. useXR?: boolean;
  45350. }
  45351. /**
  45352. * Event containing information after VR has been entered
  45353. */
  45354. export class OnAfterEnteringVRObservableEvent {
  45355. /**
  45356. * If entering vr was successful
  45357. */
  45358. success: boolean;
  45359. }
  45360. /**
  45361. * Helps to quickly add VR support to an existing scene.
  45362. * See http://doc.babylonjs.com/how_to/webvr_helper
  45363. */
  45364. export class VRExperienceHelper {
  45365. /** Options to modify the vr experience helper's behavior. */
  45366. webVROptions: VRExperienceHelperOptions;
  45367. private _scene;
  45368. private _position;
  45369. private _btnVR;
  45370. private _btnVRDisplayed;
  45371. private _webVRsupported;
  45372. private _webVRready;
  45373. private _webVRrequesting;
  45374. private _webVRpresenting;
  45375. private _hasEnteredVR;
  45376. private _fullscreenVRpresenting;
  45377. private _inputElement;
  45378. private _webVRCamera;
  45379. private _vrDeviceOrientationCamera;
  45380. private _deviceOrientationCamera;
  45381. private _existingCamera;
  45382. private _onKeyDown;
  45383. private _onVrDisplayPresentChange;
  45384. private _onVRDisplayChanged;
  45385. private _onVRRequestPresentStart;
  45386. private _onVRRequestPresentComplete;
  45387. /**
  45388. * 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)
  45389. */
  45390. enableGazeEvenWhenNoPointerLock: boolean;
  45391. /**
  45392. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45393. */
  45394. exitVROnDoubleTap: boolean;
  45395. /**
  45396. * Observable raised right before entering VR.
  45397. */
  45398. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45399. /**
  45400. * Observable raised when entering VR has completed.
  45401. */
  45402. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45403. /**
  45404. * Observable raised when exiting VR.
  45405. */
  45406. onExitingVRObservable: Observable<VRExperienceHelper>;
  45407. /**
  45408. * Observable raised when controller mesh is loaded.
  45409. */
  45410. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45411. /** Return this.onEnteringVRObservable
  45412. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45413. */
  45414. get onEnteringVR(): Observable<VRExperienceHelper>;
  45415. /** Return this.onExitingVRObservable
  45416. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45417. */
  45418. get onExitingVR(): Observable<VRExperienceHelper>;
  45419. /** Return this.onControllerMeshLoadedObservable
  45420. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45421. */
  45422. get onControllerMeshLoaded(): Observable<WebVRController>;
  45423. private _rayLength;
  45424. private _useCustomVRButton;
  45425. private _teleportationRequested;
  45426. private _teleportActive;
  45427. private _floorMeshName;
  45428. private _floorMeshesCollection;
  45429. private _teleportationMode;
  45430. private _teleportationTime;
  45431. private _teleportationSpeed;
  45432. private _teleportationEasing;
  45433. private _rotationAllowed;
  45434. private _teleportBackwardsVector;
  45435. private _teleportationTarget;
  45436. private _isDefaultTeleportationTarget;
  45437. private _postProcessMove;
  45438. private _teleportationFillColor;
  45439. private _teleportationBorderColor;
  45440. private _rotationAngle;
  45441. private _haloCenter;
  45442. private _cameraGazer;
  45443. private _padSensibilityUp;
  45444. private _padSensibilityDown;
  45445. private _leftController;
  45446. private _rightController;
  45447. /**
  45448. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45449. */
  45450. onNewMeshSelected: Observable<AbstractMesh>;
  45451. /**
  45452. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45453. * This observable will provide the mesh and the controller used to select the mesh
  45454. */
  45455. onMeshSelectedWithController: Observable<{
  45456. mesh: AbstractMesh;
  45457. controller: WebVRController;
  45458. }>;
  45459. /**
  45460. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45461. */
  45462. onNewMeshPicked: Observable<PickingInfo>;
  45463. private _circleEase;
  45464. /**
  45465. * Observable raised before camera teleportation
  45466. */
  45467. onBeforeCameraTeleport: Observable<Vector3>;
  45468. /**
  45469. * Observable raised after camera teleportation
  45470. */
  45471. onAfterCameraTeleport: Observable<Vector3>;
  45472. /**
  45473. * Observable raised when current selected mesh gets unselected
  45474. */
  45475. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45476. private _raySelectionPredicate;
  45477. /**
  45478. * To be optionaly changed by user to define custom ray selection
  45479. */
  45480. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45481. /**
  45482. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45483. */
  45484. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45485. /**
  45486. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45487. */
  45488. teleportationEnabled: boolean;
  45489. private _defaultHeight;
  45490. private _teleportationInitialized;
  45491. private _interactionsEnabled;
  45492. private _interactionsRequested;
  45493. private _displayGaze;
  45494. private _displayLaserPointer;
  45495. /**
  45496. * The mesh used to display where the user is going to teleport.
  45497. */
  45498. get teleportationTarget(): Mesh;
  45499. /**
  45500. * Sets the mesh to be used to display where the user is going to teleport.
  45501. */
  45502. set teleportationTarget(value: Mesh);
  45503. /**
  45504. * 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
  45505. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45506. * See http://doc.babylonjs.com/resources/baking_transformations
  45507. */
  45508. get gazeTrackerMesh(): Mesh;
  45509. set gazeTrackerMesh(value: Mesh);
  45510. /**
  45511. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45512. */
  45513. updateGazeTrackerScale: boolean;
  45514. /**
  45515. * If the gaze trackers color should be updated when selecting meshes
  45516. */
  45517. updateGazeTrackerColor: boolean;
  45518. /**
  45519. * If the controller laser color should be updated when selecting meshes
  45520. */
  45521. updateControllerLaserColor: boolean;
  45522. /**
  45523. * The gaze tracking mesh corresponding to the left controller
  45524. */
  45525. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45526. /**
  45527. * The gaze tracking mesh corresponding to the right controller
  45528. */
  45529. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45530. /**
  45531. * If the ray of the gaze should be displayed.
  45532. */
  45533. get displayGaze(): boolean;
  45534. /**
  45535. * Sets if the ray of the gaze should be displayed.
  45536. */
  45537. set displayGaze(value: boolean);
  45538. /**
  45539. * If the ray of the LaserPointer should be displayed.
  45540. */
  45541. get displayLaserPointer(): boolean;
  45542. /**
  45543. * Sets if the ray of the LaserPointer should be displayed.
  45544. */
  45545. set displayLaserPointer(value: boolean);
  45546. /**
  45547. * The deviceOrientationCamera used as the camera when not in VR.
  45548. */
  45549. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45550. /**
  45551. * Based on the current WebVR support, returns the current VR camera used.
  45552. */
  45553. get currentVRCamera(): Nullable<Camera>;
  45554. /**
  45555. * The webVRCamera which is used when in VR.
  45556. */
  45557. get webVRCamera(): WebVRFreeCamera;
  45558. /**
  45559. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45560. */
  45561. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45562. /**
  45563. * The html button that is used to trigger entering into VR.
  45564. */
  45565. get vrButton(): Nullable<HTMLButtonElement>;
  45566. private get _teleportationRequestInitiated();
  45567. /**
  45568. * Defines wether or not Pointer lock should be requested when switching to
  45569. * full screen.
  45570. */
  45571. requestPointerLockOnFullScreen: boolean;
  45572. /**
  45573. * If asking to force XR, this will be populated with the default xr experience
  45574. */
  45575. xr: WebXRDefaultExperience;
  45576. /**
  45577. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45578. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45579. */
  45580. xrTestDone: boolean;
  45581. /**
  45582. * Instantiates a VRExperienceHelper.
  45583. * Helps to quickly add VR support to an existing scene.
  45584. * @param scene The scene the VRExperienceHelper belongs to.
  45585. * @param webVROptions Options to modify the vr experience helper's behavior.
  45586. */
  45587. constructor(scene: Scene,
  45588. /** Options to modify the vr experience helper's behavior. */
  45589. webVROptions?: VRExperienceHelperOptions);
  45590. private completeVRInit;
  45591. private _onDefaultMeshLoaded;
  45592. private _onResize;
  45593. private _onFullscreenChange;
  45594. /**
  45595. * Gets a value indicating if we are currently in VR mode.
  45596. */
  45597. get isInVRMode(): boolean;
  45598. private onVrDisplayPresentChange;
  45599. private onVRDisplayChanged;
  45600. private moveButtonToBottomRight;
  45601. private displayVRButton;
  45602. private updateButtonVisibility;
  45603. private _cachedAngularSensibility;
  45604. /**
  45605. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45606. * Otherwise, will use the fullscreen API.
  45607. */
  45608. enterVR(): void;
  45609. /**
  45610. * Attempt to exit VR, or fullscreen.
  45611. */
  45612. exitVR(): void;
  45613. /**
  45614. * The position of the vr experience helper.
  45615. */
  45616. get position(): Vector3;
  45617. /**
  45618. * Sets the position of the vr experience helper.
  45619. */
  45620. set position(value: Vector3);
  45621. /**
  45622. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45623. */
  45624. enableInteractions(): void;
  45625. private get _noControllerIsActive();
  45626. private beforeRender;
  45627. private _isTeleportationFloor;
  45628. /**
  45629. * Adds a floor mesh to be used for teleportation.
  45630. * @param floorMesh the mesh to be used for teleportation.
  45631. */
  45632. addFloorMesh(floorMesh: Mesh): void;
  45633. /**
  45634. * Removes a floor mesh from being used for teleportation.
  45635. * @param floorMesh the mesh to be removed.
  45636. */
  45637. removeFloorMesh(floorMesh: Mesh): void;
  45638. /**
  45639. * Enables interactions and teleportation using the VR controllers and gaze.
  45640. * @param vrTeleportationOptions options to modify teleportation behavior.
  45641. */
  45642. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45643. private _onNewGamepadConnected;
  45644. private _tryEnableInteractionOnController;
  45645. private _onNewGamepadDisconnected;
  45646. private _enableInteractionOnController;
  45647. private _checkTeleportWithRay;
  45648. private _checkRotate;
  45649. private _checkTeleportBackwards;
  45650. private _enableTeleportationOnController;
  45651. private _createTeleportationCircles;
  45652. private _displayTeleportationTarget;
  45653. private _hideTeleportationTarget;
  45654. private _rotateCamera;
  45655. private _moveTeleportationSelectorTo;
  45656. private _workingVector;
  45657. private _workingQuaternion;
  45658. private _workingMatrix;
  45659. /**
  45660. * Time Constant Teleportation Mode
  45661. */
  45662. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45663. /**
  45664. * Speed Constant Teleportation Mode
  45665. */
  45666. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45667. /**
  45668. * Teleports the users feet to the desired location
  45669. * @param location The location where the user's feet should be placed
  45670. */
  45671. teleportCamera(location: Vector3): void;
  45672. private _convertNormalToDirectionOfRay;
  45673. private _castRayAndSelectObject;
  45674. private _notifySelectedMeshUnselected;
  45675. /**
  45676. * Sets the color of the laser ray from the vr controllers.
  45677. * @param color new color for the ray.
  45678. */
  45679. changeLaserColor(color: Color3): void;
  45680. /**
  45681. * Sets the color of the ray from the vr headsets gaze.
  45682. * @param color new color for the ray.
  45683. */
  45684. changeGazeColor(color: Color3): void;
  45685. /**
  45686. * Exits VR and disposes of the vr experience helper
  45687. */
  45688. dispose(): void;
  45689. /**
  45690. * Gets the name of the VRExperienceHelper class
  45691. * @returns "VRExperienceHelper"
  45692. */
  45693. getClassName(): string;
  45694. }
  45695. }
  45696. declare module "babylonjs/Cameras/VR/index" {
  45697. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45698. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45699. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45700. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45701. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45702. export * from "babylonjs/Cameras/VR/webVRCamera";
  45703. }
  45704. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45705. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45706. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45707. import { Observable } from "babylonjs/Misc/observable";
  45708. import { Matrix } from "babylonjs/Maths/math.vector";
  45709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45710. /**
  45711. * Options used for hit testing
  45712. */
  45713. export interface IWebXRHitTestOptions {
  45714. /**
  45715. * Only test when user interacted with the scene. Default - hit test every frame
  45716. */
  45717. testOnPointerDownOnly?: boolean;
  45718. /**
  45719. * The node to use to transform the local results to world coordinates
  45720. */
  45721. worldParentNode?: TransformNode;
  45722. }
  45723. /**
  45724. * Interface defining the babylon result of raycasting/hit-test
  45725. */
  45726. export interface IWebXRHitResult {
  45727. /**
  45728. * The native hit test result
  45729. */
  45730. xrHitResult: XRHitResult;
  45731. /**
  45732. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45733. */
  45734. transformationMatrix: Matrix;
  45735. }
  45736. /**
  45737. * The currently-working hit-test module.
  45738. * Hit test (or raycasting) is used to interact with the real world.
  45739. * For further information read here - https://github.com/immersive-web/hit-test
  45740. */
  45741. export class WebXRHitTestLegacy implements IWebXRFeature {
  45742. private _xrSessionManager;
  45743. /**
  45744. * options to use when constructing this feature
  45745. */
  45746. readonly options: IWebXRHitTestOptions;
  45747. /**
  45748. * The module's name
  45749. */
  45750. static readonly Name: string;
  45751. /**
  45752. * The (Babylon) version of this module.
  45753. * This is an integer representing the implementation version.
  45754. * This number does not correspond to the webxr specs version
  45755. */
  45756. static readonly Version: number;
  45757. /**
  45758. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45759. * @param event the (select) event to use to select with
  45760. * @param referenceSpace the reference space to use for this hit test
  45761. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45762. */
  45763. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45764. /**
  45765. * execute a hit test with an XR Ray
  45766. *
  45767. * @param xrSession a native xrSession that will execute this hit test
  45768. * @param xrRay the ray (position and direction) to use for raycasting
  45769. * @param referenceSpace native XR reference space to use for the hit-test
  45770. * @param filter filter function that will filter the results
  45771. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45772. */
  45773. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45774. /**
  45775. * Triggered when new babylon (transformed) hit test results are available
  45776. */
  45777. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45778. /**
  45779. * Creates a new instance of the (legacy version) hit test feature
  45780. * @param _xrSessionManager an instance of WebXRSessionManager
  45781. * @param options options to use when constructing this feature
  45782. */
  45783. constructor(_xrSessionManager: WebXRSessionManager,
  45784. /**
  45785. * options to use when constructing this feature
  45786. */
  45787. options?: IWebXRHitTestOptions);
  45788. private _onSelectEnabled;
  45789. private _xrFrameObserver;
  45790. private _attached;
  45791. /**
  45792. * Populated with the last native XR Hit Results
  45793. */
  45794. lastNativeXRHitResults: XRHitResult[];
  45795. /**
  45796. * attach this feature
  45797. * Will usually be called by the features manager
  45798. *
  45799. * @returns true if successful.
  45800. */
  45801. attach(): boolean;
  45802. /**
  45803. * detach this feature.
  45804. * Will usually be called by the features manager
  45805. *
  45806. * @returns true if successful.
  45807. */
  45808. detach(): boolean;
  45809. private _onHitTestResults;
  45810. private _onSelect;
  45811. /**
  45812. * Dispose this feature and all of the resources attached
  45813. */
  45814. dispose(): void;
  45815. }
  45816. }
  45817. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  45818. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45819. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45820. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45821. import { Observable } from "babylonjs/Misc/observable";
  45822. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  45823. /**
  45824. * Options used in the plane detector module
  45825. */
  45826. export interface IWebXRPlaneDetectorOptions {
  45827. /**
  45828. * The node to use to transform the local results to world coordinates
  45829. */
  45830. worldParentNode?: TransformNode;
  45831. }
  45832. /**
  45833. * A babylon interface for a webxr plane.
  45834. * A Plane is actually a polygon, built from N points in space
  45835. */
  45836. export interface IWebXRPlane {
  45837. /**
  45838. * a babylon-assigned ID for this polygon
  45839. */
  45840. id: number;
  45841. /**
  45842. * the native xr-plane object
  45843. */
  45844. xrPlane: XRPlane;
  45845. /**
  45846. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45847. */
  45848. polygonDefinition: Array<Vector3>;
  45849. /**
  45850. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45851. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45852. */
  45853. transformationMatrix: Matrix;
  45854. }
  45855. /**
  45856. * The plane detector is used to detect planes in the real world when in AR
  45857. * For more information see https://github.com/immersive-web/real-world-geometry/
  45858. */
  45859. export class WebXRPlaneDetector implements IWebXRFeature {
  45860. private _xrSessionManager;
  45861. private _options;
  45862. /**
  45863. * The module's name
  45864. */
  45865. static readonly Name: string;
  45866. /**
  45867. * The (Babylon) version of this module.
  45868. * This is an integer representing the implementation version.
  45869. * This number does not correspond to the webxr specs version
  45870. */
  45871. static readonly Version: number;
  45872. /**
  45873. * Observers registered here will be executed when a new plane was added to the session
  45874. */
  45875. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45876. /**
  45877. * Observers registered here will be executed when a plane is no longer detected in the session
  45878. */
  45879. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45880. /**
  45881. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45882. * This can execute N times every frame
  45883. */
  45884. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45885. private _enabled;
  45886. private _attached;
  45887. private _detectedPlanes;
  45888. private _lastFrameDetected;
  45889. private _observerTracked;
  45890. /**
  45891. * construct a new Plane Detector
  45892. * @param _xrSessionManager an instance of xr Session manager
  45893. * @param _options configuration to use when constructing this feature
  45894. */
  45895. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45896. /**
  45897. * attach this feature
  45898. * Will usually be called by the features manager
  45899. *
  45900. * @returns true if successful.
  45901. */
  45902. attach(): boolean;
  45903. /**
  45904. * detach this feature.
  45905. * Will usually be called by the features manager
  45906. *
  45907. * @returns true if successful.
  45908. */
  45909. detach(): boolean;
  45910. /**
  45911. * Dispose this feature and all of the resources attached
  45912. */
  45913. dispose(): void;
  45914. private _updatePlaneWithXRPlane;
  45915. /**
  45916. * avoiding using Array.find for global support.
  45917. * @param xrPlane the plane to find in the array
  45918. */
  45919. private findIndexInPlaneArray;
  45920. }
  45921. }
  45922. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  45923. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45924. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45925. import { Observable } from "babylonjs/Misc/observable";
  45926. import { Matrix } from "babylonjs/Maths/math.vector";
  45927. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45928. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  45929. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  45930. /**
  45931. * Configuration options of the anchor system
  45932. */
  45933. export interface IWebXRAnchorSystemOptions {
  45934. /**
  45935. * a node that will be used to convert local to world coordinates
  45936. */
  45937. worldParentNode?: TransformNode;
  45938. /**
  45939. * should the anchor system use plane detection.
  45940. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45941. */
  45942. usePlaneDetection?: boolean;
  45943. /**
  45944. * Should a new anchor be added every time a select event is triggered
  45945. */
  45946. addAnchorOnSelect?: boolean;
  45947. }
  45948. /**
  45949. * A babylon container for an XR Anchor
  45950. */
  45951. export interface IWebXRAnchor {
  45952. /**
  45953. * A babylon-assigned ID for this anchor
  45954. */
  45955. id: number;
  45956. /**
  45957. * The native anchor object
  45958. */
  45959. xrAnchor: XRAnchor;
  45960. /**
  45961. * Transformation matrix to apply to an object attached to this anchor
  45962. */
  45963. transformationMatrix: Matrix;
  45964. }
  45965. /**
  45966. * An implementation of the anchor system of WebXR.
  45967. * Note that the current documented implementation is not available in any browser. Future implementations
  45968. * will use the frame to create an anchor and not the session or a detected plane
  45969. * For further information see https://github.com/immersive-web/anchors/
  45970. */
  45971. export class WebXRAnchorSystem implements IWebXRFeature {
  45972. private _xrSessionManager;
  45973. private _options;
  45974. /**
  45975. * The module's name
  45976. */
  45977. static readonly Name: string;
  45978. /**
  45979. * The (Babylon) version of this module.
  45980. * This is an integer representing the implementation version.
  45981. * This number does not correspond to the webxr specs version
  45982. */
  45983. static readonly Version: number;
  45984. /**
  45985. * Observers registered here will be executed when a new anchor was added to the session
  45986. */
  45987. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45988. /**
  45989. * Observers registered here will be executed when an existing anchor updates
  45990. * This can execute N times every frame
  45991. */
  45992. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45993. /**
  45994. * Observers registered here will be executed when an anchor was removed from the session
  45995. */
  45996. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45997. private _planeDetector;
  45998. private _hitTestModule;
  45999. private _enabled;
  46000. private _attached;
  46001. private _trackedAnchors;
  46002. private _lastFrameDetected;
  46003. private _observerTracked;
  46004. /**
  46005. * constructs a new anchor system
  46006. * @param _xrSessionManager an instance of WebXRSessionManager
  46007. * @param _options configuration object for this feature
  46008. */
  46009. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46010. /**
  46011. * set the plane detector to use in order to create anchors from frames
  46012. * @param planeDetector the plane-detector module to use
  46013. * @param enable enable plane-anchors. default is true
  46014. */
  46015. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46016. /**
  46017. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46018. * @param hitTestModule the hit-test module to use.
  46019. */
  46020. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46021. /**
  46022. * attach this feature
  46023. * Will usually be called by the features manager
  46024. *
  46025. * @returns true if successful.
  46026. */
  46027. attach(): boolean;
  46028. /**
  46029. * detach this feature.
  46030. * Will usually be called by the features manager
  46031. *
  46032. * @returns true if successful.
  46033. */
  46034. detach(): boolean;
  46035. /**
  46036. * Dispose this feature and all of the resources attached
  46037. */
  46038. dispose(): void;
  46039. private _onSelect;
  46040. /**
  46041. * Add anchor at a specific XR point.
  46042. *
  46043. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46044. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46045. * @returns a promise the fulfills when the anchor was created
  46046. */
  46047. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46048. private _updateAnchorWithXRFrame;
  46049. /**
  46050. * avoiding using Array.find for global support.
  46051. * @param xrAnchor the plane to find in the array
  46052. */
  46053. private _findIndexInAnchorArray;
  46054. }
  46055. }
  46056. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46057. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46058. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46060. import { Observable } from "babylonjs/Misc/observable";
  46061. /**
  46062. * Options interface for the background remover plugin
  46063. */
  46064. export interface IWebXRBackgroundRemoverOptions {
  46065. /**
  46066. * don't disable the environment helper
  46067. */
  46068. ignoreEnvironmentHelper?: boolean;
  46069. /**
  46070. * flags to configure the removal of the environment helper.
  46071. * If not set, the entire background will be removed. If set, flags should be set as well.
  46072. */
  46073. environmentHelperRemovalFlags?: {
  46074. /**
  46075. * Should the skybox be removed (default false)
  46076. */
  46077. skyBox?: boolean;
  46078. /**
  46079. * Should the ground be removed (default false)
  46080. */
  46081. ground?: boolean;
  46082. };
  46083. /**
  46084. * Further background meshes to disable when entering AR
  46085. */
  46086. backgroundMeshes?: AbstractMesh[];
  46087. }
  46088. /**
  46089. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46090. */
  46091. export class WebXRBackgroundRemover implements IWebXRFeature {
  46092. private _xrSessionManager;
  46093. /**
  46094. * read-only options to be used in this module
  46095. */
  46096. readonly options: IWebXRBackgroundRemoverOptions;
  46097. /**
  46098. * The module's name
  46099. */
  46100. static readonly Name: string;
  46101. /**
  46102. * The (Babylon) version of this module.
  46103. * This is an integer representing the implementation version.
  46104. * This number does not correspond to the webxr specs version
  46105. */
  46106. static readonly Version: number;
  46107. /**
  46108. * registered observers will be triggered when the background state changes
  46109. */
  46110. onBackgroundStateChangedObservable: Observable<boolean>;
  46111. /**
  46112. * constructs a new background remover module
  46113. * @param _xrSessionManager the session manager for this module
  46114. * @param options read-only options to be used in this module
  46115. */
  46116. constructor(_xrSessionManager: WebXRSessionManager,
  46117. /**
  46118. * read-only options to be used in this module
  46119. */
  46120. options?: IWebXRBackgroundRemoverOptions);
  46121. /**
  46122. * attach this feature
  46123. * Will usually be called by the features manager
  46124. *
  46125. * @returns true if successful.
  46126. */
  46127. attach(): boolean;
  46128. /**
  46129. * detach this feature.
  46130. * Will usually be called by the features manager
  46131. *
  46132. * @returns true if successful.
  46133. */
  46134. detach(): boolean;
  46135. private _setBackgroundState;
  46136. /**
  46137. * Dispose this feature and all of the resources attached
  46138. */
  46139. dispose(): void;
  46140. }
  46141. }
  46142. declare module "babylonjs/Cameras/XR/features/index" {
  46143. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46144. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46145. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46146. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46147. }
  46148. declare module "babylonjs/Cameras/XR/index" {
  46149. export * from "babylonjs/Cameras/XR/webXRCamera";
  46150. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46151. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46152. export * from "babylonjs/Cameras/XR/webXRInput";
  46153. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46154. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46155. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  46156. export * from "babylonjs/Cameras/XR/webXRController";
  46157. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46158. export * from "babylonjs/Cameras/XR/webXRTypes";
  46159. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46160. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46161. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46162. export * from "babylonjs/Cameras/XR/features/index";
  46163. }
  46164. declare module "babylonjs/Cameras/RigModes/index" {
  46165. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46166. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46167. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46168. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46169. }
  46170. declare module "babylonjs/Cameras/index" {
  46171. export * from "babylonjs/Cameras/Inputs/index";
  46172. export * from "babylonjs/Cameras/cameraInputsManager";
  46173. export * from "babylonjs/Cameras/camera";
  46174. export * from "babylonjs/Cameras/targetCamera";
  46175. export * from "babylonjs/Cameras/freeCamera";
  46176. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46177. export * from "babylonjs/Cameras/touchCamera";
  46178. export * from "babylonjs/Cameras/arcRotateCamera";
  46179. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46180. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46181. export * from "babylonjs/Cameras/flyCamera";
  46182. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46183. export * from "babylonjs/Cameras/followCamera";
  46184. export * from "babylonjs/Cameras/followCameraInputsManager";
  46185. export * from "babylonjs/Cameras/gamepadCamera";
  46186. export * from "babylonjs/Cameras/Stereoscopic/index";
  46187. export * from "babylonjs/Cameras/universalCamera";
  46188. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46189. export * from "babylonjs/Cameras/VR/index";
  46190. export * from "babylonjs/Cameras/XR/index";
  46191. export * from "babylonjs/Cameras/RigModes/index";
  46192. }
  46193. declare module "babylonjs/Collisions/index" {
  46194. export * from "babylonjs/Collisions/collider";
  46195. export * from "babylonjs/Collisions/collisionCoordinator";
  46196. export * from "babylonjs/Collisions/pickingInfo";
  46197. export * from "babylonjs/Collisions/intersectionInfo";
  46198. export * from "babylonjs/Collisions/meshCollisionData";
  46199. }
  46200. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46201. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46202. import { Vector3 } from "babylonjs/Maths/math.vector";
  46203. import { Ray } from "babylonjs/Culling/ray";
  46204. import { Plane } from "babylonjs/Maths/math.plane";
  46205. /**
  46206. * Contains an array of blocks representing the octree
  46207. */
  46208. export interface IOctreeContainer<T> {
  46209. /**
  46210. * Blocks within the octree
  46211. */
  46212. blocks: Array<OctreeBlock<T>>;
  46213. }
  46214. /**
  46215. * Class used to store a cell in an octree
  46216. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46217. */
  46218. export class OctreeBlock<T> {
  46219. /**
  46220. * Gets the content of the current block
  46221. */
  46222. entries: T[];
  46223. /**
  46224. * Gets the list of block children
  46225. */
  46226. blocks: Array<OctreeBlock<T>>;
  46227. private _depth;
  46228. private _maxDepth;
  46229. private _capacity;
  46230. private _minPoint;
  46231. private _maxPoint;
  46232. private _boundingVectors;
  46233. private _creationFunc;
  46234. /**
  46235. * Creates a new block
  46236. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46237. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46238. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46239. * @param depth defines the current depth of this block in the octree
  46240. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46241. * @param creationFunc defines a callback to call when an element is added to the block
  46242. */
  46243. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46244. /**
  46245. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46246. */
  46247. get capacity(): number;
  46248. /**
  46249. * Gets the minimum vector (in world space) of the block's bounding box
  46250. */
  46251. get minPoint(): Vector3;
  46252. /**
  46253. * Gets the maximum vector (in world space) of the block's bounding box
  46254. */
  46255. get maxPoint(): Vector3;
  46256. /**
  46257. * Add a new element to this block
  46258. * @param entry defines the element to add
  46259. */
  46260. addEntry(entry: T): void;
  46261. /**
  46262. * Remove an element from this block
  46263. * @param entry defines the element to remove
  46264. */
  46265. removeEntry(entry: T): void;
  46266. /**
  46267. * Add an array of elements to this block
  46268. * @param entries defines the array of elements to add
  46269. */
  46270. addEntries(entries: T[]): void;
  46271. /**
  46272. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46273. * @param frustumPlanes defines the frustum planes to test
  46274. * @param selection defines the array to store current content if selection is positive
  46275. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46276. */
  46277. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46278. /**
  46279. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46280. * @param sphereCenter defines the bounding sphere center
  46281. * @param sphereRadius defines the bounding sphere radius
  46282. * @param selection defines the array to store current content if selection is positive
  46283. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46284. */
  46285. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46286. /**
  46287. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46288. * @param ray defines the ray to test with
  46289. * @param selection defines the array to store current content if selection is positive
  46290. */
  46291. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46292. /**
  46293. * Subdivide the content into child blocks (this block will then be empty)
  46294. */
  46295. createInnerBlocks(): void;
  46296. /**
  46297. * @hidden
  46298. */
  46299. 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;
  46300. }
  46301. }
  46302. declare module "babylonjs/Culling/Octrees/octree" {
  46303. import { SmartArray } from "babylonjs/Misc/smartArray";
  46304. import { Vector3 } from "babylonjs/Maths/math.vector";
  46305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46307. import { Ray } from "babylonjs/Culling/ray";
  46308. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46309. import { Plane } from "babylonjs/Maths/math.plane";
  46310. /**
  46311. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46312. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46313. */
  46314. export class Octree<T> {
  46315. /** 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.) */
  46316. maxDepth: number;
  46317. /**
  46318. * Blocks within the octree containing objects
  46319. */
  46320. blocks: Array<OctreeBlock<T>>;
  46321. /**
  46322. * Content stored in the octree
  46323. */
  46324. dynamicContent: T[];
  46325. private _maxBlockCapacity;
  46326. private _selectionContent;
  46327. private _creationFunc;
  46328. /**
  46329. * Creates a octree
  46330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46331. * @param creationFunc function to be used to instatiate the octree
  46332. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46333. * @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.)
  46334. */
  46335. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46336. /** 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.) */
  46337. maxDepth?: number);
  46338. /**
  46339. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46340. * @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);
  46341. * @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);
  46342. * @param entries meshes to be added to the octree blocks
  46343. */
  46344. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46345. /**
  46346. * Adds a mesh to the octree
  46347. * @param entry Mesh to add to the octree
  46348. */
  46349. addMesh(entry: T): void;
  46350. /**
  46351. * Remove an element from the octree
  46352. * @param entry defines the element to remove
  46353. */
  46354. removeMesh(entry: T): void;
  46355. /**
  46356. * Selects an array of meshes within the frustum
  46357. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46358. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46359. * @returns array of meshes within the frustum
  46360. */
  46361. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46362. /**
  46363. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46364. * @param sphereCenter defines the bounding sphere center
  46365. * @param sphereRadius defines the bounding sphere radius
  46366. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46367. * @returns an array of objects that intersect the sphere
  46368. */
  46369. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46370. /**
  46371. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46372. * @param ray defines the ray to test with
  46373. * @returns array of intersected objects
  46374. */
  46375. intersectsRay(ray: Ray): SmartArray<T>;
  46376. /**
  46377. * Adds a mesh into the octree block if it intersects the block
  46378. */
  46379. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46380. /**
  46381. * Adds a submesh into the octree block if it intersects the block
  46382. */
  46383. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46384. }
  46385. }
  46386. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46387. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46388. import { Scene } from "babylonjs/scene";
  46389. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46391. import { Ray } from "babylonjs/Culling/ray";
  46392. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46393. import { Collider } from "babylonjs/Collisions/collider";
  46394. module "babylonjs/scene" {
  46395. interface Scene {
  46396. /**
  46397. * @hidden
  46398. * Backing Filed
  46399. */
  46400. _selectionOctree: Octree<AbstractMesh>;
  46401. /**
  46402. * Gets the octree used to boost mesh selection (picking)
  46403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46404. */
  46405. selectionOctree: Octree<AbstractMesh>;
  46406. /**
  46407. * Creates or updates the octree used to boost selection (picking)
  46408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46409. * @param maxCapacity defines the maximum capacity per leaf
  46410. * @param maxDepth defines the maximum depth of the octree
  46411. * @returns an octree of AbstractMesh
  46412. */
  46413. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46414. }
  46415. }
  46416. module "babylonjs/Meshes/abstractMesh" {
  46417. interface AbstractMesh {
  46418. /**
  46419. * @hidden
  46420. * Backing Field
  46421. */
  46422. _submeshesOctree: Octree<SubMesh>;
  46423. /**
  46424. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46425. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46426. * @param maxCapacity defines the maximum size of each block (64 by default)
  46427. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46428. * @returns the new octree
  46429. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46431. */
  46432. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46433. }
  46434. }
  46435. /**
  46436. * Defines the octree scene component responsible to manage any octrees
  46437. * in a given scene.
  46438. */
  46439. export class OctreeSceneComponent {
  46440. /**
  46441. * The component name help to identify the component in the list of scene components.
  46442. */
  46443. readonly name: string;
  46444. /**
  46445. * The scene the component belongs to.
  46446. */
  46447. scene: Scene;
  46448. /**
  46449. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46450. */
  46451. readonly checksIsEnabled: boolean;
  46452. /**
  46453. * Creates a new instance of the component for the given scene
  46454. * @param scene Defines the scene to register the component in
  46455. */
  46456. constructor(scene: Scene);
  46457. /**
  46458. * Registers the component in a given scene
  46459. */
  46460. register(): void;
  46461. /**
  46462. * Return the list of active meshes
  46463. * @returns the list of active meshes
  46464. */
  46465. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46466. /**
  46467. * Return the list of active sub meshes
  46468. * @param mesh The mesh to get the candidates sub meshes from
  46469. * @returns the list of active sub meshes
  46470. */
  46471. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46472. private _tempRay;
  46473. /**
  46474. * Return the list of sub meshes intersecting with a given local ray
  46475. * @param mesh defines the mesh to find the submesh for
  46476. * @param localRay defines the ray in local space
  46477. * @returns the list of intersecting sub meshes
  46478. */
  46479. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46480. /**
  46481. * Return the list of sub meshes colliding with a collider
  46482. * @param mesh defines the mesh to find the submesh for
  46483. * @param collider defines the collider to evaluate the collision against
  46484. * @returns the list of colliding sub meshes
  46485. */
  46486. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46487. /**
  46488. * Rebuilds the elements related to this component in case of
  46489. * context lost for instance.
  46490. */
  46491. rebuild(): void;
  46492. /**
  46493. * Disposes the component and the associated ressources.
  46494. */
  46495. dispose(): void;
  46496. }
  46497. }
  46498. declare module "babylonjs/Culling/Octrees/index" {
  46499. export * from "babylonjs/Culling/Octrees/octree";
  46500. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46501. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46502. }
  46503. declare module "babylonjs/Culling/index" {
  46504. export * from "babylonjs/Culling/boundingBox";
  46505. export * from "babylonjs/Culling/boundingInfo";
  46506. export * from "babylonjs/Culling/boundingSphere";
  46507. export * from "babylonjs/Culling/Octrees/index";
  46508. export * from "babylonjs/Culling/ray";
  46509. }
  46510. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46511. import { IDisposable, Scene } from "babylonjs/scene";
  46512. import { Nullable } from "babylonjs/types";
  46513. import { Observable } from "babylonjs/Misc/observable";
  46514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46515. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46516. import { Camera } from "babylonjs/Cameras/camera";
  46517. /**
  46518. * Renders a layer on top of an existing scene
  46519. */
  46520. export class UtilityLayerRenderer implements IDisposable {
  46521. /** the original scene that will be rendered on top of */
  46522. originalScene: Scene;
  46523. private _pointerCaptures;
  46524. private _lastPointerEvents;
  46525. private static _DefaultUtilityLayer;
  46526. private static _DefaultKeepDepthUtilityLayer;
  46527. private _sharedGizmoLight;
  46528. private _renderCamera;
  46529. /**
  46530. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46531. * @returns the camera that is used when rendering the utility layer
  46532. */
  46533. getRenderCamera(): Nullable<Camera>;
  46534. /**
  46535. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46536. * @param cam the camera that should be used when rendering the utility layer
  46537. */
  46538. setRenderCamera(cam: Nullable<Camera>): void;
  46539. /**
  46540. * @hidden
  46541. * Light which used by gizmos to get light shading
  46542. */
  46543. _getSharedGizmoLight(): HemisphericLight;
  46544. /**
  46545. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46546. */
  46547. pickUtilitySceneFirst: boolean;
  46548. /**
  46549. * 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)
  46550. */
  46551. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46552. /**
  46553. * 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)
  46554. */
  46555. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46556. /**
  46557. * The scene that is rendered on top of the original scene
  46558. */
  46559. utilityLayerScene: Scene;
  46560. /**
  46561. * If the utility layer should automatically be rendered on top of existing scene
  46562. */
  46563. shouldRender: boolean;
  46564. /**
  46565. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46566. */
  46567. onlyCheckPointerDownEvents: boolean;
  46568. /**
  46569. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46570. */
  46571. processAllEvents: boolean;
  46572. /**
  46573. * Observable raised when the pointer move from the utility layer scene to the main scene
  46574. */
  46575. onPointerOutObservable: Observable<number>;
  46576. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46577. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46578. private _afterRenderObserver;
  46579. private _sceneDisposeObserver;
  46580. private _originalPointerObserver;
  46581. /**
  46582. * Instantiates a UtilityLayerRenderer
  46583. * @param originalScene the original scene that will be rendered on top of
  46584. * @param handleEvents boolean indicating if the utility layer should handle events
  46585. */
  46586. constructor(
  46587. /** the original scene that will be rendered on top of */
  46588. originalScene: Scene, handleEvents?: boolean);
  46589. private _notifyObservers;
  46590. /**
  46591. * Renders the utility layers scene on top of the original scene
  46592. */
  46593. render(): void;
  46594. /**
  46595. * Disposes of the renderer
  46596. */
  46597. dispose(): void;
  46598. private _updateCamera;
  46599. }
  46600. }
  46601. declare module "babylonjs/Gizmos/gizmo" {
  46602. import { Nullable } from "babylonjs/types";
  46603. import { IDisposable } from "babylonjs/scene";
  46604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46605. import { Mesh } from "babylonjs/Meshes/mesh";
  46606. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46607. /**
  46608. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46609. */
  46610. export class Gizmo implements IDisposable {
  46611. /** The utility layer the gizmo will be added to */
  46612. gizmoLayer: UtilityLayerRenderer;
  46613. /**
  46614. * The root mesh of the gizmo
  46615. */
  46616. _rootMesh: Mesh;
  46617. private _attachedMesh;
  46618. /**
  46619. * Ratio for the scale of the gizmo (Default: 1)
  46620. */
  46621. scaleRatio: number;
  46622. /**
  46623. * If a custom mesh has been set (Default: false)
  46624. */
  46625. protected _customMeshSet: boolean;
  46626. /**
  46627. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46628. * * When set, interactions will be enabled
  46629. */
  46630. get attachedMesh(): Nullable<AbstractMesh>;
  46631. set attachedMesh(value: Nullable<AbstractMesh>);
  46632. /**
  46633. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46634. * @param mesh The mesh to replace the default mesh of the gizmo
  46635. */
  46636. setCustomMesh(mesh: Mesh): void;
  46637. /**
  46638. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46639. */
  46640. updateGizmoRotationToMatchAttachedMesh: boolean;
  46641. /**
  46642. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46643. */
  46644. updateGizmoPositionToMatchAttachedMesh: boolean;
  46645. /**
  46646. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46647. */
  46648. updateScale: boolean;
  46649. protected _interactionsEnabled: boolean;
  46650. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46651. private _beforeRenderObserver;
  46652. private _tempVector;
  46653. /**
  46654. * Creates a gizmo
  46655. * @param gizmoLayer The utility layer the gizmo will be added to
  46656. */
  46657. constructor(
  46658. /** The utility layer the gizmo will be added to */
  46659. gizmoLayer?: UtilityLayerRenderer);
  46660. /**
  46661. * Updates the gizmo to match the attached mesh's position/rotation
  46662. */
  46663. protected _update(): void;
  46664. /**
  46665. * Disposes of the gizmo
  46666. */
  46667. dispose(): void;
  46668. }
  46669. }
  46670. declare module "babylonjs/Gizmos/planeDragGizmo" {
  46671. import { Observable } from "babylonjs/Misc/observable";
  46672. import { Nullable } from "babylonjs/types";
  46673. import { Vector3 } from "babylonjs/Maths/math.vector";
  46674. import { Color3 } from "babylonjs/Maths/math.color";
  46675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46677. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46678. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46679. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46680. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46681. import { Scene } from "babylonjs/scene";
  46682. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46683. /**
  46684. * Single plane drag gizmo
  46685. */
  46686. export class PlaneDragGizmo extends Gizmo {
  46687. /**
  46688. * Drag behavior responsible for the gizmos dragging interactions
  46689. */
  46690. dragBehavior: PointerDragBehavior;
  46691. private _pointerObserver;
  46692. /**
  46693. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46694. */
  46695. snapDistance: number;
  46696. /**
  46697. * Event that fires each time the gizmo snaps to a new location.
  46698. * * snapDistance is the the change in distance
  46699. */
  46700. onSnapObservable: Observable<{
  46701. snapDistance: number;
  46702. }>;
  46703. private _plane;
  46704. private _coloredMaterial;
  46705. private _hoverMaterial;
  46706. private _isEnabled;
  46707. private _parent;
  46708. /** @hidden */
  46709. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46710. /** @hidden */
  46711. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46712. /**
  46713. * Creates a PlaneDragGizmo
  46714. * @param gizmoLayer The utility layer the gizmo will be added to
  46715. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46716. * @param color The color of the gizmo
  46717. */
  46718. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46719. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46720. /**
  46721. * If the gizmo is enabled
  46722. */
  46723. set isEnabled(value: boolean);
  46724. get isEnabled(): boolean;
  46725. /**
  46726. * Disposes of the gizmo
  46727. */
  46728. dispose(): void;
  46729. }
  46730. }
  46731. declare module "babylonjs/Gizmos/positionGizmo" {
  46732. import { Observable } from "babylonjs/Misc/observable";
  46733. import { Nullable } from "babylonjs/types";
  46734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46735. import { Mesh } from "babylonjs/Meshes/mesh";
  46736. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46737. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  46738. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  46739. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46740. /**
  46741. * Gizmo that enables dragging a mesh along 3 axis
  46742. */
  46743. export class PositionGizmo extends Gizmo {
  46744. /**
  46745. * Internal gizmo used for interactions on the x axis
  46746. */
  46747. xGizmo: AxisDragGizmo;
  46748. /**
  46749. * Internal gizmo used for interactions on the y axis
  46750. */
  46751. yGizmo: AxisDragGizmo;
  46752. /**
  46753. * Internal gizmo used for interactions on the z axis
  46754. */
  46755. zGizmo: AxisDragGizmo;
  46756. /**
  46757. * Internal gizmo used for interactions on the yz plane
  46758. */
  46759. xPlaneGizmo: PlaneDragGizmo;
  46760. /**
  46761. * Internal gizmo used for interactions on the xz plane
  46762. */
  46763. yPlaneGizmo: PlaneDragGizmo;
  46764. /**
  46765. * Internal gizmo used for interactions on the xy plane
  46766. */
  46767. zPlaneGizmo: PlaneDragGizmo;
  46768. /**
  46769. * private variables
  46770. */
  46771. private _meshAttached;
  46772. private _updateGizmoRotationToMatchAttachedMesh;
  46773. private _snapDistance;
  46774. private _scaleRatio;
  46775. /** Fires an event when any of it's sub gizmos are dragged */
  46776. onDragStartObservable: Observable<unknown>;
  46777. /** Fires an event when any of it's sub gizmos are released from dragging */
  46778. onDragEndObservable: Observable<unknown>;
  46779. /**
  46780. * If set to true, planar drag is enabled
  46781. */
  46782. private _planarGizmoEnabled;
  46783. get attachedMesh(): Nullable<AbstractMesh>;
  46784. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46785. /**
  46786. * Creates a PositionGizmo
  46787. * @param gizmoLayer The utility layer the gizmo will be added to
  46788. */
  46789. constructor(gizmoLayer?: UtilityLayerRenderer);
  46790. /**
  46791. * If the planar drag gizmo is enabled
  46792. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46793. */
  46794. set planarGizmoEnabled(value: boolean);
  46795. get planarGizmoEnabled(): boolean;
  46796. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46797. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46798. /**
  46799. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46800. */
  46801. set snapDistance(value: number);
  46802. get snapDistance(): number;
  46803. /**
  46804. * Ratio for the scale of the gizmo (Default: 1)
  46805. */
  46806. set scaleRatio(value: number);
  46807. get scaleRatio(): number;
  46808. /**
  46809. * Disposes of the gizmo
  46810. */
  46811. dispose(): void;
  46812. /**
  46813. * CustomMeshes are not supported by this gizmo
  46814. * @param mesh The mesh to replace the default mesh of the gizmo
  46815. */
  46816. setCustomMesh(mesh: Mesh): void;
  46817. }
  46818. }
  46819. declare module "babylonjs/Gizmos/axisDragGizmo" {
  46820. import { Observable } from "babylonjs/Misc/observable";
  46821. import { Nullable } from "babylonjs/types";
  46822. import { Vector3 } from "babylonjs/Maths/math.vector";
  46823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46825. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46826. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46827. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46828. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46829. import { Scene } from "babylonjs/scene";
  46830. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46831. import { Color3 } from "babylonjs/Maths/math.color";
  46832. /**
  46833. * Single axis drag gizmo
  46834. */
  46835. export class AxisDragGizmo extends Gizmo {
  46836. /**
  46837. * Drag behavior responsible for the gizmos dragging interactions
  46838. */
  46839. dragBehavior: PointerDragBehavior;
  46840. private _pointerObserver;
  46841. /**
  46842. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46843. */
  46844. snapDistance: number;
  46845. /**
  46846. * Event that fires each time the gizmo snaps to a new location.
  46847. * * snapDistance is the the change in distance
  46848. */
  46849. onSnapObservable: Observable<{
  46850. snapDistance: number;
  46851. }>;
  46852. private _isEnabled;
  46853. private _parent;
  46854. private _arrow;
  46855. private _coloredMaterial;
  46856. private _hoverMaterial;
  46857. /** @hidden */
  46858. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46859. /** @hidden */
  46860. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46861. /**
  46862. * Creates an AxisDragGizmo
  46863. * @param gizmoLayer The utility layer the gizmo will be added to
  46864. * @param dragAxis The axis which the gizmo will be able to drag on
  46865. * @param color The color of the gizmo
  46866. */
  46867. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46868. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46869. /**
  46870. * If the gizmo is enabled
  46871. */
  46872. set isEnabled(value: boolean);
  46873. get isEnabled(): boolean;
  46874. /**
  46875. * Disposes of the gizmo
  46876. */
  46877. dispose(): void;
  46878. }
  46879. }
  46880. declare module "babylonjs/Debug/axesViewer" {
  46881. import { Vector3 } from "babylonjs/Maths/math.vector";
  46882. import { Nullable } from "babylonjs/types";
  46883. import { Scene } from "babylonjs/scene";
  46884. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46885. /**
  46886. * The Axes viewer will show 3 axes in a specific point in space
  46887. */
  46888. export class AxesViewer {
  46889. private _xAxis;
  46890. private _yAxis;
  46891. private _zAxis;
  46892. private _scaleLinesFactor;
  46893. private _instanced;
  46894. /**
  46895. * Gets the hosting scene
  46896. */
  46897. scene: Scene;
  46898. /**
  46899. * Gets or sets a number used to scale line length
  46900. */
  46901. scaleLines: number;
  46902. /** Gets the node hierarchy used to render x-axis */
  46903. get xAxis(): TransformNode;
  46904. /** Gets the node hierarchy used to render y-axis */
  46905. get yAxis(): TransformNode;
  46906. /** Gets the node hierarchy used to render z-axis */
  46907. get zAxis(): TransformNode;
  46908. /**
  46909. * Creates a new AxesViewer
  46910. * @param scene defines the hosting scene
  46911. * @param scaleLines defines a number used to scale line length (1 by default)
  46912. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46913. * @param xAxis defines the node hierarchy used to render the x-axis
  46914. * @param yAxis defines the node hierarchy used to render the y-axis
  46915. * @param zAxis defines the node hierarchy used to render the z-axis
  46916. */
  46917. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46918. /**
  46919. * Force the viewer to update
  46920. * @param position defines the position of the viewer
  46921. * @param xaxis defines the x axis of the viewer
  46922. * @param yaxis defines the y axis of the viewer
  46923. * @param zaxis defines the z axis of the viewer
  46924. */
  46925. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46926. /**
  46927. * Creates an instance of this axes viewer.
  46928. * @returns a new axes viewer with instanced meshes
  46929. */
  46930. createInstance(): AxesViewer;
  46931. /** Releases resources */
  46932. dispose(): void;
  46933. private static _SetRenderingGroupId;
  46934. }
  46935. }
  46936. declare module "babylonjs/Debug/boneAxesViewer" {
  46937. import { Nullable } from "babylonjs/types";
  46938. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  46939. import { Vector3 } from "babylonjs/Maths/math.vector";
  46940. import { Mesh } from "babylonjs/Meshes/mesh";
  46941. import { Bone } from "babylonjs/Bones/bone";
  46942. import { Scene } from "babylonjs/scene";
  46943. /**
  46944. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46945. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46946. */
  46947. export class BoneAxesViewer extends AxesViewer {
  46948. /**
  46949. * Gets or sets the target mesh where to display the axes viewer
  46950. */
  46951. mesh: Nullable<Mesh>;
  46952. /**
  46953. * Gets or sets the target bone where to display the axes viewer
  46954. */
  46955. bone: Nullable<Bone>;
  46956. /** Gets current position */
  46957. pos: Vector3;
  46958. /** Gets direction of X axis */
  46959. xaxis: Vector3;
  46960. /** Gets direction of Y axis */
  46961. yaxis: Vector3;
  46962. /** Gets direction of Z axis */
  46963. zaxis: Vector3;
  46964. /**
  46965. * Creates a new BoneAxesViewer
  46966. * @param scene defines the hosting scene
  46967. * @param bone defines the target bone
  46968. * @param mesh defines the target mesh
  46969. * @param scaleLines defines a scaling factor for line length (1 by default)
  46970. */
  46971. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46972. /**
  46973. * Force the viewer to update
  46974. */
  46975. update(): void;
  46976. /** Releases resources */
  46977. dispose(): void;
  46978. }
  46979. }
  46980. declare module "babylonjs/Debug/debugLayer" {
  46981. import { Scene } from "babylonjs/scene";
  46982. /**
  46983. * Interface used to define scene explorer extensibility option
  46984. */
  46985. export interface IExplorerExtensibilityOption {
  46986. /**
  46987. * Define the option label
  46988. */
  46989. label: string;
  46990. /**
  46991. * Defines the action to execute on click
  46992. */
  46993. action: (entity: any) => void;
  46994. }
  46995. /**
  46996. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46997. */
  46998. export interface IExplorerExtensibilityGroup {
  46999. /**
  47000. * Defines a predicate to test if a given type mut be extended
  47001. */
  47002. predicate: (entity: any) => boolean;
  47003. /**
  47004. * Gets the list of options added to a type
  47005. */
  47006. entries: IExplorerExtensibilityOption[];
  47007. }
  47008. /**
  47009. * Interface used to define the options to use to create the Inspector
  47010. */
  47011. export interface IInspectorOptions {
  47012. /**
  47013. * Display in overlay mode (default: false)
  47014. */
  47015. overlay?: boolean;
  47016. /**
  47017. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47018. */
  47019. globalRoot?: HTMLElement;
  47020. /**
  47021. * Display the Scene explorer
  47022. */
  47023. showExplorer?: boolean;
  47024. /**
  47025. * Display the property inspector
  47026. */
  47027. showInspector?: boolean;
  47028. /**
  47029. * Display in embed mode (both panes on the right)
  47030. */
  47031. embedMode?: boolean;
  47032. /**
  47033. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47034. */
  47035. handleResize?: boolean;
  47036. /**
  47037. * Allow the panes to popup (default: true)
  47038. */
  47039. enablePopup?: boolean;
  47040. /**
  47041. * Allow the panes to be closed by users (default: true)
  47042. */
  47043. enableClose?: boolean;
  47044. /**
  47045. * Optional list of extensibility entries
  47046. */
  47047. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47048. /**
  47049. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47050. */
  47051. inspectorURL?: string;
  47052. /**
  47053. * Optional initial tab (default to DebugLayerTab.Properties)
  47054. */
  47055. initialTab?: DebugLayerTab;
  47056. }
  47057. module "babylonjs/scene" {
  47058. interface Scene {
  47059. /**
  47060. * @hidden
  47061. * Backing field
  47062. */
  47063. _debugLayer: DebugLayer;
  47064. /**
  47065. * Gets the debug layer (aka Inspector) associated with the scene
  47066. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47067. */
  47068. debugLayer: DebugLayer;
  47069. }
  47070. }
  47071. /**
  47072. * Enum of inspector action tab
  47073. */
  47074. export enum DebugLayerTab {
  47075. /**
  47076. * Properties tag (default)
  47077. */
  47078. Properties = 0,
  47079. /**
  47080. * Debug tab
  47081. */
  47082. Debug = 1,
  47083. /**
  47084. * Statistics tab
  47085. */
  47086. Statistics = 2,
  47087. /**
  47088. * Tools tab
  47089. */
  47090. Tools = 3,
  47091. /**
  47092. * Settings tab
  47093. */
  47094. Settings = 4
  47095. }
  47096. /**
  47097. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47098. * what is happening in your scene
  47099. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47100. */
  47101. export class DebugLayer {
  47102. /**
  47103. * Define the url to get the inspector script from.
  47104. * By default it uses the babylonjs CDN.
  47105. * @ignoreNaming
  47106. */
  47107. static InspectorURL: string;
  47108. private _scene;
  47109. private BJSINSPECTOR;
  47110. private _onPropertyChangedObservable?;
  47111. /**
  47112. * Observable triggered when a property is changed through the inspector.
  47113. */
  47114. get onPropertyChangedObservable(): any;
  47115. /**
  47116. * Instantiates a new debug layer.
  47117. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47118. * what is happening in your scene
  47119. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47120. * @param scene Defines the scene to inspect
  47121. */
  47122. constructor(scene: Scene);
  47123. /** Creates the inspector window. */
  47124. private _createInspector;
  47125. /**
  47126. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47127. * @param entity defines the entity to select
  47128. * @param lineContainerTitle defines the specific block to highlight
  47129. */
  47130. select(entity: any, lineContainerTitle?: string): void;
  47131. /** Get the inspector from bundle or global */
  47132. private _getGlobalInspector;
  47133. /**
  47134. * Get if the inspector is visible or not.
  47135. * @returns true if visible otherwise, false
  47136. */
  47137. isVisible(): boolean;
  47138. /**
  47139. * Hide the inspector and close its window.
  47140. */
  47141. hide(): void;
  47142. /**
  47143. * Launch the debugLayer.
  47144. * @param config Define the configuration of the inspector
  47145. * @return a promise fulfilled when the debug layer is visible
  47146. */
  47147. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47148. }
  47149. }
  47150. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47151. import { Nullable } from "babylonjs/types";
  47152. import { Scene } from "babylonjs/scene";
  47153. import { Vector4 } from "babylonjs/Maths/math.vector";
  47154. import { Color4 } from "babylonjs/Maths/math.color";
  47155. import { Mesh } from "babylonjs/Meshes/mesh";
  47156. /**
  47157. * Class containing static functions to help procedurally build meshes
  47158. */
  47159. export class BoxBuilder {
  47160. /**
  47161. * Creates a box mesh
  47162. * * The parameter `size` sets the size (float) of each box side (default 1)
  47163. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47164. * * 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)
  47165. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47169. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47170. * @param name defines the name of the mesh
  47171. * @param options defines the options used to create the mesh
  47172. * @param scene defines the hosting scene
  47173. * @returns the box mesh
  47174. */
  47175. static CreateBox(name: string, options: {
  47176. size?: number;
  47177. width?: number;
  47178. height?: number;
  47179. depth?: number;
  47180. faceUV?: Vector4[];
  47181. faceColors?: Color4[];
  47182. sideOrientation?: number;
  47183. frontUVs?: Vector4;
  47184. backUVs?: Vector4;
  47185. wrap?: boolean;
  47186. topBaseAt?: number;
  47187. bottomBaseAt?: number;
  47188. updatable?: boolean;
  47189. }, scene?: Nullable<Scene>): Mesh;
  47190. }
  47191. }
  47192. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47193. import { Vector4 } from "babylonjs/Maths/math.vector";
  47194. import { Mesh } from "babylonjs/Meshes/mesh";
  47195. import { Scene } from "babylonjs/scene";
  47196. import { Nullable } from "babylonjs/types";
  47197. /**
  47198. * Class containing static functions to help procedurally build meshes
  47199. */
  47200. export class SphereBuilder {
  47201. /**
  47202. * Creates a sphere mesh
  47203. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47204. * * 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`)
  47205. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47206. * * 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
  47207. * * 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)
  47208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47211. * @param name defines the name of the mesh
  47212. * @param options defines the options used to create the mesh
  47213. * @param scene defines the hosting scene
  47214. * @returns the sphere mesh
  47215. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47216. */
  47217. static CreateSphere(name: string, options: {
  47218. segments?: number;
  47219. diameter?: number;
  47220. diameterX?: number;
  47221. diameterY?: number;
  47222. diameterZ?: number;
  47223. arc?: number;
  47224. slice?: number;
  47225. sideOrientation?: number;
  47226. frontUVs?: Vector4;
  47227. backUVs?: Vector4;
  47228. updatable?: boolean;
  47229. }, scene?: Nullable<Scene>): Mesh;
  47230. }
  47231. }
  47232. declare module "babylonjs/Debug/physicsViewer" {
  47233. import { Nullable } from "babylonjs/types";
  47234. import { Scene } from "babylonjs/scene";
  47235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47236. import { Mesh } from "babylonjs/Meshes/mesh";
  47237. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47238. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47239. /**
  47240. * Used to show the physics impostor around the specific mesh
  47241. */
  47242. export class PhysicsViewer {
  47243. /** @hidden */
  47244. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47245. /** @hidden */
  47246. protected _meshes: Array<Nullable<AbstractMesh>>;
  47247. /** @hidden */
  47248. protected _scene: Nullable<Scene>;
  47249. /** @hidden */
  47250. protected _numMeshes: number;
  47251. /** @hidden */
  47252. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47253. private _renderFunction;
  47254. private _utilityLayer;
  47255. private _debugBoxMesh;
  47256. private _debugSphereMesh;
  47257. private _debugCylinderMesh;
  47258. private _debugMaterial;
  47259. private _debugMeshMeshes;
  47260. /**
  47261. * Creates a new PhysicsViewer
  47262. * @param scene defines the hosting scene
  47263. */
  47264. constructor(scene: Scene);
  47265. /** @hidden */
  47266. protected _updateDebugMeshes(): void;
  47267. /**
  47268. * Renders a specified physic impostor
  47269. * @param impostor defines the impostor to render
  47270. * @param targetMesh defines the mesh represented by the impostor
  47271. * @returns the new debug mesh used to render the impostor
  47272. */
  47273. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47274. /**
  47275. * Hides a specified physic impostor
  47276. * @param impostor defines the impostor to hide
  47277. */
  47278. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47279. private _getDebugMaterial;
  47280. private _getDebugBoxMesh;
  47281. private _getDebugSphereMesh;
  47282. private _getDebugCylinderMesh;
  47283. private _getDebugMeshMesh;
  47284. private _getDebugMesh;
  47285. /** Releases all resources */
  47286. dispose(): void;
  47287. }
  47288. }
  47289. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47290. import { Vector3 } from "babylonjs/Maths/math.vector";
  47291. import { Color4 } from "babylonjs/Maths/math.color";
  47292. import { Nullable } from "babylonjs/types";
  47293. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47294. import { Scene } from "babylonjs/scene";
  47295. /**
  47296. * Class containing static functions to help procedurally build meshes
  47297. */
  47298. export class LinesBuilder {
  47299. /**
  47300. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47301. * * 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
  47302. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47303. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47304. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47305. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47306. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47307. * * 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
  47308. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47310. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47311. * @param name defines the name of the new line system
  47312. * @param options defines the options used to create the line system
  47313. * @param scene defines the hosting scene
  47314. * @returns a new line system mesh
  47315. */
  47316. static CreateLineSystem(name: string, options: {
  47317. lines: Vector3[][];
  47318. updatable?: boolean;
  47319. instance?: Nullable<LinesMesh>;
  47320. colors?: Nullable<Color4[][]>;
  47321. useVertexAlpha?: boolean;
  47322. }, scene: Nullable<Scene>): LinesMesh;
  47323. /**
  47324. * Creates a line mesh
  47325. * 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
  47326. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47327. * * The parameter `points` is an array successive Vector3
  47328. * * 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
  47329. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47330. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47331. * * When updating an instance, remember that only point positions can change, not the number of points
  47332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47334. * @param name defines the name of the new line system
  47335. * @param options defines the options used to create the line system
  47336. * @param scene defines the hosting scene
  47337. * @returns a new line mesh
  47338. */
  47339. static CreateLines(name: string, options: {
  47340. points: Vector3[];
  47341. updatable?: boolean;
  47342. instance?: Nullable<LinesMesh>;
  47343. colors?: Color4[];
  47344. useVertexAlpha?: boolean;
  47345. }, scene?: Nullable<Scene>): LinesMesh;
  47346. /**
  47347. * Creates a dashed line mesh
  47348. * * 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
  47349. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47350. * * The parameter `points` is an array successive Vector3
  47351. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47352. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47353. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47354. * * 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
  47355. * * When updating an instance, remember that only point positions can change, not the number of points
  47356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47357. * @param name defines the name of the mesh
  47358. * @param options defines the options used to create the mesh
  47359. * @param scene defines the hosting scene
  47360. * @returns the dashed line mesh
  47361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47362. */
  47363. static CreateDashedLines(name: string, options: {
  47364. points: Vector3[];
  47365. dashSize?: number;
  47366. gapSize?: number;
  47367. dashNb?: number;
  47368. updatable?: boolean;
  47369. instance?: LinesMesh;
  47370. }, scene?: Nullable<Scene>): LinesMesh;
  47371. }
  47372. }
  47373. declare module "babylonjs/Debug/rayHelper" {
  47374. import { Nullable } from "babylonjs/types";
  47375. import { Ray } from "babylonjs/Culling/ray";
  47376. import { Vector3 } from "babylonjs/Maths/math.vector";
  47377. import { Color3 } from "babylonjs/Maths/math.color";
  47378. import { Scene } from "babylonjs/scene";
  47379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47380. import "babylonjs/Meshes/Builders/linesBuilder";
  47381. /**
  47382. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47383. * in order to better appreciate the issue one might have.
  47384. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47385. */
  47386. export class RayHelper {
  47387. /**
  47388. * Defines the ray we are currently tryin to visualize.
  47389. */
  47390. ray: Nullable<Ray>;
  47391. private _renderPoints;
  47392. private _renderLine;
  47393. private _renderFunction;
  47394. private _scene;
  47395. private _updateToMeshFunction;
  47396. private _attachedToMesh;
  47397. private _meshSpaceDirection;
  47398. private _meshSpaceOrigin;
  47399. /**
  47400. * Helper function to create a colored helper in a scene in one line.
  47401. * @param ray Defines the ray we are currently tryin to visualize
  47402. * @param scene Defines the scene the ray is used in
  47403. * @param color Defines the color we want to see the ray in
  47404. * @returns The newly created ray helper.
  47405. */
  47406. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47407. /**
  47408. * Instantiate a new ray helper.
  47409. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47410. * in order to better appreciate the issue one might have.
  47411. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47412. * @param ray Defines the ray we are currently tryin to visualize
  47413. */
  47414. constructor(ray: Ray);
  47415. /**
  47416. * Shows the ray we are willing to debug.
  47417. * @param scene Defines the scene the ray needs to be rendered in
  47418. * @param color Defines the color the ray needs to be rendered in
  47419. */
  47420. show(scene: Scene, color?: Color3): void;
  47421. /**
  47422. * Hides the ray we are debugging.
  47423. */
  47424. hide(): void;
  47425. private _render;
  47426. /**
  47427. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47428. * @param mesh Defines the mesh we want the helper attached to
  47429. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47430. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47431. * @param length Defines the length of the ray
  47432. */
  47433. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47434. /**
  47435. * Detach the ray helper from the mesh it has previously been attached to.
  47436. */
  47437. detachFromMesh(): void;
  47438. private _updateToMesh;
  47439. /**
  47440. * Dispose the helper and release its associated resources.
  47441. */
  47442. dispose(): void;
  47443. }
  47444. }
  47445. declare module "babylonjs/Debug/skeletonViewer" {
  47446. import { Color3 } from "babylonjs/Maths/math.color";
  47447. import { Scene } from "babylonjs/scene";
  47448. import { Nullable } from "babylonjs/types";
  47449. import { Skeleton } from "babylonjs/Bones/skeleton";
  47450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47451. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47452. /**
  47453. * Class used to render a debug view of a given skeleton
  47454. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47455. */
  47456. export class SkeletonViewer {
  47457. /** defines the skeleton to render */
  47458. skeleton: Skeleton;
  47459. /** defines the mesh attached to the skeleton */
  47460. mesh: AbstractMesh;
  47461. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47462. autoUpdateBonesMatrices: boolean;
  47463. /** defines the rendering group id to use with the viewer */
  47464. renderingGroupId: number;
  47465. /** Gets or sets the color used to render the skeleton */
  47466. color: Color3;
  47467. private _scene;
  47468. private _debugLines;
  47469. private _debugMesh;
  47470. private _isEnabled;
  47471. private _renderFunction;
  47472. private _utilityLayer;
  47473. /**
  47474. * Returns the mesh used to render the bones
  47475. */
  47476. get debugMesh(): Nullable<LinesMesh>;
  47477. /**
  47478. * Creates a new SkeletonViewer
  47479. * @param skeleton defines the skeleton to render
  47480. * @param mesh defines the mesh attached to the skeleton
  47481. * @param scene defines the hosting scene
  47482. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47483. * @param renderingGroupId defines the rendering group id to use with the viewer
  47484. */
  47485. constructor(
  47486. /** defines the skeleton to render */
  47487. skeleton: Skeleton,
  47488. /** defines the mesh attached to the skeleton */
  47489. mesh: AbstractMesh, scene: Scene,
  47490. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47491. autoUpdateBonesMatrices?: boolean,
  47492. /** defines the rendering group id to use with the viewer */
  47493. renderingGroupId?: number);
  47494. /** Gets or sets a boolean indicating if the viewer is enabled */
  47495. set isEnabled(value: boolean);
  47496. get isEnabled(): boolean;
  47497. private _getBonePosition;
  47498. private _getLinesForBonesWithLength;
  47499. private _getLinesForBonesNoLength;
  47500. /** Update the viewer to sync with current skeleton state */
  47501. update(): void;
  47502. /** Release associated resources */
  47503. dispose(): void;
  47504. }
  47505. }
  47506. declare module "babylonjs/Debug/index" {
  47507. export * from "babylonjs/Debug/axesViewer";
  47508. export * from "babylonjs/Debug/boneAxesViewer";
  47509. export * from "babylonjs/Debug/debugLayer";
  47510. export * from "babylonjs/Debug/physicsViewer";
  47511. export * from "babylonjs/Debug/rayHelper";
  47512. export * from "babylonjs/Debug/skeletonViewer";
  47513. }
  47514. declare module "babylonjs/Engines/nullEngine" {
  47515. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47516. import { Scene } from "babylonjs/scene";
  47517. import { Engine } from "babylonjs/Engines/engine";
  47518. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47519. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47521. import { Effect } from "babylonjs/Materials/effect";
  47522. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47523. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47524. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47525. /**
  47526. * Options to create the null engine
  47527. */
  47528. export class NullEngineOptions {
  47529. /**
  47530. * Render width (Default: 512)
  47531. */
  47532. renderWidth: number;
  47533. /**
  47534. * Render height (Default: 256)
  47535. */
  47536. renderHeight: number;
  47537. /**
  47538. * Texture size (Default: 512)
  47539. */
  47540. textureSize: number;
  47541. /**
  47542. * If delta time between frames should be constant
  47543. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47544. */
  47545. deterministicLockstep: boolean;
  47546. /**
  47547. * Maximum about of steps between frames (Default: 4)
  47548. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47549. */
  47550. lockstepMaxSteps: number;
  47551. }
  47552. /**
  47553. * The null engine class provides support for headless version of babylon.js.
  47554. * This can be used in server side scenario or for testing purposes
  47555. */
  47556. export class NullEngine extends Engine {
  47557. private _options;
  47558. /**
  47559. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47561. * @returns true if engine is in deterministic lock step mode
  47562. */
  47563. isDeterministicLockStep(): boolean;
  47564. /**
  47565. * Gets the max steps when engine is running in deterministic lock step
  47566. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47567. * @returns the max steps
  47568. */
  47569. getLockstepMaxSteps(): number;
  47570. /**
  47571. * Gets the current hardware scaling level.
  47572. * By default the hardware scaling level is computed from the window device ratio.
  47573. * 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.
  47574. * @returns a number indicating the current hardware scaling level
  47575. */
  47576. getHardwareScalingLevel(): number;
  47577. constructor(options?: NullEngineOptions);
  47578. /**
  47579. * Creates a vertex buffer
  47580. * @param vertices the data for the vertex buffer
  47581. * @returns the new WebGL static buffer
  47582. */
  47583. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47584. /**
  47585. * Creates a new index buffer
  47586. * @param indices defines the content of the index buffer
  47587. * @param updatable defines if the index buffer must be updatable
  47588. * @returns a new webGL buffer
  47589. */
  47590. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47591. /**
  47592. * Clear the current render buffer or the current render target (if any is set up)
  47593. * @param color defines the color to use
  47594. * @param backBuffer defines if the back buffer must be cleared
  47595. * @param depth defines if the depth buffer must be cleared
  47596. * @param stencil defines if the stencil buffer must be cleared
  47597. */
  47598. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47599. /**
  47600. * Gets the current render width
  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 width
  47603. */
  47604. getRenderWidth(useScreen?: boolean): number;
  47605. /**
  47606. * Gets the current render height
  47607. * @param useScreen defines if screen size must be used (or the current render target if any)
  47608. * @returns a number defining the current render height
  47609. */
  47610. getRenderHeight(useScreen?: boolean): number;
  47611. /**
  47612. * Set the WebGL's viewport
  47613. * @param viewport defines the viewport element to be used
  47614. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47615. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47616. */
  47617. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47618. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47619. /**
  47620. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47621. * @param pipelineContext defines the pipeline context to use
  47622. * @param uniformsNames defines the list of uniform names
  47623. * @returns an array of webGL uniform locations
  47624. */
  47625. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47626. /**
  47627. * Gets the lsit of active attributes for a given webGL program
  47628. * @param pipelineContext defines the pipeline context to use
  47629. * @param attributesNames defines the list of attribute names to get
  47630. * @returns an array of indices indicating the offset of each attribute
  47631. */
  47632. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47633. /**
  47634. * Binds an effect to the webGL context
  47635. * @param effect defines the effect to bind
  47636. */
  47637. bindSamplers(effect: Effect): void;
  47638. /**
  47639. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47640. * @param effect defines the effect to activate
  47641. */
  47642. enableEffect(effect: Effect): void;
  47643. /**
  47644. * Set various states to the webGL context
  47645. * @param culling defines backface culling state
  47646. * @param zOffset defines the value to apply to zOffset (0 by default)
  47647. * @param force defines if states must be applied even if cache is up to date
  47648. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47649. */
  47650. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47651. /**
  47652. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47657. /**
  47658. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47663. /**
  47664. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47669. /**
  47670. * Set the value of an uniform to an array of int32 (stored as vec4)
  47671. * @param uniform defines the webGL uniform location where to store the value
  47672. * @param array defines the array of int32 to store
  47673. */
  47674. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47675. /**
  47676. * Set the value of an uniform to an array of float32
  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. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47681. /**
  47682. * Set the value of an uniform to an array of float32 (stored as vec2)
  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. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47687. /**
  47688. * Set the value of an uniform to an array of float32 (stored as vec3)
  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. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47693. /**
  47694. * Set the value of an uniform to an array of float32 (stored as vec4)
  47695. * @param uniform defines the webGL uniform location where to store the value
  47696. * @param array defines the array of float32 to store
  47697. */
  47698. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47699. /**
  47700. * Set the value of an uniform to an array of number
  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. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47705. /**
  47706. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47711. /**
  47712. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47717. /**
  47718. * Set the value of an uniform to an array of number (stored as vec4)
  47719. * @param uniform defines the webGL uniform location where to store the value
  47720. * @param array defines the array of number to store
  47721. */
  47722. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47723. /**
  47724. * Set the value of an uniform to an array of float32 (stored as matrices)
  47725. * @param uniform defines the webGL uniform location where to store the value
  47726. * @param matrices defines the array of float32 to store
  47727. */
  47728. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47729. /**
  47730. * Set the value of an uniform to a matrix (3x3)
  47731. * @param uniform defines the webGL uniform location where to store the value
  47732. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47733. */
  47734. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47735. /**
  47736. * Set the value of an uniform to a matrix (2x2)
  47737. * @param uniform defines the webGL uniform location where to store the value
  47738. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47739. */
  47740. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47741. /**
  47742. * Set the value of an uniform to a number (float)
  47743. * @param uniform defines the webGL uniform location where to store the value
  47744. * @param value defines the float number to store
  47745. */
  47746. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47747. /**
  47748. * Set the value of an uniform to a vec2
  47749. * @param uniform defines the webGL uniform location where to store the value
  47750. * @param x defines the 1st component of the value
  47751. * @param y defines the 2nd component of the value
  47752. */
  47753. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47754. /**
  47755. * Set the value of an uniform to a vec3
  47756. * @param uniform defines the webGL uniform location where to store the value
  47757. * @param x defines the 1st component of the value
  47758. * @param y defines the 2nd component of the value
  47759. * @param z defines the 3rd component of the value
  47760. */
  47761. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47762. /**
  47763. * Set the value of an uniform to a boolean
  47764. * @param uniform defines the webGL uniform location where to store the value
  47765. * @param bool defines the boolean to store
  47766. */
  47767. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47768. /**
  47769. * Set the value of an uniform to a vec4
  47770. * @param uniform defines the webGL uniform location where to store the value
  47771. * @param x defines the 1st component of the value
  47772. * @param y defines the 2nd component of the value
  47773. * @param z defines the 3rd component of the value
  47774. * @param w defines the 4th component of the value
  47775. */
  47776. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47777. /**
  47778. * Sets the current alpha mode
  47779. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47780. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47781. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47782. */
  47783. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47784. /**
  47785. * Bind webGl buffers directly to the webGL context
  47786. * @param vertexBuffers defines the vertex buffer to bind
  47787. * @param indexBuffer defines the index buffer to bind
  47788. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47789. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47790. * @param effect defines the effect associated with the vertex buffer
  47791. */
  47792. bindBuffers(vertexBuffers: {
  47793. [key: string]: VertexBuffer;
  47794. }, indexBuffer: DataBuffer, effect: Effect): void;
  47795. /**
  47796. * Force the entire cache to be cleared
  47797. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47798. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47799. */
  47800. wipeCaches(bruteForce?: boolean): void;
  47801. /**
  47802. * Send a draw order
  47803. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47804. * @param indexStart defines the starting index
  47805. * @param indexCount defines the number of index to draw
  47806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47807. */
  47808. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47809. /**
  47810. * Draw a list of indexed primitives
  47811. * @param fillMode defines the primitive to use
  47812. * @param indexStart defines the starting index
  47813. * @param indexCount defines the number of index to draw
  47814. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47815. */
  47816. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47817. /**
  47818. * Draw a list of unindexed primitives
  47819. * @param fillMode defines the primitive to use
  47820. * @param verticesStart defines the index of first vertex to draw
  47821. * @param verticesCount defines the count of vertices to draw
  47822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47823. */
  47824. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47825. /** @hidden */
  47826. _createTexture(): WebGLTexture;
  47827. /** @hidden */
  47828. _releaseTexture(texture: InternalTexture): void;
  47829. /**
  47830. * Usually called from Texture.ts.
  47831. * Passed information to create a WebGLTexture
  47832. * @param urlArg defines a value which contains one of the following:
  47833. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47834. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47835. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47837. * @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)
  47838. * @param scene needed for loading to the correct scene
  47839. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47840. * @param onLoad optional callback to be called upon successful completion
  47841. * @param onError optional callback to be called upon failure
  47842. * @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
  47843. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47844. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47845. * @param forcedExtension defines the extension to use to pick the right loader
  47846. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47847. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47848. */
  47849. 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;
  47850. /**
  47851. * Creates a new render target texture
  47852. * @param size defines the size of the texture
  47853. * @param options defines the options used to create the texture
  47854. * @returns a new render target texture stored in an InternalTexture
  47855. */
  47856. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47857. /**
  47858. * Update the sampling mode of a given texture
  47859. * @param samplingMode defines the required sampling mode
  47860. * @param texture defines the texture to update
  47861. */
  47862. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47863. /**
  47864. * Binds the frame buffer to the specified texture.
  47865. * @param texture The texture to render to or null for the default canvas
  47866. * @param faceIndex The face of the texture to render to in case of cube texture
  47867. * @param requiredWidth The width of the target to render to
  47868. * @param requiredHeight The height of the target to render to
  47869. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47870. * @param depthStencilTexture The depth stencil texture to use to render
  47871. * @param lodLevel defines le lod level to bind to the frame buffer
  47872. */
  47873. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47874. /**
  47875. * Unbind the current render target texture from the webGL context
  47876. * @param texture defines the render target texture to unbind
  47877. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47878. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47879. */
  47880. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47881. /**
  47882. * Creates a dynamic vertex buffer
  47883. * @param vertices the data for the dynamic vertex buffer
  47884. * @returns the new WebGL dynamic buffer
  47885. */
  47886. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47887. /**
  47888. * Update the content of a dynamic texture
  47889. * @param texture defines the texture to update
  47890. * @param canvas defines the canvas containing the source
  47891. * @param invertY defines if data must be stored with Y axis inverted
  47892. * @param premulAlpha defines if alpha is stored as premultiplied
  47893. * @param format defines the format of the data
  47894. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47895. */
  47896. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47897. /**
  47898. * Gets a boolean indicating if all created effects are ready
  47899. * @returns true if all effects are ready
  47900. */
  47901. areAllEffectsReady(): boolean;
  47902. /**
  47903. * @hidden
  47904. * Get the current error code of the webGL context
  47905. * @returns the error code
  47906. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47907. */
  47908. getError(): number;
  47909. /** @hidden */
  47910. _getUnpackAlignement(): number;
  47911. /** @hidden */
  47912. _unpackFlipY(value: boolean): void;
  47913. /**
  47914. * Update a dynamic index buffer
  47915. * @param indexBuffer defines the target index buffer
  47916. * @param indices defines the data to update
  47917. * @param offset defines the offset in the target index buffer where update should start
  47918. */
  47919. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47920. /**
  47921. * Updates a dynamic vertex buffer.
  47922. * @param vertexBuffer the vertex buffer to update
  47923. * @param vertices the data used to update the vertex buffer
  47924. * @param byteOffset the byte offset of the data (optional)
  47925. * @param byteLength the byte length of the data (optional)
  47926. */
  47927. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47928. /** @hidden */
  47929. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47930. /** @hidden */
  47931. _bindTexture(channel: number, texture: InternalTexture): void;
  47932. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47933. /**
  47934. * 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
  47935. */
  47936. releaseEffects(): void;
  47937. displayLoadingUI(): void;
  47938. hideLoadingUI(): void;
  47939. /** @hidden */
  47940. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47941. /** @hidden */
  47942. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47943. /** @hidden */
  47944. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47945. /** @hidden */
  47946. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47947. }
  47948. }
  47949. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  47950. import { Nullable, int } from "babylonjs/types";
  47951. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  47952. /** @hidden */
  47953. export class _OcclusionDataStorage {
  47954. /** @hidden */
  47955. occlusionInternalRetryCounter: number;
  47956. /** @hidden */
  47957. isOcclusionQueryInProgress: boolean;
  47958. /** @hidden */
  47959. isOccluded: boolean;
  47960. /** @hidden */
  47961. occlusionRetryCount: number;
  47962. /** @hidden */
  47963. occlusionType: number;
  47964. /** @hidden */
  47965. occlusionQueryAlgorithmType: number;
  47966. }
  47967. module "babylonjs/Engines/engine" {
  47968. interface Engine {
  47969. /**
  47970. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47971. * @return the new query
  47972. */
  47973. createQuery(): WebGLQuery;
  47974. /**
  47975. * Delete and release a webGL query
  47976. * @param query defines the query to delete
  47977. * @return the current engine
  47978. */
  47979. deleteQuery(query: WebGLQuery): Engine;
  47980. /**
  47981. * Check if a given query has resolved and got its value
  47982. * @param query defines the query to check
  47983. * @returns true if the query got its value
  47984. */
  47985. isQueryResultAvailable(query: WebGLQuery): boolean;
  47986. /**
  47987. * Gets the value of a given query
  47988. * @param query defines the query to check
  47989. * @returns the value of the query
  47990. */
  47991. getQueryResult(query: WebGLQuery): number;
  47992. /**
  47993. * Initiates an occlusion query
  47994. * @param algorithmType defines the algorithm to use
  47995. * @param query defines the query to use
  47996. * @returns the current engine
  47997. * @see http://doc.babylonjs.com/features/occlusionquery
  47998. */
  47999. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48000. /**
  48001. * Ends an occlusion query
  48002. * @see http://doc.babylonjs.com/features/occlusionquery
  48003. * @param algorithmType defines the algorithm to use
  48004. * @returns the current engine
  48005. */
  48006. endOcclusionQuery(algorithmType: number): Engine;
  48007. /**
  48008. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48009. * Please note that only one query can be issued at a time
  48010. * @returns a time token used to track the time span
  48011. */
  48012. startTimeQuery(): Nullable<_TimeToken>;
  48013. /**
  48014. * Ends a time query
  48015. * @param token defines the token used to measure the time span
  48016. * @returns the time spent (in ns)
  48017. */
  48018. endTimeQuery(token: _TimeToken): int;
  48019. /** @hidden */
  48020. _currentNonTimestampToken: Nullable<_TimeToken>;
  48021. /** @hidden */
  48022. _createTimeQuery(): WebGLQuery;
  48023. /** @hidden */
  48024. _deleteTimeQuery(query: WebGLQuery): void;
  48025. /** @hidden */
  48026. _getGlAlgorithmType(algorithmType: number): number;
  48027. /** @hidden */
  48028. _getTimeQueryResult(query: WebGLQuery): any;
  48029. /** @hidden */
  48030. _getTimeQueryAvailability(query: WebGLQuery): any;
  48031. }
  48032. }
  48033. module "babylonjs/Meshes/abstractMesh" {
  48034. interface AbstractMesh {
  48035. /**
  48036. * Backing filed
  48037. * @hidden
  48038. */
  48039. __occlusionDataStorage: _OcclusionDataStorage;
  48040. /**
  48041. * Access property
  48042. * @hidden
  48043. */
  48044. _occlusionDataStorage: _OcclusionDataStorage;
  48045. /**
  48046. * 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.
  48047. * The default value is -1 which means don't break the query and wait till the result
  48048. * @see http://doc.babylonjs.com/features/occlusionquery
  48049. */
  48050. occlusionRetryCount: number;
  48051. /**
  48052. * 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:
  48053. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48054. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48055. * * 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.
  48056. * @see http://doc.babylonjs.com/features/occlusionquery
  48057. */
  48058. occlusionType: number;
  48059. /**
  48060. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48061. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48062. * * 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.
  48063. * @see http://doc.babylonjs.com/features/occlusionquery
  48064. */
  48065. occlusionQueryAlgorithmType: number;
  48066. /**
  48067. * 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
  48068. * @see http://doc.babylonjs.com/features/occlusionquery
  48069. */
  48070. isOccluded: boolean;
  48071. /**
  48072. * Flag to check the progress status of the query
  48073. * @see http://doc.babylonjs.com/features/occlusionquery
  48074. */
  48075. isOcclusionQueryInProgress: boolean;
  48076. }
  48077. }
  48078. }
  48079. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48080. import { Nullable } from "babylonjs/types";
  48081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48082. /** @hidden */
  48083. export var _forceTransformFeedbackToBundle: boolean;
  48084. module "babylonjs/Engines/engine" {
  48085. interface Engine {
  48086. /**
  48087. * Creates a webGL transform feedback object
  48088. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48089. * @returns the webGL transform feedback object
  48090. */
  48091. createTransformFeedback(): WebGLTransformFeedback;
  48092. /**
  48093. * Delete a webGL transform feedback object
  48094. * @param value defines the webGL transform feedback object to delete
  48095. */
  48096. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48097. /**
  48098. * Bind a webGL transform feedback object to the webgl context
  48099. * @param value defines the webGL transform feedback object to bind
  48100. */
  48101. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48102. /**
  48103. * Begins a transform feedback operation
  48104. * @param usePoints defines if points or triangles must be used
  48105. */
  48106. beginTransformFeedback(usePoints: boolean): void;
  48107. /**
  48108. * Ends a transform feedback operation
  48109. */
  48110. endTransformFeedback(): void;
  48111. /**
  48112. * Specify the varyings to use with transform feedback
  48113. * @param program defines the associated webGL program
  48114. * @param value defines the list of strings representing the varying names
  48115. */
  48116. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48117. /**
  48118. * Bind a webGL buffer for a transform feedback operation
  48119. * @param value defines the webGL buffer to bind
  48120. */
  48121. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48122. }
  48123. }
  48124. }
  48125. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48126. import { Scene } from "babylonjs/scene";
  48127. import { Engine } from "babylonjs/Engines/engine";
  48128. import { Texture } from "babylonjs/Materials/Textures/texture";
  48129. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48130. import "babylonjs/Engines/Extensions/engine.multiRender";
  48131. /**
  48132. * Creation options of the multi render target texture.
  48133. */
  48134. export interface IMultiRenderTargetOptions {
  48135. /**
  48136. * Define if the texture needs to create mip maps after render.
  48137. */
  48138. generateMipMaps?: boolean;
  48139. /**
  48140. * Define the types of all the draw buffers we want to create
  48141. */
  48142. types?: number[];
  48143. /**
  48144. * Define the sampling modes of all the draw buffers we want to create
  48145. */
  48146. samplingModes?: number[];
  48147. /**
  48148. * Define if a depth buffer is required
  48149. */
  48150. generateDepthBuffer?: boolean;
  48151. /**
  48152. * Define if a stencil buffer is required
  48153. */
  48154. generateStencilBuffer?: boolean;
  48155. /**
  48156. * Define if a depth texture is required instead of a depth buffer
  48157. */
  48158. generateDepthTexture?: boolean;
  48159. /**
  48160. * Define the number of desired draw buffers
  48161. */
  48162. textureCount?: number;
  48163. /**
  48164. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48165. */
  48166. doNotChangeAspectRatio?: boolean;
  48167. /**
  48168. * Define the default type of the buffers we are creating
  48169. */
  48170. defaultType?: number;
  48171. }
  48172. /**
  48173. * A multi render target, like a render target provides the ability to render to a texture.
  48174. * Unlike the render target, it can render to several draw buffers in one draw.
  48175. * This is specially interesting in deferred rendering or for any effects requiring more than
  48176. * just one color from a single pass.
  48177. */
  48178. export class MultiRenderTarget extends RenderTargetTexture {
  48179. private _internalTextures;
  48180. private _textures;
  48181. private _multiRenderTargetOptions;
  48182. /**
  48183. * Get if draw buffers are currently supported by the used hardware and browser.
  48184. */
  48185. get isSupported(): boolean;
  48186. /**
  48187. * Get the list of textures generated by the multi render target.
  48188. */
  48189. get textures(): Texture[];
  48190. /**
  48191. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48192. */
  48193. get depthTexture(): Texture;
  48194. /**
  48195. * Set the wrapping mode on U of all the textures we are rendering to.
  48196. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48197. */
  48198. set wrapU(wrap: number);
  48199. /**
  48200. * Set the wrapping mode on V of all the textures we are rendering to.
  48201. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48202. */
  48203. set wrapV(wrap: number);
  48204. /**
  48205. * Instantiate a new multi render target texture.
  48206. * A multi render target, like a render target provides the ability to render to a texture.
  48207. * Unlike the render target, it can render to several draw buffers in one draw.
  48208. * This is specially interesting in deferred rendering or for any effects requiring more than
  48209. * just one color from a single pass.
  48210. * @param name Define the name of the texture
  48211. * @param size Define the size of the buffers to render to
  48212. * @param count Define the number of target we are rendering into
  48213. * @param scene Define the scene the texture belongs to
  48214. * @param options Define the options used to create the multi render target
  48215. */
  48216. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48217. /** @hidden */
  48218. _rebuild(): void;
  48219. private _createInternalTextures;
  48220. private _createTextures;
  48221. /**
  48222. * Define the number of samples used if MSAA is enabled.
  48223. */
  48224. get samples(): number;
  48225. set samples(value: number);
  48226. /**
  48227. * Resize all the textures in the multi render target.
  48228. * Be carrefull as it will recreate all the data in the new texture.
  48229. * @param size Define the new size
  48230. */
  48231. resize(size: any): void;
  48232. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48233. /**
  48234. * Dispose the render targets and their associated resources
  48235. */
  48236. dispose(): void;
  48237. /**
  48238. * Release all the underlying texture used as draw buffers.
  48239. */
  48240. releaseInternalTextures(): void;
  48241. }
  48242. }
  48243. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48244. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48245. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48246. import { Nullable } from "babylonjs/types";
  48247. module "babylonjs/Engines/thinEngine" {
  48248. interface ThinEngine {
  48249. /**
  48250. * Unbind a list of render target textures from the webGL context
  48251. * This is used only when drawBuffer extension or webGL2 are active
  48252. * @param textures defines the render target textures to unbind
  48253. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48254. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48255. */
  48256. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48257. /**
  48258. * Create a multi render target texture
  48259. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48260. * @param size defines the size of the texture
  48261. * @param options defines the creation options
  48262. * @returns the cube texture as an InternalTexture
  48263. */
  48264. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48265. /**
  48266. * Update the sample count for a given multiple render target texture
  48267. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48268. * @param textures defines the textures to update
  48269. * @param samples defines the sample count to set
  48270. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48271. */
  48272. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48273. }
  48274. }
  48275. }
  48276. declare module "babylonjs/Engines/Extensions/engine.views" {
  48277. import { Camera } from "babylonjs/Cameras/camera";
  48278. import { Nullable } from "babylonjs/types";
  48279. /**
  48280. * Class used to define an additional view for the engine
  48281. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48282. */
  48283. export class EngineView {
  48284. /** Defines the canvas where to render the view */
  48285. target: HTMLCanvasElement;
  48286. /** Defines an optional camera used to render the view (will use active camera else) */
  48287. camera?: Camera;
  48288. }
  48289. module "babylonjs/Engines/engine" {
  48290. interface Engine {
  48291. /**
  48292. * Gets or sets the HTML element to use for attaching events
  48293. */
  48294. inputElement: Nullable<HTMLElement>;
  48295. /**
  48296. * Gets the current engine view
  48297. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48298. */
  48299. activeView: Nullable<EngineView>;
  48300. /** Gets or sets the list of views */
  48301. views: EngineView[];
  48302. /**
  48303. * Register a new child canvas
  48304. * @param canvas defines the canvas to register
  48305. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48306. * @returns the associated view
  48307. */
  48308. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48309. /**
  48310. * Remove a registered child canvas
  48311. * @param canvas defines the canvas to remove
  48312. * @returns the current engine
  48313. */
  48314. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48315. }
  48316. }
  48317. }
  48318. declare module "babylonjs/Engines/Extensions/index" {
  48319. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48320. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48321. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48322. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48323. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48324. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48325. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48326. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48327. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48328. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48329. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48330. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48331. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48332. export * from "babylonjs/Engines/Extensions/engine.views";
  48333. }
  48334. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48335. import { Nullable } from "babylonjs/types";
  48336. /**
  48337. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48338. */
  48339. export interface CubeMapInfo {
  48340. /**
  48341. * The pixel array for the front face.
  48342. * This is stored in format, left to right, up to down format.
  48343. */
  48344. front: Nullable<ArrayBufferView>;
  48345. /**
  48346. * The pixel array for the back face.
  48347. * This is stored in format, left to right, up to down format.
  48348. */
  48349. back: Nullable<ArrayBufferView>;
  48350. /**
  48351. * The pixel array for the left face.
  48352. * This is stored in format, left to right, up to down format.
  48353. */
  48354. left: Nullable<ArrayBufferView>;
  48355. /**
  48356. * The pixel array for the right face.
  48357. * This is stored in format, left to right, up to down format.
  48358. */
  48359. right: Nullable<ArrayBufferView>;
  48360. /**
  48361. * The pixel array for the up face.
  48362. * This is stored in format, left to right, up to down format.
  48363. */
  48364. up: Nullable<ArrayBufferView>;
  48365. /**
  48366. * The pixel array for the down face.
  48367. * This is stored in format, left to right, up to down format.
  48368. */
  48369. down: Nullable<ArrayBufferView>;
  48370. /**
  48371. * The size of the cubemap stored.
  48372. *
  48373. * Each faces will be size * size pixels.
  48374. */
  48375. size: number;
  48376. /**
  48377. * The format of the texture.
  48378. *
  48379. * RGBA, RGB.
  48380. */
  48381. format: number;
  48382. /**
  48383. * The type of the texture data.
  48384. *
  48385. * UNSIGNED_INT, FLOAT.
  48386. */
  48387. type: number;
  48388. /**
  48389. * Specifies whether the texture is in gamma space.
  48390. */
  48391. gammaSpace: boolean;
  48392. }
  48393. /**
  48394. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48395. */
  48396. export class PanoramaToCubeMapTools {
  48397. private static FACE_FRONT;
  48398. private static FACE_BACK;
  48399. private static FACE_RIGHT;
  48400. private static FACE_LEFT;
  48401. private static FACE_DOWN;
  48402. private static FACE_UP;
  48403. /**
  48404. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48405. *
  48406. * @param float32Array The source data.
  48407. * @param inputWidth The width of the input panorama.
  48408. * @param inputHeight The height of the input panorama.
  48409. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48410. * @return The cubemap data
  48411. */
  48412. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48413. private static CreateCubemapTexture;
  48414. private static CalcProjectionSpherical;
  48415. }
  48416. }
  48417. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48418. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48419. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48420. import { Nullable } from "babylonjs/types";
  48421. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48422. /**
  48423. * Helper class dealing with the extraction of spherical polynomial dataArray
  48424. * from a cube map.
  48425. */
  48426. export class CubeMapToSphericalPolynomialTools {
  48427. private static FileFaces;
  48428. /**
  48429. * Converts a texture to the according Spherical Polynomial data.
  48430. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48431. *
  48432. * @param texture The texture to extract the information from.
  48433. * @return The Spherical Polynomial data.
  48434. */
  48435. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48436. /**
  48437. * Converts a cubemap to the according Spherical Polynomial data.
  48438. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48439. *
  48440. * @param cubeInfo The Cube map to extract the information from.
  48441. * @return The Spherical Polynomial data.
  48442. */
  48443. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48444. }
  48445. }
  48446. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48447. import { Nullable } from "babylonjs/types";
  48448. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48449. module "babylonjs/Materials/Textures/baseTexture" {
  48450. interface BaseTexture {
  48451. /**
  48452. * Get the polynomial representation of the texture data.
  48453. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48454. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48455. */
  48456. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48457. }
  48458. }
  48459. }
  48460. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48461. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48462. /** @hidden */
  48463. export var rgbdEncodePixelShader: {
  48464. name: string;
  48465. shader: string;
  48466. };
  48467. }
  48468. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48469. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48470. /** @hidden */
  48471. export var rgbdDecodePixelShader: {
  48472. name: string;
  48473. shader: string;
  48474. };
  48475. }
  48476. declare module "babylonjs/Misc/environmentTextureTools" {
  48477. import { Nullable } from "babylonjs/types";
  48478. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48479. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48480. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48481. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48482. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48483. import "babylonjs/Shaders/rgbdEncode.fragment";
  48484. import "babylonjs/Shaders/rgbdDecode.fragment";
  48485. /**
  48486. * Raw texture data and descriptor sufficient for WebGL texture upload
  48487. */
  48488. export interface EnvironmentTextureInfo {
  48489. /**
  48490. * Version of the environment map
  48491. */
  48492. version: number;
  48493. /**
  48494. * Width of image
  48495. */
  48496. width: number;
  48497. /**
  48498. * Irradiance information stored in the file.
  48499. */
  48500. irradiance: any;
  48501. /**
  48502. * Specular information stored in the file.
  48503. */
  48504. specular: any;
  48505. }
  48506. /**
  48507. * Defines One Image in the file. It requires only the position in the file
  48508. * as well as the length.
  48509. */
  48510. interface BufferImageData {
  48511. /**
  48512. * Length of the image data.
  48513. */
  48514. length: number;
  48515. /**
  48516. * Position of the data from the null terminator delimiting the end of the JSON.
  48517. */
  48518. position: number;
  48519. }
  48520. /**
  48521. * Defines the specular data enclosed in the file.
  48522. * This corresponds to the version 1 of the data.
  48523. */
  48524. export interface EnvironmentTextureSpecularInfoV1 {
  48525. /**
  48526. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48527. */
  48528. specularDataPosition?: number;
  48529. /**
  48530. * This contains all the images data needed to reconstruct the cubemap.
  48531. */
  48532. mipmaps: Array<BufferImageData>;
  48533. /**
  48534. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48535. */
  48536. lodGenerationScale: number;
  48537. }
  48538. /**
  48539. * Sets of helpers addressing the serialization and deserialization of environment texture
  48540. * stored in a BabylonJS env file.
  48541. * Those files are usually stored as .env files.
  48542. */
  48543. export class EnvironmentTextureTools {
  48544. /**
  48545. * Magic number identifying the env file.
  48546. */
  48547. private static _MagicBytes;
  48548. /**
  48549. * Gets the environment info from an env file.
  48550. * @param data The array buffer containing the .env bytes.
  48551. * @returns the environment file info (the json header) if successfully parsed.
  48552. */
  48553. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48554. /**
  48555. * Creates an environment texture from a loaded cube texture.
  48556. * @param texture defines the cube texture to convert in env file
  48557. * @return a promise containing the environment data if succesfull.
  48558. */
  48559. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48560. /**
  48561. * Creates a JSON representation of the spherical data.
  48562. * @param texture defines the texture containing the polynomials
  48563. * @return the JSON representation of the spherical info
  48564. */
  48565. private static _CreateEnvTextureIrradiance;
  48566. /**
  48567. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48568. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48569. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48570. * @return the views described by info providing access to the underlying buffer
  48571. */
  48572. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48573. /**
  48574. * Uploads the texture info contained in the env file to the GPU.
  48575. * @param texture defines the internal texture to upload to
  48576. * @param arrayBuffer defines the buffer cotaining the data to load
  48577. * @param info defines the texture info retrieved through the GetEnvInfo method
  48578. * @returns a promise
  48579. */
  48580. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48581. private static _OnImageReadyAsync;
  48582. /**
  48583. * Uploads the levels of image data to the GPU.
  48584. * @param texture defines the internal texture to upload to
  48585. * @param imageData defines the array buffer views of image data [mipmap][face]
  48586. * @returns a promise
  48587. */
  48588. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48589. /**
  48590. * Uploads spherical polynomials information to the texture.
  48591. * @param texture defines the texture we are trying to upload the information to
  48592. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48593. */
  48594. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48595. /** @hidden */
  48596. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48597. }
  48598. }
  48599. declare module "babylonjs/Maths/math.vertexFormat" {
  48600. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48601. /**
  48602. * Contains position and normal vectors for a vertex
  48603. */
  48604. export class PositionNormalVertex {
  48605. /** the position of the vertex (defaut: 0,0,0) */
  48606. position: Vector3;
  48607. /** the normal of the vertex (defaut: 0,1,0) */
  48608. normal: Vector3;
  48609. /**
  48610. * Creates a PositionNormalVertex
  48611. * @param position the position of the vertex (defaut: 0,0,0)
  48612. * @param normal the normal of the vertex (defaut: 0,1,0)
  48613. */
  48614. constructor(
  48615. /** the position of the vertex (defaut: 0,0,0) */
  48616. position?: Vector3,
  48617. /** the normal of the vertex (defaut: 0,1,0) */
  48618. normal?: Vector3);
  48619. /**
  48620. * Clones the PositionNormalVertex
  48621. * @returns the cloned PositionNormalVertex
  48622. */
  48623. clone(): PositionNormalVertex;
  48624. }
  48625. /**
  48626. * Contains position, normal and uv vectors for a vertex
  48627. */
  48628. export class PositionNormalTextureVertex {
  48629. /** the position of the vertex (defaut: 0,0,0) */
  48630. position: Vector3;
  48631. /** the normal of the vertex (defaut: 0,1,0) */
  48632. normal: Vector3;
  48633. /** the uv of the vertex (default: 0,0) */
  48634. uv: Vector2;
  48635. /**
  48636. * Creates a PositionNormalTextureVertex
  48637. * @param position the position of the vertex (defaut: 0,0,0)
  48638. * @param normal the normal of the vertex (defaut: 0,1,0)
  48639. * @param uv the uv of the vertex (default: 0,0)
  48640. */
  48641. constructor(
  48642. /** the position of the vertex (defaut: 0,0,0) */
  48643. position?: Vector3,
  48644. /** the normal of the vertex (defaut: 0,1,0) */
  48645. normal?: Vector3,
  48646. /** the uv of the vertex (default: 0,0) */
  48647. uv?: Vector2);
  48648. /**
  48649. * Clones the PositionNormalTextureVertex
  48650. * @returns the cloned PositionNormalTextureVertex
  48651. */
  48652. clone(): PositionNormalTextureVertex;
  48653. }
  48654. }
  48655. declare module "babylonjs/Maths/math" {
  48656. export * from "babylonjs/Maths/math.axis";
  48657. export * from "babylonjs/Maths/math.color";
  48658. export * from "babylonjs/Maths/math.constants";
  48659. export * from "babylonjs/Maths/math.frustum";
  48660. export * from "babylonjs/Maths/math.path";
  48661. export * from "babylonjs/Maths/math.plane";
  48662. export * from "babylonjs/Maths/math.size";
  48663. export * from "babylonjs/Maths/math.vector";
  48664. export * from "babylonjs/Maths/math.vertexFormat";
  48665. export * from "babylonjs/Maths/math.viewport";
  48666. }
  48667. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  48668. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48669. /** @hidden */
  48670. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48671. private _genericAttributeLocation;
  48672. private _varyingLocationCount;
  48673. private _varyingLocationMap;
  48674. private _replacements;
  48675. private _textureCount;
  48676. private _uniforms;
  48677. lineProcessor(line: string): string;
  48678. attributeProcessor(attribute: string): string;
  48679. varyingProcessor(varying: string, isFragment: boolean): string;
  48680. uniformProcessor(uniform: string): string;
  48681. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48682. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48683. }
  48684. }
  48685. declare module "babylonjs/Engines/nativeEngine" {
  48686. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  48687. import { Engine } from "babylonjs/Engines/engine";
  48688. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48689. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48691. import { Effect } from "babylonjs/Materials/effect";
  48692. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48693. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  48694. import { IColor4Like } from "babylonjs/Maths/math.like";
  48695. import { Scene } from "babylonjs/scene";
  48696. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48697. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48698. /**
  48699. * Container for accessors for natively-stored mesh data buffers.
  48700. */
  48701. class NativeDataBuffer extends DataBuffer {
  48702. /**
  48703. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48704. */
  48705. nativeIndexBuffer?: any;
  48706. /**
  48707. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48708. */
  48709. nativeVertexBuffer?: any;
  48710. }
  48711. /** @hidden */
  48712. class NativeTexture extends InternalTexture {
  48713. getInternalTexture(): InternalTexture;
  48714. getViewCount(): number;
  48715. }
  48716. /** @hidden */
  48717. export class NativeEngine extends Engine {
  48718. private readonly _native;
  48719. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48720. private readonly INVALID_HANDLE;
  48721. getHardwareScalingLevel(): number;
  48722. constructor();
  48723. /**
  48724. * Can be used to override the current requestAnimationFrame requester.
  48725. * @hidden
  48726. */
  48727. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48728. /**
  48729. * Override default engine behavior.
  48730. * @param color
  48731. * @param backBuffer
  48732. * @param depth
  48733. * @param stencil
  48734. */
  48735. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48736. /**
  48737. * Gets host document
  48738. * @returns the host document object
  48739. */
  48740. getHostDocument(): Nullable<Document>;
  48741. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48742. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48743. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48744. recordVertexArrayObject(vertexBuffers: {
  48745. [key: string]: VertexBuffer;
  48746. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48747. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48748. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48749. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48750. /**
  48751. * Draw a list of indexed primitives
  48752. * @param fillMode defines the primitive to use
  48753. * @param indexStart defines the starting index
  48754. * @param indexCount defines the number of index to draw
  48755. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48756. */
  48757. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48758. /**
  48759. * Draw a list of unindexed primitives
  48760. * @param fillMode defines the primitive to use
  48761. * @param verticesStart defines the index of first vertex to draw
  48762. * @param verticesCount defines the count of vertices to draw
  48763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48764. */
  48765. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48766. createPipelineContext(): IPipelineContext;
  48767. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48768. /** @hidden */
  48769. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48770. /** @hidden */
  48771. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48772. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48773. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48774. protected _setProgram(program: WebGLProgram): void;
  48775. _releaseEffect(effect: Effect): void;
  48776. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48777. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48778. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48779. bindSamplers(effect: Effect): void;
  48780. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48781. getRenderWidth(useScreen?: boolean): number;
  48782. getRenderHeight(useScreen?: boolean): number;
  48783. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48784. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48785. /**
  48786. * Set the z offset to apply to current rendering
  48787. * @param value defines the offset to apply
  48788. */
  48789. setZOffset(value: number): void;
  48790. /**
  48791. * Gets the current value of the zOffset
  48792. * @returns the current zOffset state
  48793. */
  48794. getZOffset(): number;
  48795. /**
  48796. * Enable or disable depth buffering
  48797. * @param enable defines the state to set
  48798. */
  48799. setDepthBuffer(enable: boolean): void;
  48800. /**
  48801. * Gets a boolean indicating if depth writing is enabled
  48802. * @returns the current depth writing state
  48803. */
  48804. getDepthWrite(): boolean;
  48805. /**
  48806. * Enable or disable depth writing
  48807. * @param enable defines the state to set
  48808. */
  48809. setDepthWrite(enable: boolean): void;
  48810. /**
  48811. * Enable or disable color writing
  48812. * @param enable defines the state to set
  48813. */
  48814. setColorWrite(enable: boolean): void;
  48815. /**
  48816. * Gets a boolean indicating if color writing is enabled
  48817. * @returns the current color writing state
  48818. */
  48819. getColorWrite(): boolean;
  48820. /**
  48821. * Sets alpha constants used by some alpha blending modes
  48822. * @param r defines the red component
  48823. * @param g defines the green component
  48824. * @param b defines the blue component
  48825. * @param a defines the alpha component
  48826. */
  48827. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48828. /**
  48829. * Sets the current alpha mode
  48830. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48831. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48832. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48833. */
  48834. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48835. /**
  48836. * Gets the current alpha mode
  48837. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48838. * @returns the current alpha mode
  48839. */
  48840. getAlphaMode(): number;
  48841. setInt(uniform: WebGLUniformLocation, int: number): void;
  48842. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48843. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48844. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48845. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48846. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48847. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48848. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48849. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48850. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48851. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48852. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48853. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48854. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48855. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48856. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48857. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48858. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48859. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48860. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48861. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48862. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48863. wipeCaches(bruteForce?: boolean): void;
  48864. _createTexture(): WebGLTexture;
  48865. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48866. /**
  48867. * Usually called from BABYLON.Texture.ts.
  48868. * Passed information to create a WebGLTexture
  48869. * @param urlArg defines a value which contains one of the following:
  48870. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48871. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48872. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48873. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48874. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48875. * @param scene needed for loading to the correct scene
  48876. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48877. * @param onLoad optional callback to be called upon successful completion
  48878. * @param onError optional callback to be called upon failure
  48879. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48880. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48881. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48882. * @param forcedExtension defines the extension to use to pick the right loader
  48883. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48884. */
  48885. 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;
  48886. /**
  48887. * Creates a cube texture
  48888. * @param rootUrl defines the url where the files to load is located
  48889. * @param scene defines the current scene
  48890. * @param files defines the list of files to load (1 per face)
  48891. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48892. * @param onLoad defines an optional callback raised when the texture is loaded
  48893. * @param onError defines an optional callback raised if there is an issue to load the texture
  48894. * @param format defines the format of the data
  48895. * @param forcedExtension defines the extension to use to pick the right loader
  48896. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48897. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48898. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48899. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48900. * @returns the cube texture as an InternalTexture
  48901. */
  48902. 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;
  48903. private _getSamplingFilter;
  48904. private static _GetNativeTextureFormat;
  48905. createRenderTargetTexture(size: number | {
  48906. width: number;
  48907. height: number;
  48908. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48909. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48910. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48911. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48912. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48913. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48914. /**
  48915. * Updates a dynamic vertex buffer.
  48916. * @param vertexBuffer the vertex buffer to update
  48917. * @param data the data used to update the vertex buffer
  48918. * @param byteOffset the byte offset of the data (optional)
  48919. * @param byteLength the byte length of the data (optional)
  48920. */
  48921. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48922. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48923. private _updateAnisotropicLevel;
  48924. private _getAddressMode;
  48925. /** @hidden */
  48926. _bindTexture(channel: number, texture: InternalTexture): void;
  48927. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48928. releaseEffects(): void;
  48929. /** @hidden */
  48930. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48931. /** @hidden */
  48932. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48933. /** @hidden */
  48934. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48935. /** @hidden */
  48936. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48937. }
  48938. }
  48939. declare module "babylonjs/Engines/index" {
  48940. export * from "babylonjs/Engines/constants";
  48941. export * from "babylonjs/Engines/engineCapabilities";
  48942. export * from "babylonjs/Engines/instancingAttributeInfo";
  48943. export * from "babylonjs/Engines/thinEngine";
  48944. export * from "babylonjs/Engines/engine";
  48945. export * from "babylonjs/Engines/engineStore";
  48946. export * from "babylonjs/Engines/nullEngine";
  48947. export * from "babylonjs/Engines/Extensions/index";
  48948. export * from "babylonjs/Engines/IPipelineContext";
  48949. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  48950. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48951. export * from "babylonjs/Engines/nativeEngine";
  48952. }
  48953. declare module "babylonjs/Events/clipboardEvents" {
  48954. /**
  48955. * Gather the list of clipboard event types as constants.
  48956. */
  48957. export class ClipboardEventTypes {
  48958. /**
  48959. * The clipboard event is fired when a copy command is active (pressed).
  48960. */
  48961. static readonly COPY: number;
  48962. /**
  48963. * The clipboard event is fired when a cut command is active (pressed).
  48964. */
  48965. static readonly CUT: number;
  48966. /**
  48967. * The clipboard event is fired when a paste command is active (pressed).
  48968. */
  48969. static readonly PASTE: number;
  48970. }
  48971. /**
  48972. * This class is used to store clipboard related info for the onClipboardObservable event.
  48973. */
  48974. export class ClipboardInfo {
  48975. /**
  48976. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48977. */
  48978. type: number;
  48979. /**
  48980. * Defines the related dom event
  48981. */
  48982. event: ClipboardEvent;
  48983. /**
  48984. *Creates an instance of ClipboardInfo.
  48985. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48986. * @param event Defines the related dom event
  48987. */
  48988. constructor(
  48989. /**
  48990. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48991. */
  48992. type: number,
  48993. /**
  48994. * Defines the related dom event
  48995. */
  48996. event: ClipboardEvent);
  48997. /**
  48998. * Get the clipboard event's type from the keycode.
  48999. * @param keyCode Defines the keyCode for the current keyboard event.
  49000. * @return {number}
  49001. */
  49002. static GetTypeFromCharacter(keyCode: number): number;
  49003. }
  49004. }
  49005. declare module "babylonjs/Events/index" {
  49006. export * from "babylonjs/Events/keyboardEvents";
  49007. export * from "babylonjs/Events/pointerEvents";
  49008. export * from "babylonjs/Events/clipboardEvents";
  49009. }
  49010. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49011. import { Scene } from "babylonjs/scene";
  49012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49013. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49014. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49015. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49016. /**
  49017. * Google Daydream controller
  49018. */
  49019. export class DaydreamController extends WebVRController {
  49020. /**
  49021. * Base Url for the controller model.
  49022. */
  49023. static MODEL_BASE_URL: string;
  49024. /**
  49025. * File name for the controller model.
  49026. */
  49027. static MODEL_FILENAME: string;
  49028. /**
  49029. * Gamepad Id prefix used to identify Daydream Controller.
  49030. */
  49031. static readonly GAMEPAD_ID_PREFIX: string;
  49032. /**
  49033. * Creates a new DaydreamController from a gamepad
  49034. * @param vrGamepad the gamepad that the controller should be created from
  49035. */
  49036. constructor(vrGamepad: any);
  49037. /**
  49038. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49039. * @param scene scene in which to add meshes
  49040. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49041. */
  49042. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49043. /**
  49044. * Called once for each button that changed state since the last frame
  49045. * @param buttonIdx Which button index changed
  49046. * @param state New state of the button
  49047. * @param changes Which properties on the state changed since last frame
  49048. */
  49049. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49050. }
  49051. }
  49052. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49053. import { Scene } from "babylonjs/scene";
  49054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49055. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49056. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49057. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49058. /**
  49059. * Gear VR Controller
  49060. */
  49061. export class GearVRController extends WebVRController {
  49062. /**
  49063. * Base Url for the controller model.
  49064. */
  49065. static MODEL_BASE_URL: string;
  49066. /**
  49067. * File name for the controller model.
  49068. */
  49069. static MODEL_FILENAME: string;
  49070. /**
  49071. * Gamepad Id prefix used to identify this controller.
  49072. */
  49073. static readonly GAMEPAD_ID_PREFIX: string;
  49074. private readonly _buttonIndexToObservableNameMap;
  49075. /**
  49076. * Creates a new GearVRController from a gamepad
  49077. * @param vrGamepad the gamepad that the controller should be created from
  49078. */
  49079. constructor(vrGamepad: any);
  49080. /**
  49081. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49082. * @param scene scene in which to add meshes
  49083. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49084. */
  49085. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49086. /**
  49087. * Called once for each button that changed state since the last frame
  49088. * @param buttonIdx Which button index changed
  49089. * @param state New state of the button
  49090. * @param changes Which properties on the state changed since last frame
  49091. */
  49092. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49093. }
  49094. }
  49095. declare module "babylonjs/Gamepads/Controllers/index" {
  49096. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49097. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49098. export * from "babylonjs/Gamepads/Controllers/genericController";
  49099. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49100. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49101. export * from "babylonjs/Gamepads/Controllers/viveController";
  49102. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49103. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49104. }
  49105. declare module "babylonjs/Gamepads/index" {
  49106. export * from "babylonjs/Gamepads/Controllers/index";
  49107. export * from "babylonjs/Gamepads/gamepad";
  49108. export * from "babylonjs/Gamepads/gamepadManager";
  49109. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49110. export * from "babylonjs/Gamepads/xboxGamepad";
  49111. export * from "babylonjs/Gamepads/dualShockGamepad";
  49112. }
  49113. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49114. import { Scene } from "babylonjs/scene";
  49115. import { Vector4 } from "babylonjs/Maths/math.vector";
  49116. import { Color4 } from "babylonjs/Maths/math.color";
  49117. import { Mesh } from "babylonjs/Meshes/mesh";
  49118. import { Nullable } from "babylonjs/types";
  49119. /**
  49120. * Class containing static functions to help procedurally build meshes
  49121. */
  49122. export class PolyhedronBuilder {
  49123. /**
  49124. * Creates a polyhedron mesh
  49125. * * 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
  49126. * * The parameter `size` (positive float, default 1) sets the polygon size
  49127. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49128. * * 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`
  49129. * * 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
  49130. * * 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)`)
  49131. * * 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
  49132. * * 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
  49133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49136. * @param name defines the name of the mesh
  49137. * @param options defines the options used to create the mesh
  49138. * @param scene defines the hosting scene
  49139. * @returns the polyhedron mesh
  49140. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49141. */
  49142. static CreatePolyhedron(name: string, options: {
  49143. type?: number;
  49144. size?: number;
  49145. sizeX?: number;
  49146. sizeY?: number;
  49147. sizeZ?: number;
  49148. custom?: any;
  49149. faceUV?: Vector4[];
  49150. faceColors?: Color4[];
  49151. flat?: boolean;
  49152. updatable?: boolean;
  49153. sideOrientation?: number;
  49154. frontUVs?: Vector4;
  49155. backUVs?: Vector4;
  49156. }, scene?: Nullable<Scene>): Mesh;
  49157. }
  49158. }
  49159. declare module "babylonjs/Gizmos/scaleGizmo" {
  49160. import { Observable } from "babylonjs/Misc/observable";
  49161. import { Nullable } from "babylonjs/types";
  49162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49163. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49164. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49165. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49166. /**
  49167. * Gizmo that enables scaling a mesh along 3 axis
  49168. */
  49169. export class ScaleGizmo extends Gizmo {
  49170. /**
  49171. * Internal gizmo used for interactions on the x axis
  49172. */
  49173. xGizmo: AxisScaleGizmo;
  49174. /**
  49175. * Internal gizmo used for interactions on the y axis
  49176. */
  49177. yGizmo: AxisScaleGizmo;
  49178. /**
  49179. * Internal gizmo used for interactions on the z axis
  49180. */
  49181. zGizmo: AxisScaleGizmo;
  49182. /**
  49183. * Internal gizmo used to scale all axis equally
  49184. */
  49185. uniformScaleGizmo: AxisScaleGizmo;
  49186. private _meshAttached;
  49187. private _updateGizmoRotationToMatchAttachedMesh;
  49188. private _snapDistance;
  49189. private _scaleRatio;
  49190. private _uniformScalingMesh;
  49191. private _octahedron;
  49192. private _sensitivity;
  49193. /** Fires an event when any of it's sub gizmos are dragged */
  49194. onDragStartObservable: Observable<unknown>;
  49195. /** Fires an event when any of it's sub gizmos are released from dragging */
  49196. onDragEndObservable: Observable<unknown>;
  49197. get attachedMesh(): Nullable<AbstractMesh>;
  49198. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49199. /**
  49200. * Creates a ScaleGizmo
  49201. * @param gizmoLayer The utility layer the gizmo will be added to
  49202. */
  49203. constructor(gizmoLayer?: UtilityLayerRenderer);
  49204. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49205. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49206. /**
  49207. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49208. */
  49209. set snapDistance(value: number);
  49210. get snapDistance(): number;
  49211. /**
  49212. * Ratio for the scale of the gizmo (Default: 1)
  49213. */
  49214. set scaleRatio(value: number);
  49215. get scaleRatio(): number;
  49216. /**
  49217. * Sensitivity factor for dragging (Default: 1)
  49218. */
  49219. set sensitivity(value: number);
  49220. get sensitivity(): number;
  49221. /**
  49222. * Disposes of the gizmo
  49223. */
  49224. dispose(): void;
  49225. }
  49226. }
  49227. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  49228. import { Observable } from "babylonjs/Misc/observable";
  49229. import { Nullable } from "babylonjs/types";
  49230. import { Vector3 } from "babylonjs/Maths/math.vector";
  49231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49232. import { Mesh } from "babylonjs/Meshes/mesh";
  49233. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49234. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49235. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49236. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49237. import { Color3 } from "babylonjs/Maths/math.color";
  49238. /**
  49239. * Single axis scale gizmo
  49240. */
  49241. export class AxisScaleGizmo extends Gizmo {
  49242. /**
  49243. * Drag behavior responsible for the gizmos dragging interactions
  49244. */
  49245. dragBehavior: PointerDragBehavior;
  49246. private _pointerObserver;
  49247. /**
  49248. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49249. */
  49250. snapDistance: number;
  49251. /**
  49252. * Event that fires each time the gizmo snaps to a new location.
  49253. * * snapDistance is the the change in distance
  49254. */
  49255. onSnapObservable: Observable<{
  49256. snapDistance: number;
  49257. }>;
  49258. /**
  49259. * If the scaling operation should be done on all axis (default: false)
  49260. */
  49261. uniformScaling: boolean;
  49262. /**
  49263. * Custom sensitivity value for the drag strength
  49264. */
  49265. sensitivity: number;
  49266. private _isEnabled;
  49267. private _parent;
  49268. private _arrow;
  49269. private _coloredMaterial;
  49270. private _hoverMaterial;
  49271. /**
  49272. * Creates an AxisScaleGizmo
  49273. * @param gizmoLayer The utility layer the gizmo will be added to
  49274. * @param dragAxis The axis which the gizmo will be able to scale on
  49275. * @param color The color of the gizmo
  49276. */
  49277. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49278. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49279. /**
  49280. * If the gizmo is enabled
  49281. */
  49282. set isEnabled(value: boolean);
  49283. get isEnabled(): boolean;
  49284. /**
  49285. * Disposes of the gizmo
  49286. */
  49287. dispose(): void;
  49288. /**
  49289. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49290. * @param mesh The mesh to replace the default mesh of the gizmo
  49291. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49292. */
  49293. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49294. }
  49295. }
  49296. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  49297. import { Observable } from "babylonjs/Misc/observable";
  49298. import { Nullable } from "babylonjs/types";
  49299. import { Vector3 } from "babylonjs/Maths/math.vector";
  49300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49301. import { Mesh } from "babylonjs/Meshes/mesh";
  49302. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49303. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49304. import { Color3 } from "babylonjs/Maths/math.color";
  49305. import "babylonjs/Meshes/Builders/boxBuilder";
  49306. /**
  49307. * Bounding box gizmo
  49308. */
  49309. export class BoundingBoxGizmo extends Gizmo {
  49310. private _lineBoundingBox;
  49311. private _rotateSpheresParent;
  49312. private _scaleBoxesParent;
  49313. private _boundingDimensions;
  49314. private _renderObserver;
  49315. private _pointerObserver;
  49316. private _scaleDragSpeed;
  49317. private _tmpQuaternion;
  49318. private _tmpVector;
  49319. private _tmpRotationMatrix;
  49320. /**
  49321. * 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)
  49322. */
  49323. ignoreChildren: boolean;
  49324. /**
  49325. * 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)
  49326. */
  49327. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49328. /**
  49329. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49330. */
  49331. rotationSphereSize: number;
  49332. /**
  49333. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49334. */
  49335. scaleBoxSize: number;
  49336. /**
  49337. * 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)
  49338. */
  49339. fixedDragMeshScreenSize: boolean;
  49340. /**
  49341. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49342. */
  49343. fixedDragMeshScreenSizeDistanceFactor: number;
  49344. /**
  49345. * Fired when a rotation sphere or scale box is dragged
  49346. */
  49347. onDragStartObservable: Observable<{}>;
  49348. /**
  49349. * Fired when a scale box is dragged
  49350. */
  49351. onScaleBoxDragObservable: Observable<{}>;
  49352. /**
  49353. * Fired when a scale box drag is ended
  49354. */
  49355. onScaleBoxDragEndObservable: Observable<{}>;
  49356. /**
  49357. * Fired when a rotation sphere is dragged
  49358. */
  49359. onRotationSphereDragObservable: Observable<{}>;
  49360. /**
  49361. * Fired when a rotation sphere drag is ended
  49362. */
  49363. onRotationSphereDragEndObservable: Observable<{}>;
  49364. /**
  49365. * 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)
  49366. */
  49367. scalePivot: Nullable<Vector3>;
  49368. /**
  49369. * Mesh used as a pivot to rotate the attached mesh
  49370. */
  49371. private _anchorMesh;
  49372. private _existingMeshScale;
  49373. private _dragMesh;
  49374. private pointerDragBehavior;
  49375. private coloredMaterial;
  49376. private hoverColoredMaterial;
  49377. /**
  49378. * Sets the color of the bounding box gizmo
  49379. * @param color the color to set
  49380. */
  49381. setColor(color: Color3): void;
  49382. /**
  49383. * Creates an BoundingBoxGizmo
  49384. * @param gizmoLayer The utility layer the gizmo will be added to
  49385. * @param color The color of the gizmo
  49386. */
  49387. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49388. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49389. private _selectNode;
  49390. /**
  49391. * Updates the bounding box information for the Gizmo
  49392. */
  49393. updateBoundingBox(): void;
  49394. private _updateRotationSpheres;
  49395. private _updateScaleBoxes;
  49396. /**
  49397. * Enables rotation on the specified axis and disables rotation on the others
  49398. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49399. */
  49400. setEnabledRotationAxis(axis: string): void;
  49401. /**
  49402. * Enables/disables scaling
  49403. * @param enable if scaling should be enabled
  49404. */
  49405. setEnabledScaling(enable: boolean): void;
  49406. private _updateDummy;
  49407. /**
  49408. * Enables a pointer drag behavior on the bounding box of the gizmo
  49409. */
  49410. enableDragBehavior(): void;
  49411. /**
  49412. * Disposes of the gizmo
  49413. */
  49414. dispose(): void;
  49415. /**
  49416. * 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)
  49417. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49418. * @returns the bounding box mesh with the passed in mesh as a child
  49419. */
  49420. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49421. /**
  49422. * CustomMeshes are not supported by this gizmo
  49423. * @param mesh The mesh to replace the default mesh of the gizmo
  49424. */
  49425. setCustomMesh(mesh: Mesh): void;
  49426. }
  49427. }
  49428. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  49429. import { Observable } from "babylonjs/Misc/observable";
  49430. import { Nullable } from "babylonjs/types";
  49431. import { Vector3 } from "babylonjs/Maths/math.vector";
  49432. import { Color3 } from "babylonjs/Maths/math.color";
  49433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49434. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49435. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49436. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49437. import "babylonjs/Meshes/Builders/linesBuilder";
  49438. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49439. /**
  49440. * Single plane rotation gizmo
  49441. */
  49442. export class PlaneRotationGizmo extends Gizmo {
  49443. /**
  49444. * Drag behavior responsible for the gizmos dragging interactions
  49445. */
  49446. dragBehavior: PointerDragBehavior;
  49447. private _pointerObserver;
  49448. /**
  49449. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49450. */
  49451. snapDistance: number;
  49452. /**
  49453. * Event that fires each time the gizmo snaps to a new location.
  49454. * * snapDistance is the the change in distance
  49455. */
  49456. onSnapObservable: Observable<{
  49457. snapDistance: number;
  49458. }>;
  49459. private _isEnabled;
  49460. private _parent;
  49461. /**
  49462. * Creates a PlaneRotationGizmo
  49463. * @param gizmoLayer The utility layer the gizmo will be added to
  49464. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49465. * @param color The color of the gizmo
  49466. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49467. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49468. */
  49469. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49470. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49471. /**
  49472. * If the gizmo is enabled
  49473. */
  49474. set isEnabled(value: boolean);
  49475. get isEnabled(): boolean;
  49476. /**
  49477. * Disposes of the gizmo
  49478. */
  49479. dispose(): void;
  49480. }
  49481. }
  49482. declare module "babylonjs/Gizmos/rotationGizmo" {
  49483. import { Observable } from "babylonjs/Misc/observable";
  49484. import { Nullable } from "babylonjs/types";
  49485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49486. import { Mesh } from "babylonjs/Meshes/mesh";
  49487. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49488. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  49489. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49490. /**
  49491. * Gizmo that enables rotating a mesh along 3 axis
  49492. */
  49493. export class RotationGizmo extends Gizmo {
  49494. /**
  49495. * Internal gizmo used for interactions on the x axis
  49496. */
  49497. xGizmo: PlaneRotationGizmo;
  49498. /**
  49499. * Internal gizmo used for interactions on the y axis
  49500. */
  49501. yGizmo: PlaneRotationGizmo;
  49502. /**
  49503. * Internal gizmo used for interactions on the z axis
  49504. */
  49505. zGizmo: PlaneRotationGizmo;
  49506. /** Fires an event when any of it's sub gizmos are dragged */
  49507. onDragStartObservable: Observable<unknown>;
  49508. /** Fires an event when any of it's sub gizmos are released from dragging */
  49509. onDragEndObservable: Observable<unknown>;
  49510. private _meshAttached;
  49511. get attachedMesh(): Nullable<AbstractMesh>;
  49512. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49513. /**
  49514. * Creates a RotationGizmo
  49515. * @param gizmoLayer The utility layer the gizmo will be added to
  49516. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49517. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49518. */
  49519. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49520. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49521. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49522. /**
  49523. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49524. */
  49525. set snapDistance(value: number);
  49526. get snapDistance(): number;
  49527. /**
  49528. * Ratio for the scale of the gizmo (Default: 1)
  49529. */
  49530. set scaleRatio(value: number);
  49531. get scaleRatio(): number;
  49532. /**
  49533. * Disposes of the gizmo
  49534. */
  49535. dispose(): void;
  49536. /**
  49537. * CustomMeshes are not supported by this gizmo
  49538. * @param mesh The mesh to replace the default mesh of the gizmo
  49539. */
  49540. setCustomMesh(mesh: Mesh): void;
  49541. }
  49542. }
  49543. declare module "babylonjs/Gizmos/gizmoManager" {
  49544. import { Observable } from "babylonjs/Misc/observable";
  49545. import { Nullable } from "babylonjs/types";
  49546. import { Scene, IDisposable } from "babylonjs/scene";
  49547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49548. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49549. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49550. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49551. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  49552. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49553. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  49554. /**
  49555. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49556. */
  49557. export class GizmoManager implements IDisposable {
  49558. private scene;
  49559. /**
  49560. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49561. */
  49562. gizmos: {
  49563. positionGizmo: Nullable<PositionGizmo>;
  49564. rotationGizmo: Nullable<RotationGizmo>;
  49565. scaleGizmo: Nullable<ScaleGizmo>;
  49566. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49567. };
  49568. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49569. clearGizmoOnEmptyPointerEvent: boolean;
  49570. /** Fires an event when the manager is attached to a mesh */
  49571. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49572. private _gizmosEnabled;
  49573. private _pointerObserver;
  49574. private _attachedMesh;
  49575. private _boundingBoxColor;
  49576. private _defaultUtilityLayer;
  49577. private _defaultKeepDepthUtilityLayer;
  49578. /**
  49579. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49580. */
  49581. boundingBoxDragBehavior: SixDofDragBehavior;
  49582. /**
  49583. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49584. */
  49585. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49586. /**
  49587. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49588. */
  49589. usePointerToAttachGizmos: boolean;
  49590. /**
  49591. * Utility layer that the bounding box gizmo belongs to
  49592. */
  49593. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49594. /**
  49595. * Utility layer that all gizmos besides bounding box belong to
  49596. */
  49597. get utilityLayer(): UtilityLayerRenderer;
  49598. /**
  49599. * Instatiates a gizmo manager
  49600. * @param scene the scene to overlay the gizmos on top of
  49601. */
  49602. constructor(scene: Scene);
  49603. /**
  49604. * Attaches a set of gizmos to the specified mesh
  49605. * @param mesh The mesh the gizmo's should be attached to
  49606. */
  49607. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49608. /**
  49609. * If the position gizmo is enabled
  49610. */
  49611. set positionGizmoEnabled(value: boolean);
  49612. get positionGizmoEnabled(): boolean;
  49613. /**
  49614. * If the rotation gizmo is enabled
  49615. */
  49616. set rotationGizmoEnabled(value: boolean);
  49617. get rotationGizmoEnabled(): boolean;
  49618. /**
  49619. * If the scale gizmo is enabled
  49620. */
  49621. set scaleGizmoEnabled(value: boolean);
  49622. get scaleGizmoEnabled(): boolean;
  49623. /**
  49624. * If the boundingBox gizmo is enabled
  49625. */
  49626. set boundingBoxGizmoEnabled(value: boolean);
  49627. get boundingBoxGizmoEnabled(): boolean;
  49628. /**
  49629. * Disposes of the gizmo manager
  49630. */
  49631. dispose(): void;
  49632. }
  49633. }
  49634. declare module "babylonjs/Lights/directionalLight" {
  49635. import { Camera } from "babylonjs/Cameras/camera";
  49636. import { Scene } from "babylonjs/scene";
  49637. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49639. import { Light } from "babylonjs/Lights/light";
  49640. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49641. import { Effect } from "babylonjs/Materials/effect";
  49642. /**
  49643. * A directional light is defined by a direction (what a surprise!).
  49644. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49645. * 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.
  49646. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49647. */
  49648. export class DirectionalLight extends ShadowLight {
  49649. private _shadowFrustumSize;
  49650. /**
  49651. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49652. */
  49653. get shadowFrustumSize(): number;
  49654. /**
  49655. * Specifies a fix frustum size for the shadow generation.
  49656. */
  49657. set shadowFrustumSize(value: number);
  49658. private _shadowOrthoScale;
  49659. /**
  49660. * Gets 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. get shadowOrthoScale(): number;
  49665. /**
  49666. * Sets the shadow projection scale against the optimal computed one.
  49667. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49668. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49669. */
  49670. set shadowOrthoScale(value: number);
  49671. /**
  49672. * Automatically compute the projection matrix to best fit (including all the casters)
  49673. * on each frame.
  49674. */
  49675. autoUpdateExtends: boolean;
  49676. private _orthoLeft;
  49677. private _orthoRight;
  49678. private _orthoTop;
  49679. private _orthoBottom;
  49680. /**
  49681. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49682. * The directional light is emitted from everywhere in the given direction.
  49683. * It can cast shadows.
  49684. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49685. * @param name The friendly name of the light
  49686. * @param direction The direction of the light
  49687. * @param scene The scene the light belongs to
  49688. */
  49689. constructor(name: string, direction: Vector3, scene: Scene);
  49690. /**
  49691. * Returns the string "DirectionalLight".
  49692. * @return The class name
  49693. */
  49694. getClassName(): string;
  49695. /**
  49696. * Returns the integer 1.
  49697. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49698. */
  49699. getTypeID(): number;
  49700. /**
  49701. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49702. * Returns the DirectionalLight Shadow projection matrix.
  49703. */
  49704. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49705. /**
  49706. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49707. * Returns the DirectionalLight Shadow projection matrix.
  49708. */
  49709. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49710. /**
  49711. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49712. * Returns the DirectionalLight Shadow projection matrix.
  49713. */
  49714. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49715. protected _buildUniformLayout(): void;
  49716. /**
  49717. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49718. * @param effect The effect to update
  49719. * @param lightIndex The index of the light in the effect to update
  49720. * @returns The directional light
  49721. */
  49722. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49723. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49724. /**
  49725. * Gets the minZ used for shadow according to both the scene and the light.
  49726. *
  49727. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49728. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49729. * @param activeCamera The camera we are returning the min for
  49730. * @returns the depth min z
  49731. */
  49732. getDepthMinZ(activeCamera: Camera): number;
  49733. /**
  49734. * Gets the maxZ used for shadow according to both the scene and the light.
  49735. *
  49736. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49737. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49738. * @param activeCamera The camera we are returning the max for
  49739. * @returns the depth max z
  49740. */
  49741. getDepthMaxZ(activeCamera: Camera): number;
  49742. /**
  49743. * Prepares the list of defines specific to the light type.
  49744. * @param defines the list of defines
  49745. * @param lightIndex defines the index of the light for the effect
  49746. */
  49747. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49748. }
  49749. }
  49750. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  49751. import { Mesh } from "babylonjs/Meshes/mesh";
  49752. /**
  49753. * Class containing static functions to help procedurally build meshes
  49754. */
  49755. export class HemisphereBuilder {
  49756. /**
  49757. * Creates a hemisphere mesh
  49758. * @param name defines the name of the mesh
  49759. * @param options defines the options used to create the mesh
  49760. * @param scene defines the hosting scene
  49761. * @returns the hemisphere mesh
  49762. */
  49763. static CreateHemisphere(name: string, options: {
  49764. segments?: number;
  49765. diameter?: number;
  49766. sideOrientation?: number;
  49767. }, scene: any): Mesh;
  49768. }
  49769. }
  49770. declare module "babylonjs/Lights/spotLight" {
  49771. import { Nullable } from "babylonjs/types";
  49772. import { Scene } from "babylonjs/scene";
  49773. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49775. import { Effect } from "babylonjs/Materials/effect";
  49776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49777. import { Light } from "babylonjs/Lights/light";
  49778. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49779. /**
  49780. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49781. * These values define a cone of light starting from the position, emitting toward the direction.
  49782. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49783. * and the exponent defines the speed of the decay of the light with distance (reach).
  49784. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49785. */
  49786. export class SpotLight extends ShadowLight {
  49787. private _angle;
  49788. private _innerAngle;
  49789. private _cosHalfAngle;
  49790. private _lightAngleScale;
  49791. private _lightAngleOffset;
  49792. /**
  49793. * Gets the cone angle of the spot light in Radians.
  49794. */
  49795. get angle(): number;
  49796. /**
  49797. * Sets the cone angle of the spot light in Radians.
  49798. */
  49799. set angle(value: 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. get innerAngle(): number;
  49806. /**
  49807. * Only used in gltf falloff mode, this defines the angle where
  49808. * the directional falloff will start before cutting at angle which could be seen
  49809. * as outer angle.
  49810. */
  49811. set innerAngle(value: number);
  49812. private _shadowAngleScale;
  49813. /**
  49814. * Allows scaling the angle of the light for shadow generation only.
  49815. */
  49816. get shadowAngleScale(): number;
  49817. /**
  49818. * Allows scaling the angle of the light for shadow generation only.
  49819. */
  49820. set shadowAngleScale(value: number);
  49821. /**
  49822. * The light decay speed with the distance from the emission spot.
  49823. */
  49824. exponent: number;
  49825. private _projectionTextureMatrix;
  49826. /**
  49827. * Allows reading the projecton texture
  49828. */
  49829. get projectionTextureMatrix(): Matrix;
  49830. protected _projectionTextureLightNear: number;
  49831. /**
  49832. * Gets the near clip of the Spotlight for texture projection.
  49833. */
  49834. get projectionTextureLightNear(): number;
  49835. /**
  49836. * Sets the near clip of the Spotlight for texture projection.
  49837. */
  49838. set projectionTextureLightNear(value: number);
  49839. protected _projectionTextureLightFar: number;
  49840. /**
  49841. * Gets the far clip of the Spotlight for texture projection.
  49842. */
  49843. get projectionTextureLightFar(): number;
  49844. /**
  49845. * Sets the far clip of the Spotlight for texture projection.
  49846. */
  49847. set projectionTextureLightFar(value: number);
  49848. protected _projectionTextureUpDirection: Vector3;
  49849. /**
  49850. * Gets the Up vector of the Spotlight for texture projection.
  49851. */
  49852. get projectionTextureUpDirection(): Vector3;
  49853. /**
  49854. * Sets the Up vector of the Spotlight for texture projection.
  49855. */
  49856. set projectionTextureUpDirection(value: Vector3);
  49857. private _projectionTexture;
  49858. /**
  49859. * Gets the projection texture of the light.
  49860. */
  49861. get projectionTexture(): Nullable<BaseTexture>;
  49862. /**
  49863. * Sets the projection texture of the light.
  49864. */
  49865. set projectionTexture(value: Nullable<BaseTexture>);
  49866. private _projectionTextureViewLightDirty;
  49867. private _projectionTextureProjectionLightDirty;
  49868. private _projectionTextureDirty;
  49869. private _projectionTextureViewTargetVector;
  49870. private _projectionTextureViewLightMatrix;
  49871. private _projectionTextureProjectionLightMatrix;
  49872. private _projectionTextureScalingMatrix;
  49873. /**
  49874. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49875. * It can cast shadows.
  49876. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49877. * @param name The light friendly name
  49878. * @param position The position of the spot light in the scene
  49879. * @param direction The direction of the light in the scene
  49880. * @param angle The cone angle of the light in Radians
  49881. * @param exponent The light decay speed with the distance from the emission spot
  49882. * @param scene The scene the lights belongs to
  49883. */
  49884. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49885. /**
  49886. * Returns the string "SpotLight".
  49887. * @returns the class name
  49888. */
  49889. getClassName(): string;
  49890. /**
  49891. * Returns the integer 2.
  49892. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49893. */
  49894. getTypeID(): number;
  49895. /**
  49896. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49897. */
  49898. protected _setDirection(value: Vector3): void;
  49899. /**
  49900. * Overrides the position setter to recompute the projection texture view light Matrix.
  49901. */
  49902. protected _setPosition(value: Vector3): void;
  49903. /**
  49904. * 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.
  49905. * Returns the SpotLight.
  49906. */
  49907. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49908. protected _computeProjectionTextureViewLightMatrix(): void;
  49909. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49910. /**
  49911. * Main function for light texture projection matrix computing.
  49912. */
  49913. protected _computeProjectionTextureMatrix(): void;
  49914. protected _buildUniformLayout(): void;
  49915. private _computeAngleValues;
  49916. /**
  49917. * Sets the passed Effect "effect" with the Light textures.
  49918. * @param effect The effect to update
  49919. * @param lightIndex The index of the light in the effect to update
  49920. * @returns The light
  49921. */
  49922. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49923. /**
  49924. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49925. * @param effect The effect to update
  49926. * @param lightIndex The index of the light in the effect to update
  49927. * @returns The spot light
  49928. */
  49929. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49930. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49931. /**
  49932. * Disposes the light and the associated resources.
  49933. */
  49934. dispose(): void;
  49935. /**
  49936. * Prepares the list of defines specific to the light type.
  49937. * @param defines the list of defines
  49938. * @param lightIndex defines the index of the light for the effect
  49939. */
  49940. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49941. }
  49942. }
  49943. declare module "babylonjs/Gizmos/lightGizmo" {
  49944. import { Nullable } from "babylonjs/types";
  49945. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49946. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49947. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  49948. import { Light } from "babylonjs/Lights/light";
  49949. /**
  49950. * Gizmo that enables viewing a light
  49951. */
  49952. export class LightGizmo extends Gizmo {
  49953. private _lightMesh;
  49954. private _material;
  49955. private _cachedPosition;
  49956. private _cachedForward;
  49957. private _attachedMeshParent;
  49958. /**
  49959. * Creates a LightGizmo
  49960. * @param gizmoLayer The utility layer the gizmo will be added to
  49961. */
  49962. constructor(gizmoLayer?: UtilityLayerRenderer);
  49963. private _light;
  49964. /**
  49965. * The light that the gizmo is attached to
  49966. */
  49967. set light(light: Nullable<Light>);
  49968. get light(): Nullable<Light>;
  49969. /**
  49970. * Gets the material used to render the light gizmo
  49971. */
  49972. get material(): StandardMaterial;
  49973. /**
  49974. * @hidden
  49975. * Updates the gizmo to match the attached mesh's position/rotation
  49976. */
  49977. protected _update(): void;
  49978. private static _Scale;
  49979. /**
  49980. * Creates the lines for a light mesh
  49981. */
  49982. private static _CreateLightLines;
  49983. /**
  49984. * Disposes of the light gizmo
  49985. */
  49986. dispose(): void;
  49987. private static _CreateHemisphericLightMesh;
  49988. private static _CreatePointLightMesh;
  49989. private static _CreateSpotLightMesh;
  49990. private static _CreateDirectionalLightMesh;
  49991. }
  49992. }
  49993. declare module "babylonjs/Gizmos/index" {
  49994. export * from "babylonjs/Gizmos/axisDragGizmo";
  49995. export * from "babylonjs/Gizmos/axisScaleGizmo";
  49996. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  49997. export * from "babylonjs/Gizmos/gizmo";
  49998. export * from "babylonjs/Gizmos/gizmoManager";
  49999. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50000. export * from "babylonjs/Gizmos/positionGizmo";
  50001. export * from "babylonjs/Gizmos/rotationGizmo";
  50002. export * from "babylonjs/Gizmos/scaleGizmo";
  50003. export * from "babylonjs/Gizmos/lightGizmo";
  50004. export * from "babylonjs/Gizmos/planeDragGizmo";
  50005. }
  50006. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50007. /** @hidden */
  50008. export var backgroundFragmentDeclaration: {
  50009. name: string;
  50010. shader: string;
  50011. };
  50012. }
  50013. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50014. /** @hidden */
  50015. export var backgroundUboDeclaration: {
  50016. name: string;
  50017. shader: string;
  50018. };
  50019. }
  50020. declare module "babylonjs/Shaders/background.fragment" {
  50021. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50022. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50023. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50024. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50025. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50026. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50027. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50028. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50029. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50030. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50031. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50032. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50033. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50034. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50035. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50036. /** @hidden */
  50037. export var backgroundPixelShader: {
  50038. name: string;
  50039. shader: string;
  50040. };
  50041. }
  50042. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50043. /** @hidden */
  50044. export var backgroundVertexDeclaration: {
  50045. name: string;
  50046. shader: string;
  50047. };
  50048. }
  50049. declare module "babylonjs/Shaders/background.vertex" {
  50050. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50051. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50052. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50053. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50054. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50055. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50056. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50057. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50058. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50059. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50060. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50061. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50062. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50063. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50064. /** @hidden */
  50065. export var backgroundVertexShader: {
  50066. name: string;
  50067. shader: string;
  50068. };
  50069. }
  50070. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50071. import { Nullable, int, float } from "babylonjs/types";
  50072. import { Scene } from "babylonjs/scene";
  50073. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50076. import { Mesh } from "babylonjs/Meshes/mesh";
  50077. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50078. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50079. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50081. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50082. import { Color3 } from "babylonjs/Maths/math.color";
  50083. import "babylonjs/Shaders/background.fragment";
  50084. import "babylonjs/Shaders/background.vertex";
  50085. /**
  50086. * Background material used to create an efficient environement around your scene.
  50087. */
  50088. export class BackgroundMaterial extends PushMaterial {
  50089. /**
  50090. * Standard reflectance value at parallel view angle.
  50091. */
  50092. static StandardReflectance0: number;
  50093. /**
  50094. * Standard reflectance value at grazing angle.
  50095. */
  50096. static StandardReflectance90: number;
  50097. protected _primaryColor: Color3;
  50098. /**
  50099. * Key light Color (multiply against the environement texture)
  50100. */
  50101. primaryColor: Color3;
  50102. protected __perceptualColor: Nullable<Color3>;
  50103. /**
  50104. * Experimental Internal Use Only.
  50105. *
  50106. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50107. * This acts as a helper to set the primary color to a more "human friendly" value.
  50108. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50109. * output color as close as possible from the chosen value.
  50110. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50111. * part of lighting setup.)
  50112. */
  50113. get _perceptualColor(): Nullable<Color3>;
  50114. set _perceptualColor(value: Nullable<Color3>);
  50115. protected _primaryColorShadowLevel: float;
  50116. /**
  50117. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50118. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50119. */
  50120. get primaryColorShadowLevel(): float;
  50121. set primaryColorShadowLevel(value: float);
  50122. protected _primaryColorHighlightLevel: float;
  50123. /**
  50124. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50125. * The primary color is used at the level chosen to define what the white area would look.
  50126. */
  50127. get primaryColorHighlightLevel(): float;
  50128. set primaryColorHighlightLevel(value: float);
  50129. protected _reflectionTexture: Nullable<BaseTexture>;
  50130. /**
  50131. * Reflection Texture used in the material.
  50132. * Should be author in a specific way for the best result (refer to the documentation).
  50133. */
  50134. reflectionTexture: Nullable<BaseTexture>;
  50135. protected _reflectionBlur: float;
  50136. /**
  50137. * Reflection Texture level of blur.
  50138. *
  50139. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50140. * texture twice.
  50141. */
  50142. reflectionBlur: float;
  50143. protected _diffuseTexture: Nullable<BaseTexture>;
  50144. /**
  50145. * Diffuse Texture used in the material.
  50146. * Should be author in a specific way for the best result (refer to the documentation).
  50147. */
  50148. diffuseTexture: Nullable<BaseTexture>;
  50149. protected _shadowLights: Nullable<IShadowLight[]>;
  50150. /**
  50151. * Specify the list of lights casting shadow on the material.
  50152. * All scene shadow lights will be included if null.
  50153. */
  50154. shadowLights: Nullable<IShadowLight[]>;
  50155. protected _shadowLevel: float;
  50156. /**
  50157. * Helps adjusting the shadow to a softer level if required.
  50158. * 0 means black shadows and 1 means no shadows.
  50159. */
  50160. shadowLevel: float;
  50161. protected _sceneCenter: Vector3;
  50162. /**
  50163. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50164. * It is usually zero but might be interesting to modify according to your setup.
  50165. */
  50166. sceneCenter: Vector3;
  50167. protected _opacityFresnel: boolean;
  50168. /**
  50169. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50170. * This helps ensuring a nice transition when the camera goes under the ground.
  50171. */
  50172. opacityFresnel: boolean;
  50173. protected _reflectionFresnel: boolean;
  50174. /**
  50175. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50176. * This helps adding a mirror texture on the ground.
  50177. */
  50178. reflectionFresnel: boolean;
  50179. protected _reflectionFalloffDistance: number;
  50180. /**
  50181. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50182. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50183. */
  50184. reflectionFalloffDistance: number;
  50185. protected _reflectionAmount: number;
  50186. /**
  50187. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50188. */
  50189. reflectionAmount: number;
  50190. protected _reflectionReflectance0: number;
  50191. /**
  50192. * This specifies the weight of the reflection at grazing angle.
  50193. */
  50194. reflectionReflectance0: number;
  50195. protected _reflectionReflectance90: number;
  50196. /**
  50197. * This specifies the weight of the reflection at a perpendicular point of view.
  50198. */
  50199. reflectionReflectance90: number;
  50200. /**
  50201. * Sets the reflection reflectance fresnel values according to the default standard
  50202. * empirically know to work well :-)
  50203. */
  50204. set reflectionStandardFresnelWeight(value: number);
  50205. protected _useRGBColor: boolean;
  50206. /**
  50207. * Helps to directly use the maps channels instead of their level.
  50208. */
  50209. useRGBColor: boolean;
  50210. protected _enableNoise: boolean;
  50211. /**
  50212. * This helps reducing the banding effect that could occur on the background.
  50213. */
  50214. enableNoise: boolean;
  50215. /**
  50216. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50217. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50218. * Recommended to be keep at 1.0 except for special cases.
  50219. */
  50220. get fovMultiplier(): number;
  50221. set fovMultiplier(value: number);
  50222. private _fovMultiplier;
  50223. /**
  50224. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50225. */
  50226. useEquirectangularFOV: boolean;
  50227. private _maxSimultaneousLights;
  50228. /**
  50229. * Number of Simultaneous lights allowed on the material.
  50230. */
  50231. maxSimultaneousLights: int;
  50232. /**
  50233. * Default configuration related to image processing available in the Background Material.
  50234. */
  50235. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50236. /**
  50237. * Keep track of the image processing observer to allow dispose and replace.
  50238. */
  50239. private _imageProcessingObserver;
  50240. /**
  50241. * Attaches a new image processing configuration to the PBR Material.
  50242. * @param configuration (if null the scene configuration will be use)
  50243. */
  50244. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50245. /**
  50246. * Gets the image processing configuration used either in this material.
  50247. */
  50248. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50249. /**
  50250. * Sets the Default image processing configuration used either in the this material.
  50251. *
  50252. * If sets to null, the scene one is in use.
  50253. */
  50254. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50255. /**
  50256. * Gets wether the color curves effect is enabled.
  50257. */
  50258. get cameraColorCurvesEnabled(): boolean;
  50259. /**
  50260. * Sets wether the color curves effect is enabled.
  50261. */
  50262. set cameraColorCurvesEnabled(value: boolean);
  50263. /**
  50264. * Gets wether the color grading effect is enabled.
  50265. */
  50266. get cameraColorGradingEnabled(): boolean;
  50267. /**
  50268. * Gets wether the color grading effect is enabled.
  50269. */
  50270. set cameraColorGradingEnabled(value: boolean);
  50271. /**
  50272. * Gets wether tonemapping is enabled or not.
  50273. */
  50274. get cameraToneMappingEnabled(): boolean;
  50275. /**
  50276. * Sets wether tonemapping is enabled or not
  50277. */
  50278. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): float;
  50285. /**
  50286. * The camera exposure used on this material.
  50287. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50288. * This corresponds to a photographic exposure.
  50289. */
  50290. set cameraExposure(value: float);
  50291. /**
  50292. * Gets The camera contrast used on this material.
  50293. */
  50294. get cameraContrast(): float;
  50295. /**
  50296. * Sets The camera contrast used on this material.
  50297. */
  50298. set cameraContrast(value: float);
  50299. /**
  50300. * Gets the Color Grading 2D Lookup Texture.
  50301. */
  50302. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50303. /**
  50304. * Sets the Color Grading 2D Lookup Texture.
  50305. */
  50306. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50307. /**
  50308. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50309. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50310. * 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;
  50311. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50312. */
  50313. get cameraColorCurves(): Nullable<ColorCurves>;
  50314. /**
  50315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50317. * 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;
  50318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50319. */
  50320. set cameraColorCurves(value: Nullable<ColorCurves>);
  50321. /**
  50322. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50323. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50324. */
  50325. switchToBGR: boolean;
  50326. private _renderTargets;
  50327. private _reflectionControls;
  50328. private _white;
  50329. private _primaryShadowColor;
  50330. private _primaryHighlightColor;
  50331. /**
  50332. * Instantiates a Background Material in the given scene
  50333. * @param name The friendly name of the material
  50334. * @param scene The scene to add the material to
  50335. */
  50336. constructor(name: string, scene: Scene);
  50337. /**
  50338. * Gets a boolean indicating that current material needs to register RTT
  50339. */
  50340. get hasRenderTargetTextures(): boolean;
  50341. /**
  50342. * The entire material has been created in order to prevent overdraw.
  50343. * @returns false
  50344. */
  50345. needAlphaTesting(): boolean;
  50346. /**
  50347. * The entire material has been created in order to prevent overdraw.
  50348. * @returns true if blending is enable
  50349. */
  50350. needAlphaBlending(): boolean;
  50351. /**
  50352. * Checks wether the material is ready to be rendered for a given mesh.
  50353. * @param mesh The mesh to render
  50354. * @param subMesh The submesh to check against
  50355. * @param useInstances Specify wether or not the material is used with instances
  50356. * @returns true if all the dependencies are ready (Textures, Effects...)
  50357. */
  50358. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50359. /**
  50360. * Compute the primary color according to the chosen perceptual color.
  50361. */
  50362. private _computePrimaryColorFromPerceptualColor;
  50363. /**
  50364. * Compute the highlights and shadow colors according to their chosen levels.
  50365. */
  50366. private _computePrimaryColors;
  50367. /**
  50368. * Build the uniform buffer used in the material.
  50369. */
  50370. buildUniformLayout(): void;
  50371. /**
  50372. * Unbind the material.
  50373. */
  50374. unbind(): void;
  50375. /**
  50376. * Bind only the world matrix to the material.
  50377. * @param world The world matrix to bind.
  50378. */
  50379. bindOnlyWorldMatrix(world: Matrix): void;
  50380. /**
  50381. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50382. * @param world The world matrix to bind.
  50383. * @param subMesh The submesh to bind for.
  50384. */
  50385. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50386. /**
  50387. * Checks to see if a texture is used in the material.
  50388. * @param texture - Base texture to use.
  50389. * @returns - Boolean specifying if a texture is used in the material.
  50390. */
  50391. hasTexture(texture: BaseTexture): boolean;
  50392. /**
  50393. * Dispose the material.
  50394. * @param forceDisposeEffect Force disposal of the associated effect.
  50395. * @param forceDisposeTextures Force disposal of the associated textures.
  50396. */
  50397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50398. /**
  50399. * Clones the material.
  50400. * @param name The cloned name.
  50401. * @returns The cloned material.
  50402. */
  50403. clone(name: string): BackgroundMaterial;
  50404. /**
  50405. * Serializes the current material to its JSON representation.
  50406. * @returns The JSON representation.
  50407. */
  50408. serialize(): any;
  50409. /**
  50410. * Gets the class name of the material
  50411. * @returns "BackgroundMaterial"
  50412. */
  50413. getClassName(): string;
  50414. /**
  50415. * Parse a JSON input to create back a background material.
  50416. * @param source The JSON data to parse
  50417. * @param scene The scene to create the parsed material in
  50418. * @param rootUrl The root url of the assets the material depends upon
  50419. * @returns the instantiated BackgroundMaterial.
  50420. */
  50421. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50422. }
  50423. }
  50424. declare module "babylonjs/Helpers/environmentHelper" {
  50425. import { Observable } from "babylonjs/Misc/observable";
  50426. import { Nullable } from "babylonjs/types";
  50427. import { Scene } from "babylonjs/scene";
  50428. import { Vector3 } from "babylonjs/Maths/math.vector";
  50429. import { Color3 } from "babylonjs/Maths/math.color";
  50430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50431. import { Mesh } from "babylonjs/Meshes/mesh";
  50432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50433. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  50434. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50435. import "babylonjs/Meshes/Builders/planeBuilder";
  50436. import "babylonjs/Meshes/Builders/boxBuilder";
  50437. /**
  50438. * Represents the different options available during the creation of
  50439. * a Environment helper.
  50440. *
  50441. * This can control the default ground, skybox and image processing setup of your scene.
  50442. */
  50443. export interface IEnvironmentHelperOptions {
  50444. /**
  50445. * Specifies wether or not to create a ground.
  50446. * True by default.
  50447. */
  50448. createGround: boolean;
  50449. /**
  50450. * Specifies the ground size.
  50451. * 15 by default.
  50452. */
  50453. groundSize: number;
  50454. /**
  50455. * The texture used on the ground for the main color.
  50456. * Comes from the BabylonJS CDN by default.
  50457. *
  50458. * Remarks: Can be either a texture or a url.
  50459. */
  50460. groundTexture: string | BaseTexture;
  50461. /**
  50462. * The color mixed in the ground texture by default.
  50463. * BabylonJS clearColor by default.
  50464. */
  50465. groundColor: Color3;
  50466. /**
  50467. * Specifies the ground opacity.
  50468. * 1 by default.
  50469. */
  50470. groundOpacity: number;
  50471. /**
  50472. * Enables the ground to receive shadows.
  50473. * True by default.
  50474. */
  50475. enableGroundShadow: boolean;
  50476. /**
  50477. * Helps preventing the shadow to be fully black on the ground.
  50478. * 0.5 by default.
  50479. */
  50480. groundShadowLevel: number;
  50481. /**
  50482. * Creates a mirror texture attach to the ground.
  50483. * false by default.
  50484. */
  50485. enableGroundMirror: boolean;
  50486. /**
  50487. * Specifies the ground mirror size ratio.
  50488. * 0.3 by default as the default kernel is 64.
  50489. */
  50490. groundMirrorSizeRatio: number;
  50491. /**
  50492. * Specifies the ground mirror blur kernel size.
  50493. * 64 by default.
  50494. */
  50495. groundMirrorBlurKernel: number;
  50496. /**
  50497. * Specifies the ground mirror visibility amount.
  50498. * 1 by default
  50499. */
  50500. groundMirrorAmount: number;
  50501. /**
  50502. * Specifies the ground mirror reflectance weight.
  50503. * This uses the standard weight of the background material to setup the fresnel effect
  50504. * of the mirror.
  50505. * 1 by default.
  50506. */
  50507. groundMirrorFresnelWeight: number;
  50508. /**
  50509. * Specifies the ground mirror Falloff distance.
  50510. * This can helps reducing the size of the reflection.
  50511. * 0 by Default.
  50512. */
  50513. groundMirrorFallOffDistance: number;
  50514. /**
  50515. * Specifies the ground mirror texture type.
  50516. * Unsigned Int by Default.
  50517. */
  50518. groundMirrorTextureType: number;
  50519. /**
  50520. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50521. * the shown objects.
  50522. */
  50523. groundYBias: number;
  50524. /**
  50525. * Specifies wether or not to create a skybox.
  50526. * True by default.
  50527. */
  50528. createSkybox: boolean;
  50529. /**
  50530. * Specifies the skybox size.
  50531. * 20 by default.
  50532. */
  50533. skyboxSize: number;
  50534. /**
  50535. * The texture used on the skybox for the main color.
  50536. * Comes from the BabylonJS CDN by default.
  50537. *
  50538. * Remarks: Can be either a texture or a url.
  50539. */
  50540. skyboxTexture: string | BaseTexture;
  50541. /**
  50542. * The color mixed in the skybox texture by default.
  50543. * BabylonJS clearColor by default.
  50544. */
  50545. skyboxColor: Color3;
  50546. /**
  50547. * The background rotation around the Y axis of the scene.
  50548. * This helps aligning the key lights of your scene with the background.
  50549. * 0 by default.
  50550. */
  50551. backgroundYRotation: number;
  50552. /**
  50553. * Compute automatically the size of the elements to best fit with the scene.
  50554. */
  50555. sizeAuto: boolean;
  50556. /**
  50557. * Default position of the rootMesh if autoSize is not true.
  50558. */
  50559. rootPosition: Vector3;
  50560. /**
  50561. * Sets up the image processing in the scene.
  50562. * true by default.
  50563. */
  50564. setupImageProcessing: boolean;
  50565. /**
  50566. * The texture used as your environment texture in the scene.
  50567. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50568. *
  50569. * Remarks: Can be either a texture or a url.
  50570. */
  50571. environmentTexture: string | BaseTexture;
  50572. /**
  50573. * The value of the exposure to apply to the scene.
  50574. * 0.6 by default if setupImageProcessing is true.
  50575. */
  50576. cameraExposure: number;
  50577. /**
  50578. * The value of the contrast to apply to the scene.
  50579. * 1.6 by default if setupImageProcessing is true.
  50580. */
  50581. cameraContrast: number;
  50582. /**
  50583. * Specifies wether or not tonemapping should be enabled in the scene.
  50584. * true by default if setupImageProcessing is true.
  50585. */
  50586. toneMappingEnabled: boolean;
  50587. }
  50588. /**
  50589. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50590. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50591. * It also helps with the default setup of your imageProcessing configuration.
  50592. */
  50593. export class EnvironmentHelper {
  50594. /**
  50595. * Default ground texture URL.
  50596. */
  50597. private static _groundTextureCDNUrl;
  50598. /**
  50599. * Default skybox texture URL.
  50600. */
  50601. private static _skyboxTextureCDNUrl;
  50602. /**
  50603. * Default environment texture URL.
  50604. */
  50605. private static _environmentTextureCDNUrl;
  50606. /**
  50607. * Creates the default options for the helper.
  50608. */
  50609. private static _getDefaultOptions;
  50610. private _rootMesh;
  50611. /**
  50612. * Gets the root mesh created by the helper.
  50613. */
  50614. get rootMesh(): Mesh;
  50615. private _skybox;
  50616. /**
  50617. * Gets the skybox created by the helper.
  50618. */
  50619. get skybox(): Nullable<Mesh>;
  50620. private _skyboxTexture;
  50621. /**
  50622. * Gets the skybox texture created by the helper.
  50623. */
  50624. get skyboxTexture(): Nullable<BaseTexture>;
  50625. private _skyboxMaterial;
  50626. /**
  50627. * Gets the skybox material created by the helper.
  50628. */
  50629. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50630. private _ground;
  50631. /**
  50632. * Gets the ground mesh created by the helper.
  50633. */
  50634. get ground(): Nullable<Mesh>;
  50635. private _groundTexture;
  50636. /**
  50637. * Gets the ground texture created by the helper.
  50638. */
  50639. get groundTexture(): Nullable<BaseTexture>;
  50640. private _groundMirror;
  50641. /**
  50642. * Gets the ground mirror created by the helper.
  50643. */
  50644. get groundMirror(): Nullable<MirrorTexture>;
  50645. /**
  50646. * Gets the ground mirror render list to helps pushing the meshes
  50647. * you wish in the ground reflection.
  50648. */
  50649. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50650. private _groundMaterial;
  50651. /**
  50652. * Gets the ground material created by the helper.
  50653. */
  50654. get groundMaterial(): Nullable<BackgroundMaterial>;
  50655. /**
  50656. * Stores the creation options.
  50657. */
  50658. private readonly _scene;
  50659. private _options;
  50660. /**
  50661. * This observable will be notified with any error during the creation of the environment,
  50662. * mainly texture creation errors.
  50663. */
  50664. onErrorObservable: Observable<{
  50665. message?: string;
  50666. exception?: any;
  50667. }>;
  50668. /**
  50669. * constructor
  50670. * @param options Defines the options we want to customize the helper
  50671. * @param scene The scene to add the material to
  50672. */
  50673. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50674. /**
  50675. * Updates the background according to the new options
  50676. * @param options
  50677. */
  50678. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50679. /**
  50680. * Sets the primary color of all the available elements.
  50681. * @param color the main color to affect to the ground and the background
  50682. */
  50683. setMainColor(color: Color3): void;
  50684. /**
  50685. * Setup the image processing according to the specified options.
  50686. */
  50687. private _setupImageProcessing;
  50688. /**
  50689. * Setup the environment texture according to the specified options.
  50690. */
  50691. private _setupEnvironmentTexture;
  50692. /**
  50693. * Setup the background according to the specified options.
  50694. */
  50695. private _setupBackground;
  50696. /**
  50697. * Get the scene sizes according to the setup.
  50698. */
  50699. private _getSceneSize;
  50700. /**
  50701. * Setup the ground according to the specified options.
  50702. */
  50703. private _setupGround;
  50704. /**
  50705. * Setup the ground material according to the specified options.
  50706. */
  50707. private _setupGroundMaterial;
  50708. /**
  50709. * Setup the ground diffuse texture according to the specified options.
  50710. */
  50711. private _setupGroundDiffuseTexture;
  50712. /**
  50713. * Setup the ground mirror texture according to the specified options.
  50714. */
  50715. private _setupGroundMirrorTexture;
  50716. /**
  50717. * Setup the ground to receive the mirror texture.
  50718. */
  50719. private _setupMirrorInGroundMaterial;
  50720. /**
  50721. * Setup the skybox according to the specified options.
  50722. */
  50723. private _setupSkybox;
  50724. /**
  50725. * Setup the skybox material according to the specified options.
  50726. */
  50727. private _setupSkyboxMaterial;
  50728. /**
  50729. * Setup the skybox reflection texture according to the specified options.
  50730. */
  50731. private _setupSkyboxReflectionTexture;
  50732. private _errorHandler;
  50733. /**
  50734. * Dispose all the elements created by the Helper.
  50735. */
  50736. dispose(): void;
  50737. }
  50738. }
  50739. declare module "babylonjs/Helpers/photoDome" {
  50740. import { Observable } from "babylonjs/Misc/observable";
  50741. import { Nullable } from "babylonjs/types";
  50742. import { Scene } from "babylonjs/scene";
  50743. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50744. import { Mesh } from "babylonjs/Meshes/mesh";
  50745. import { Texture } from "babylonjs/Materials/Textures/texture";
  50746. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50747. import "babylonjs/Meshes/Builders/sphereBuilder";
  50748. /**
  50749. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50750. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50751. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50752. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50753. */
  50754. export class PhotoDome extends TransformNode {
  50755. /**
  50756. * Define the image as a Monoscopic panoramic 360 image.
  50757. */
  50758. static readonly MODE_MONOSCOPIC: number;
  50759. /**
  50760. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50761. */
  50762. static readonly MODE_TOPBOTTOM: number;
  50763. /**
  50764. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50765. */
  50766. static readonly MODE_SIDEBYSIDE: number;
  50767. private _useDirectMapping;
  50768. /**
  50769. * The texture being displayed on the sphere
  50770. */
  50771. protected _photoTexture: Texture;
  50772. /**
  50773. * Gets or sets the texture being displayed on the sphere
  50774. */
  50775. get photoTexture(): Texture;
  50776. set photoTexture(value: Texture);
  50777. /**
  50778. * Observable raised when an error occured while loading the 360 image
  50779. */
  50780. onLoadErrorObservable: Observable<string>;
  50781. /**
  50782. * The skybox material
  50783. */
  50784. protected _material: BackgroundMaterial;
  50785. /**
  50786. * The surface used for the skybox
  50787. */
  50788. protected _mesh: Mesh;
  50789. /**
  50790. * Gets the mesh used for the skybox.
  50791. */
  50792. get mesh(): Mesh;
  50793. /**
  50794. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50795. * Also see the options.resolution property.
  50796. */
  50797. get fovMultiplier(): number;
  50798. set fovMultiplier(value: number);
  50799. private _imageMode;
  50800. /**
  50801. * Gets or set the current video mode for the video. It can be:
  50802. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50803. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50804. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50805. */
  50806. get imageMode(): number;
  50807. set imageMode(value: number);
  50808. /**
  50809. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50810. * @param name Element's name, child elements will append suffixes for their own names.
  50811. * @param urlsOfPhoto defines the url of the photo to display
  50812. * @param options defines an object containing optional or exposed sub element properties
  50813. * @param onError defines a callback called when an error occured while loading the texture
  50814. */
  50815. constructor(name: string, urlOfPhoto: string, options: {
  50816. resolution?: number;
  50817. size?: number;
  50818. useDirectMapping?: boolean;
  50819. faceForward?: boolean;
  50820. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50821. private _onBeforeCameraRenderObserver;
  50822. private _changeImageMode;
  50823. /**
  50824. * Releases resources associated with this node.
  50825. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50826. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50827. */
  50828. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50829. }
  50830. }
  50831. declare module "babylonjs/Misc/rgbdTextureTools" {
  50832. import "babylonjs/Shaders/rgbdDecode.fragment";
  50833. import "babylonjs/Engines/Extensions/engine.renderTarget";
  50834. import { Texture } from "babylonjs/Materials/Textures/texture";
  50835. /**
  50836. * Class used to host RGBD texture specific utilities
  50837. */
  50838. export class RGBDTextureTools {
  50839. /**
  50840. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50841. * @param texture the texture to expand.
  50842. */
  50843. static ExpandRGBDTexture(texture: Texture): void;
  50844. }
  50845. }
  50846. declare module "babylonjs/Misc/brdfTextureTools" {
  50847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50848. import { Scene } from "babylonjs/scene";
  50849. /**
  50850. * Class used to host texture specific utilities
  50851. */
  50852. export class BRDFTextureTools {
  50853. /**
  50854. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50855. * @param scene defines the hosting scene
  50856. * @returns the environment BRDF texture
  50857. */
  50858. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50859. private static _environmentBRDFBase64Texture;
  50860. }
  50861. }
  50862. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  50863. import { Nullable } from "babylonjs/types";
  50864. import { Color3 } from "babylonjs/Maths/math.color";
  50865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50866. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50867. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50868. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50869. import { Engine } from "babylonjs/Engines/engine";
  50870. import { Scene } from "babylonjs/scene";
  50871. /**
  50872. * @hidden
  50873. */
  50874. export interface IMaterialClearCoatDefines {
  50875. CLEARCOAT: boolean;
  50876. CLEARCOAT_DEFAULTIOR: boolean;
  50877. CLEARCOAT_TEXTURE: boolean;
  50878. CLEARCOAT_TEXTUREDIRECTUV: number;
  50879. CLEARCOAT_BUMP: boolean;
  50880. CLEARCOAT_BUMPDIRECTUV: number;
  50881. CLEARCOAT_TINT: boolean;
  50882. CLEARCOAT_TINT_TEXTURE: boolean;
  50883. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50884. /** @hidden */
  50885. _areTexturesDirty: boolean;
  50886. }
  50887. /**
  50888. * Define the code related to the clear coat parameters of the pbr material.
  50889. */
  50890. export class PBRClearCoatConfiguration {
  50891. /**
  50892. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50893. * The default fits with a polyurethane material.
  50894. */
  50895. private static readonly _DefaultIndexOfRefraction;
  50896. private _isEnabled;
  50897. /**
  50898. * Defines if the clear coat is enabled in the material.
  50899. */
  50900. isEnabled: boolean;
  50901. /**
  50902. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50903. */
  50904. intensity: number;
  50905. /**
  50906. * Defines the clear coat layer roughness.
  50907. */
  50908. roughness: number;
  50909. private _indexOfRefraction;
  50910. /**
  50911. * Defines the index of refraction of the clear coat.
  50912. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50913. * The default fits with a polyurethane material.
  50914. * Changing the default value is more performance intensive.
  50915. */
  50916. indexOfRefraction: number;
  50917. private _texture;
  50918. /**
  50919. * Stores the clear coat values in a texture.
  50920. */
  50921. texture: Nullable<BaseTexture>;
  50922. private _bumpTexture;
  50923. /**
  50924. * Define the clear coat specific bump texture.
  50925. */
  50926. bumpTexture: Nullable<BaseTexture>;
  50927. private _isTintEnabled;
  50928. /**
  50929. * Defines if the clear coat tint is enabled in the material.
  50930. */
  50931. isTintEnabled: boolean;
  50932. /**
  50933. * Defines the clear coat tint of the material.
  50934. * This is only use if tint is enabled
  50935. */
  50936. tintColor: Color3;
  50937. /**
  50938. * Defines the distance at which the tint color should be found in the
  50939. * clear coat media.
  50940. * This is only use if tint is enabled
  50941. */
  50942. tintColorAtDistance: number;
  50943. /**
  50944. * Defines the clear coat layer thickness.
  50945. * This is only use if tint is enabled
  50946. */
  50947. tintThickness: number;
  50948. private _tintTexture;
  50949. /**
  50950. * Stores the clear tint values in a texture.
  50951. * rgb is tint
  50952. * a is a thickness factor
  50953. */
  50954. tintTexture: Nullable<BaseTexture>;
  50955. /** @hidden */
  50956. private _internalMarkAllSubMeshesAsTexturesDirty;
  50957. /** @hidden */
  50958. _markAllSubMeshesAsTexturesDirty(): void;
  50959. /**
  50960. * Instantiate a new istance of clear coat configuration.
  50961. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50962. */
  50963. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50964. /**
  50965. * Gets wehter the submesh is ready to be used or not.
  50966. * @param defines the list of "defines" to update.
  50967. * @param scene defines the scene the material belongs to.
  50968. * @param engine defines the engine the material belongs to.
  50969. * @param disableBumpMap defines wether the material disables bump or not.
  50970. * @returns - boolean indicating that the submesh is ready or not.
  50971. */
  50972. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50973. /**
  50974. * Checks to see if a texture is used in the material.
  50975. * @param defines the list of "defines" to update.
  50976. * @param scene defines the scene to the material belongs to.
  50977. */
  50978. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50979. /**
  50980. * Binds the material data.
  50981. * @param uniformBuffer defines the Uniform buffer to fill in.
  50982. * @param scene defines the scene the material belongs to.
  50983. * @param engine defines the engine the material belongs to.
  50984. * @param disableBumpMap defines wether the material disables bump or not.
  50985. * @param isFrozen defines wether the material is frozen or not.
  50986. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50987. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50988. */
  50989. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50990. /**
  50991. * Checks to see if a texture is used in the material.
  50992. * @param texture - Base texture to use.
  50993. * @returns - Boolean specifying if a texture is used in the material.
  50994. */
  50995. hasTexture(texture: BaseTexture): boolean;
  50996. /**
  50997. * Returns an array of the actively used textures.
  50998. * @param activeTextures Array of BaseTextures
  50999. */
  51000. getActiveTextures(activeTextures: BaseTexture[]): void;
  51001. /**
  51002. * Returns the animatable textures.
  51003. * @param animatables Array of animatable textures.
  51004. */
  51005. getAnimatables(animatables: IAnimatable[]): void;
  51006. /**
  51007. * Disposes the resources of the material.
  51008. * @param forceDisposeTextures - Forces the disposal of all textures.
  51009. */
  51010. dispose(forceDisposeTextures?: boolean): void;
  51011. /**
  51012. * Get the current class name of the texture useful for serialization or dynamic coding.
  51013. * @returns "PBRClearCoatConfiguration"
  51014. */
  51015. getClassName(): string;
  51016. /**
  51017. * Add fallbacks to the effect fallbacks list.
  51018. * @param defines defines the Base texture to use.
  51019. * @param fallbacks defines the current fallback list.
  51020. * @param currentRank defines the current fallback rank.
  51021. * @returns the new fallback rank.
  51022. */
  51023. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51024. /**
  51025. * Add the required uniforms to the current list.
  51026. * @param uniforms defines the current uniform list.
  51027. */
  51028. static AddUniforms(uniforms: string[]): void;
  51029. /**
  51030. * Add the required samplers to the current list.
  51031. * @param samplers defines the current sampler list.
  51032. */
  51033. static AddSamplers(samplers: string[]): void;
  51034. /**
  51035. * Add the required uniforms to the current buffer.
  51036. * @param uniformBuffer defines the current uniform buffer.
  51037. */
  51038. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51039. /**
  51040. * Makes a duplicate of the current configuration into another one.
  51041. * @param clearCoatConfiguration define the config where to copy the info
  51042. */
  51043. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51044. /**
  51045. * Serializes this clear coat configuration.
  51046. * @returns - An object with the serialized config.
  51047. */
  51048. serialize(): any;
  51049. /**
  51050. * Parses a anisotropy Configuration from a serialized object.
  51051. * @param source - Serialized object.
  51052. * @param scene Defines the scene we are parsing for
  51053. * @param rootUrl Defines the rootUrl to load from
  51054. */
  51055. parse(source: any, scene: Scene, rootUrl: string): void;
  51056. }
  51057. }
  51058. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51059. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51061. import { Vector2 } from "babylonjs/Maths/math.vector";
  51062. import { Scene } from "babylonjs/scene";
  51063. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51064. import { Nullable } from "babylonjs/types";
  51065. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51066. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51067. /**
  51068. * @hidden
  51069. */
  51070. export interface IMaterialAnisotropicDefines {
  51071. ANISOTROPIC: boolean;
  51072. ANISOTROPIC_TEXTURE: boolean;
  51073. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51074. MAINUV1: boolean;
  51075. _areTexturesDirty: boolean;
  51076. _needUVs: boolean;
  51077. }
  51078. /**
  51079. * Define the code related to the anisotropic parameters of the pbr material.
  51080. */
  51081. export class PBRAnisotropicConfiguration {
  51082. private _isEnabled;
  51083. /**
  51084. * Defines if the anisotropy is enabled in the material.
  51085. */
  51086. isEnabled: boolean;
  51087. /**
  51088. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51089. */
  51090. intensity: number;
  51091. /**
  51092. * Defines if the effect is along the tangents, bitangents or in between.
  51093. * By default, the effect is "strectching" the highlights along the tangents.
  51094. */
  51095. direction: Vector2;
  51096. private _texture;
  51097. /**
  51098. * Stores the anisotropy values in a texture.
  51099. * rg is direction (like normal from -1 to 1)
  51100. * b is a intensity
  51101. */
  51102. texture: Nullable<BaseTexture>;
  51103. /** @hidden */
  51104. private _internalMarkAllSubMeshesAsTexturesDirty;
  51105. /** @hidden */
  51106. _markAllSubMeshesAsTexturesDirty(): void;
  51107. /**
  51108. * Instantiate a new istance of anisotropy configuration.
  51109. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51110. */
  51111. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51112. /**
  51113. * Specifies that the submesh is ready to be used.
  51114. * @param defines the list of "defines" to update.
  51115. * @param scene defines the scene the material belongs to.
  51116. * @returns - boolean indicating that the submesh is ready or not.
  51117. */
  51118. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51119. /**
  51120. * Checks to see if a texture is used in the material.
  51121. * @param defines the list of "defines" to update.
  51122. * @param mesh the mesh we are preparing the defines for.
  51123. * @param scene defines the scene the material belongs to.
  51124. */
  51125. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51126. /**
  51127. * Binds the material data.
  51128. * @param uniformBuffer defines the Uniform buffer to fill in.
  51129. * @param scene defines the scene the material belongs to.
  51130. * @param isFrozen defines wether the material is frozen or not.
  51131. */
  51132. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51133. /**
  51134. * Checks to see if a texture is used in the material.
  51135. * @param texture - Base texture to use.
  51136. * @returns - Boolean specifying if a texture is used in the material.
  51137. */
  51138. hasTexture(texture: BaseTexture): boolean;
  51139. /**
  51140. * Returns an array of the actively used textures.
  51141. * @param activeTextures Array of BaseTextures
  51142. */
  51143. getActiveTextures(activeTextures: BaseTexture[]): void;
  51144. /**
  51145. * Returns the animatable textures.
  51146. * @param animatables Array of animatable textures.
  51147. */
  51148. getAnimatables(animatables: IAnimatable[]): void;
  51149. /**
  51150. * Disposes the resources of the material.
  51151. * @param forceDisposeTextures - Forces the disposal of all textures.
  51152. */
  51153. dispose(forceDisposeTextures?: boolean): void;
  51154. /**
  51155. * Get the current class name of the texture useful for serialization or dynamic coding.
  51156. * @returns "PBRAnisotropicConfiguration"
  51157. */
  51158. getClassName(): string;
  51159. /**
  51160. * Add fallbacks to the effect fallbacks list.
  51161. * @param defines defines the Base texture to use.
  51162. * @param fallbacks defines the current fallback list.
  51163. * @param currentRank defines the current fallback rank.
  51164. * @returns the new fallback rank.
  51165. */
  51166. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51167. /**
  51168. * Add the required uniforms to the current list.
  51169. * @param uniforms defines the current uniform list.
  51170. */
  51171. static AddUniforms(uniforms: string[]): void;
  51172. /**
  51173. * Add the required uniforms to the current buffer.
  51174. * @param uniformBuffer defines the current uniform buffer.
  51175. */
  51176. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51177. /**
  51178. * Add the required samplers to the current list.
  51179. * @param samplers defines the current sampler list.
  51180. */
  51181. static AddSamplers(samplers: string[]): void;
  51182. /**
  51183. * Makes a duplicate of the current configuration into another one.
  51184. * @param anisotropicConfiguration define the config where to copy the info
  51185. */
  51186. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51187. /**
  51188. * Serializes this anisotropy configuration.
  51189. * @returns - An object with the serialized config.
  51190. */
  51191. serialize(): any;
  51192. /**
  51193. * Parses a anisotropy Configuration from a serialized object.
  51194. * @param source - Serialized object.
  51195. * @param scene Defines the scene we are parsing for
  51196. * @param rootUrl Defines the rootUrl to load from
  51197. */
  51198. parse(source: any, scene: Scene, rootUrl: string): void;
  51199. }
  51200. }
  51201. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  51202. import { Scene } from "babylonjs/scene";
  51203. /**
  51204. * @hidden
  51205. */
  51206. export interface IMaterialBRDFDefines {
  51207. BRDF_V_HEIGHT_CORRELATED: boolean;
  51208. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51209. SPHERICAL_HARMONICS: boolean;
  51210. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51211. /** @hidden */
  51212. _areMiscDirty: boolean;
  51213. }
  51214. /**
  51215. * Define the code related to the BRDF parameters of the pbr material.
  51216. */
  51217. export class PBRBRDFConfiguration {
  51218. /**
  51219. * Default value used for the energy conservation.
  51220. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51221. */
  51222. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51223. /**
  51224. * Default value used for the Smith Visibility Height Correlated mode.
  51225. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51226. */
  51227. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51228. /**
  51229. * Default value used for the IBL diffuse part.
  51230. * This can help switching back to the polynomials mode globally which is a tiny bit
  51231. * less GPU intensive at the drawback of a lower quality.
  51232. */
  51233. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51234. /**
  51235. * Default value used for activating energy conservation for the specular workflow.
  51236. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51237. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51238. */
  51239. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51240. private _useEnergyConservation;
  51241. /**
  51242. * Defines if the material uses energy conservation.
  51243. */
  51244. useEnergyConservation: boolean;
  51245. private _useSmithVisibilityHeightCorrelated;
  51246. /**
  51247. * LEGACY Mode set to false
  51248. * Defines if the material uses height smith correlated visibility term.
  51249. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51250. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51251. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51252. * Not relying on height correlated will also disable energy conservation.
  51253. */
  51254. useSmithVisibilityHeightCorrelated: boolean;
  51255. private _useSphericalHarmonics;
  51256. /**
  51257. * LEGACY Mode set to false
  51258. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51259. * diffuse part of the IBL.
  51260. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51261. * to the ground truth.
  51262. */
  51263. useSphericalHarmonics: boolean;
  51264. private _useSpecularGlossinessInputEnergyConservation;
  51265. /**
  51266. * Defines if the material uses energy conservation, when the specular workflow is active.
  51267. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51268. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51269. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51270. */
  51271. useSpecularGlossinessInputEnergyConservation: boolean;
  51272. /** @hidden */
  51273. private _internalMarkAllSubMeshesAsMiscDirty;
  51274. /** @hidden */
  51275. _markAllSubMeshesAsMiscDirty(): void;
  51276. /**
  51277. * Instantiate a new istance of clear coat configuration.
  51278. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51279. */
  51280. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51281. /**
  51282. * Checks to see if a texture is used in the material.
  51283. * @param defines the list of "defines" to update.
  51284. */
  51285. prepareDefines(defines: IMaterialBRDFDefines): void;
  51286. /**
  51287. * Get the current class name of the texture useful for serialization or dynamic coding.
  51288. * @returns "PBRClearCoatConfiguration"
  51289. */
  51290. getClassName(): string;
  51291. /**
  51292. * Makes a duplicate of the current configuration into another one.
  51293. * @param brdfConfiguration define the config where to copy the info
  51294. */
  51295. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51296. /**
  51297. * Serializes this BRDF configuration.
  51298. * @returns - An object with the serialized config.
  51299. */
  51300. serialize(): any;
  51301. /**
  51302. * Parses a anisotropy Configuration from a serialized object.
  51303. * @param source - Serialized object.
  51304. * @param scene Defines the scene we are parsing for
  51305. * @param rootUrl Defines the rootUrl to load from
  51306. */
  51307. parse(source: any, scene: Scene, rootUrl: string): void;
  51308. }
  51309. }
  51310. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  51311. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51312. import { Color3 } from "babylonjs/Maths/math.color";
  51313. import { Scene } from "babylonjs/scene";
  51314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51315. import { Nullable } from "babylonjs/types";
  51316. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51317. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51318. /**
  51319. * @hidden
  51320. */
  51321. export interface IMaterialSheenDefines {
  51322. SHEEN: boolean;
  51323. SHEEN_TEXTURE: boolean;
  51324. SHEEN_TEXTUREDIRECTUV: number;
  51325. SHEEN_LINKWITHALBEDO: boolean;
  51326. /** @hidden */
  51327. _areTexturesDirty: boolean;
  51328. }
  51329. /**
  51330. * Define the code related to the Sheen parameters of the pbr material.
  51331. */
  51332. export class PBRSheenConfiguration {
  51333. private _isEnabled;
  51334. /**
  51335. * Defines if the material uses sheen.
  51336. */
  51337. isEnabled: boolean;
  51338. private _linkSheenWithAlbedo;
  51339. /**
  51340. * Defines if the sheen is linked to the sheen color.
  51341. */
  51342. linkSheenWithAlbedo: boolean;
  51343. /**
  51344. * Defines the sheen intensity.
  51345. */
  51346. intensity: number;
  51347. /**
  51348. * Defines the sheen color.
  51349. */
  51350. color: Color3;
  51351. private _texture;
  51352. /**
  51353. * Stores the sheen tint values in a texture.
  51354. * rgb is tint
  51355. * a is a intensity
  51356. */
  51357. texture: Nullable<BaseTexture>;
  51358. /** @hidden */
  51359. private _internalMarkAllSubMeshesAsTexturesDirty;
  51360. /** @hidden */
  51361. _markAllSubMeshesAsTexturesDirty(): void;
  51362. /**
  51363. * Instantiate a new istance of clear coat configuration.
  51364. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51365. */
  51366. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51367. /**
  51368. * Specifies that the submesh is ready to be used.
  51369. * @param defines the list of "defines" to update.
  51370. * @param scene defines the scene the material belongs to.
  51371. * @returns - boolean indicating that the submesh is ready or not.
  51372. */
  51373. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51374. /**
  51375. * Checks to see if a texture is used in the material.
  51376. * @param defines the list of "defines" to update.
  51377. * @param scene defines the scene the material belongs to.
  51378. */
  51379. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51380. /**
  51381. * Binds the material data.
  51382. * @param uniformBuffer defines the Uniform buffer to fill in.
  51383. * @param scene defines the scene the material belongs to.
  51384. * @param isFrozen defines wether the material is frozen or not.
  51385. */
  51386. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51387. /**
  51388. * Checks to see if a texture is used in the material.
  51389. * @param texture - Base texture to use.
  51390. * @returns - Boolean specifying if a texture is used in the material.
  51391. */
  51392. hasTexture(texture: BaseTexture): boolean;
  51393. /**
  51394. * Returns an array of the actively used textures.
  51395. * @param activeTextures Array of BaseTextures
  51396. */
  51397. getActiveTextures(activeTextures: BaseTexture[]): void;
  51398. /**
  51399. * Returns the animatable textures.
  51400. * @param animatables Array of animatable textures.
  51401. */
  51402. getAnimatables(animatables: IAnimatable[]): void;
  51403. /**
  51404. * Disposes the resources of the material.
  51405. * @param forceDisposeTextures - Forces the disposal of all textures.
  51406. */
  51407. dispose(forceDisposeTextures?: boolean): void;
  51408. /**
  51409. * Get the current class name of the texture useful for serialization or dynamic coding.
  51410. * @returns "PBRSheenConfiguration"
  51411. */
  51412. getClassName(): string;
  51413. /**
  51414. * Add fallbacks to the effect fallbacks list.
  51415. * @param defines defines the Base texture to use.
  51416. * @param fallbacks defines the current fallback list.
  51417. * @param currentRank defines the current fallback rank.
  51418. * @returns the new fallback rank.
  51419. */
  51420. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51421. /**
  51422. * Add the required uniforms to the current list.
  51423. * @param uniforms defines the current uniform list.
  51424. */
  51425. static AddUniforms(uniforms: string[]): void;
  51426. /**
  51427. * Add the required uniforms to the current buffer.
  51428. * @param uniformBuffer defines the current uniform buffer.
  51429. */
  51430. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51431. /**
  51432. * Add the required samplers to the current list.
  51433. * @param samplers defines the current sampler list.
  51434. */
  51435. static AddSamplers(samplers: string[]): void;
  51436. /**
  51437. * Makes a duplicate of the current configuration into another one.
  51438. * @param sheenConfiguration define the config where to copy the info
  51439. */
  51440. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51441. /**
  51442. * Serializes this BRDF configuration.
  51443. * @returns - An object with the serialized config.
  51444. */
  51445. serialize(): any;
  51446. /**
  51447. * Parses a anisotropy Configuration from a serialized object.
  51448. * @param source - Serialized object.
  51449. * @param scene Defines the scene we are parsing for
  51450. * @param rootUrl Defines the rootUrl to load from
  51451. */
  51452. parse(source: any, scene: Scene, rootUrl: string): void;
  51453. }
  51454. }
  51455. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  51456. import { Nullable } from "babylonjs/types";
  51457. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51458. import { Color3 } from "babylonjs/Maths/math.color";
  51459. import { SmartArray } from "babylonjs/Misc/smartArray";
  51460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51462. import { Effect } from "babylonjs/Materials/effect";
  51463. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51464. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51465. import { Engine } from "babylonjs/Engines/engine";
  51466. import { Scene } from "babylonjs/scene";
  51467. /**
  51468. * @hidden
  51469. */
  51470. export interface IMaterialSubSurfaceDefines {
  51471. SUBSURFACE: boolean;
  51472. SS_REFRACTION: boolean;
  51473. SS_TRANSLUCENCY: boolean;
  51474. SS_SCATERRING: boolean;
  51475. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51476. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51477. SS_REFRACTIONMAP_3D: boolean;
  51478. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51479. SS_LODINREFRACTIONALPHA: boolean;
  51480. SS_GAMMAREFRACTION: boolean;
  51481. SS_RGBDREFRACTION: boolean;
  51482. SS_LINEARSPECULARREFRACTION: boolean;
  51483. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51484. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51485. /** @hidden */
  51486. _areTexturesDirty: boolean;
  51487. }
  51488. /**
  51489. * Define the code related to the sub surface parameters of the pbr material.
  51490. */
  51491. export class PBRSubSurfaceConfiguration {
  51492. private _isRefractionEnabled;
  51493. /**
  51494. * Defines if the refraction is enabled in the material.
  51495. */
  51496. isRefractionEnabled: boolean;
  51497. private _isTranslucencyEnabled;
  51498. /**
  51499. * Defines if the translucency is enabled in the material.
  51500. */
  51501. isTranslucencyEnabled: boolean;
  51502. private _isScatteringEnabled;
  51503. /**
  51504. * Defines the refraction intensity of the material.
  51505. * The refraction when enabled replaces the Diffuse part of the material.
  51506. * The intensity helps transitionning between diffuse and refraction.
  51507. */
  51508. refractionIntensity: number;
  51509. /**
  51510. * Defines the translucency intensity of the material.
  51511. * When translucency has been enabled, this defines how much of the "translucency"
  51512. * is addded to the diffuse part of the material.
  51513. */
  51514. translucencyIntensity: number;
  51515. /**
  51516. * Defines the scattering intensity of the material.
  51517. * When scattering has been enabled, this defines how much of the "scattered light"
  51518. * is addded to the diffuse part of the material.
  51519. */
  51520. scatteringIntensity: number;
  51521. private _thicknessTexture;
  51522. /**
  51523. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51524. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51525. * 0 would mean minimumThickness
  51526. * 1 would mean maximumThickness
  51527. * The other channels might be use as a mask to vary the different effects intensity.
  51528. */
  51529. thicknessTexture: Nullable<BaseTexture>;
  51530. private _refractionTexture;
  51531. /**
  51532. * Defines the texture to use for refraction.
  51533. */
  51534. refractionTexture: Nullable<BaseTexture>;
  51535. private _indexOfRefraction;
  51536. /**
  51537. * Defines the index of refraction used in the material.
  51538. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51539. */
  51540. indexOfRefraction: number;
  51541. private _invertRefractionY;
  51542. /**
  51543. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51544. */
  51545. invertRefractionY: boolean;
  51546. private _linkRefractionWithTransparency;
  51547. /**
  51548. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51549. * Materials half opaque for instance using refraction could benefit from this control.
  51550. */
  51551. linkRefractionWithTransparency: boolean;
  51552. /**
  51553. * Defines the minimum thickness stored in the thickness map.
  51554. * If no thickness map is defined, this value will be used to simulate thickness.
  51555. */
  51556. minimumThickness: number;
  51557. /**
  51558. * Defines the maximum thickness stored in the thickness map.
  51559. */
  51560. maximumThickness: number;
  51561. /**
  51562. * Defines the volume tint of the material.
  51563. * This is used for both translucency and scattering.
  51564. */
  51565. tintColor: Color3;
  51566. /**
  51567. * Defines the distance at which the tint color should be found in the media.
  51568. * This is used for refraction only.
  51569. */
  51570. tintColorAtDistance: number;
  51571. /**
  51572. * Defines how far each channel transmit through the media.
  51573. * It is defined as a color to simplify it selection.
  51574. */
  51575. diffusionDistance: Color3;
  51576. private _useMaskFromThicknessTexture;
  51577. /**
  51578. * Stores the intensity of the different subsurface effects in the thickness texture.
  51579. * * the green channel is the translucency intensity.
  51580. * * the blue channel is the scattering intensity.
  51581. * * the alpha channel is the refraction intensity.
  51582. */
  51583. useMaskFromThicknessTexture: boolean;
  51584. /** @hidden */
  51585. private _internalMarkAllSubMeshesAsTexturesDirty;
  51586. /** @hidden */
  51587. _markAllSubMeshesAsTexturesDirty(): void;
  51588. /**
  51589. * Instantiate a new istance of sub surface configuration.
  51590. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51591. */
  51592. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51593. /**
  51594. * Gets wehter the submesh is ready to be used or not.
  51595. * @param defines the list of "defines" to update.
  51596. * @param scene defines the scene the material belongs to.
  51597. * @returns - boolean indicating that the submesh is ready or not.
  51598. */
  51599. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51600. /**
  51601. * Checks to see if a texture is used in the material.
  51602. * @param defines the list of "defines" to update.
  51603. * @param scene defines the scene to the material belongs to.
  51604. */
  51605. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51606. /**
  51607. * Binds the material data.
  51608. * @param uniformBuffer defines the Uniform buffer to fill in.
  51609. * @param scene defines the scene the material belongs to.
  51610. * @param engine defines the engine the material belongs to.
  51611. * @param isFrozen defines wether the material is frozen or not.
  51612. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51613. */
  51614. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51615. /**
  51616. * Unbinds the material from the mesh.
  51617. * @param activeEffect defines the effect that should be unbound from.
  51618. * @returns true if unbound, otherwise false
  51619. */
  51620. unbind(activeEffect: Effect): boolean;
  51621. /**
  51622. * Returns the texture used for refraction or null if none is used.
  51623. * @param scene defines the scene the material belongs to.
  51624. * @returns - Refraction texture if present. If no refraction texture and refraction
  51625. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51626. */
  51627. private _getRefractionTexture;
  51628. /**
  51629. * Returns true if alpha blending should be disabled.
  51630. */
  51631. get disableAlphaBlending(): boolean;
  51632. /**
  51633. * Fills the list of render target textures.
  51634. * @param renderTargets the list of render targets to update
  51635. */
  51636. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51637. /**
  51638. * Checks to see if a texture is used in the material.
  51639. * @param texture - Base texture to use.
  51640. * @returns - Boolean specifying if a texture is used in the material.
  51641. */
  51642. hasTexture(texture: BaseTexture): boolean;
  51643. /**
  51644. * Gets a boolean indicating that current material needs to register RTT
  51645. * @returns true if this uses a render target otherwise false.
  51646. */
  51647. hasRenderTargetTextures(): boolean;
  51648. /**
  51649. * Returns an array of the actively used textures.
  51650. * @param activeTextures Array of BaseTextures
  51651. */
  51652. getActiveTextures(activeTextures: BaseTexture[]): void;
  51653. /**
  51654. * Returns the animatable textures.
  51655. * @param animatables Array of animatable textures.
  51656. */
  51657. getAnimatables(animatables: IAnimatable[]): void;
  51658. /**
  51659. * Disposes the resources of the material.
  51660. * @param forceDisposeTextures - Forces the disposal of all textures.
  51661. */
  51662. dispose(forceDisposeTextures?: boolean): void;
  51663. /**
  51664. * Get the current class name of the texture useful for serialization or dynamic coding.
  51665. * @returns "PBRSubSurfaceConfiguration"
  51666. */
  51667. getClassName(): string;
  51668. /**
  51669. * Add fallbacks to the effect fallbacks list.
  51670. * @param defines defines the Base texture to use.
  51671. * @param fallbacks defines the current fallback list.
  51672. * @param currentRank defines the current fallback rank.
  51673. * @returns the new fallback rank.
  51674. */
  51675. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51676. /**
  51677. * Add the required uniforms to the current list.
  51678. * @param uniforms defines the current uniform list.
  51679. */
  51680. static AddUniforms(uniforms: string[]): void;
  51681. /**
  51682. * Add the required samplers to the current list.
  51683. * @param samplers defines the current sampler list.
  51684. */
  51685. static AddSamplers(samplers: string[]): void;
  51686. /**
  51687. * Add the required uniforms to the current buffer.
  51688. * @param uniformBuffer defines the current uniform buffer.
  51689. */
  51690. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51691. /**
  51692. * Makes a duplicate of the current configuration into another one.
  51693. * @param configuration define the config where to copy the info
  51694. */
  51695. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51696. /**
  51697. * Serializes this Sub Surface configuration.
  51698. * @returns - An object with the serialized config.
  51699. */
  51700. serialize(): any;
  51701. /**
  51702. * Parses a anisotropy Configuration from a serialized object.
  51703. * @param source - Serialized object.
  51704. * @param scene Defines the scene we are parsing for
  51705. * @param rootUrl Defines the rootUrl to load from
  51706. */
  51707. parse(source: any, scene: Scene, rootUrl: string): void;
  51708. }
  51709. }
  51710. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  51711. /** @hidden */
  51712. export var pbrFragmentDeclaration: {
  51713. name: string;
  51714. shader: string;
  51715. };
  51716. }
  51717. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  51718. /** @hidden */
  51719. export var pbrUboDeclaration: {
  51720. name: string;
  51721. shader: string;
  51722. };
  51723. }
  51724. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  51725. /** @hidden */
  51726. export var pbrFragmentExtraDeclaration: {
  51727. name: string;
  51728. shader: string;
  51729. };
  51730. }
  51731. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  51732. /** @hidden */
  51733. export var pbrFragmentSamplersDeclaration: {
  51734. name: string;
  51735. shader: string;
  51736. };
  51737. }
  51738. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  51739. /** @hidden */
  51740. export var pbrHelperFunctions: {
  51741. name: string;
  51742. shader: string;
  51743. };
  51744. }
  51745. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  51746. /** @hidden */
  51747. export var harmonicsFunctions: {
  51748. name: string;
  51749. shader: string;
  51750. };
  51751. }
  51752. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  51753. /** @hidden */
  51754. export var pbrDirectLightingSetupFunctions: {
  51755. name: string;
  51756. shader: string;
  51757. };
  51758. }
  51759. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  51760. /** @hidden */
  51761. export var pbrDirectLightingFalloffFunctions: {
  51762. name: string;
  51763. shader: string;
  51764. };
  51765. }
  51766. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  51767. /** @hidden */
  51768. export var pbrBRDFFunctions: {
  51769. name: string;
  51770. shader: string;
  51771. };
  51772. }
  51773. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  51774. /** @hidden */
  51775. export var pbrDirectLightingFunctions: {
  51776. name: string;
  51777. shader: string;
  51778. };
  51779. }
  51780. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  51781. /** @hidden */
  51782. export var pbrIBLFunctions: {
  51783. name: string;
  51784. shader: string;
  51785. };
  51786. }
  51787. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  51788. /** @hidden */
  51789. export var pbrDebug: {
  51790. name: string;
  51791. shader: string;
  51792. };
  51793. }
  51794. declare module "babylonjs/Shaders/pbr.fragment" {
  51795. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  51796. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51797. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  51798. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51799. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51800. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  51801. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51802. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51803. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51804. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51805. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51806. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  51807. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51808. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51809. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51810. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  51811. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  51812. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  51813. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  51814. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  51815. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  51816. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51817. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51818. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  51819. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  51820. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51821. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  51822. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51823. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  51824. /** @hidden */
  51825. export var pbrPixelShader: {
  51826. name: string;
  51827. shader: string;
  51828. };
  51829. }
  51830. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  51831. /** @hidden */
  51832. export var pbrVertexDeclaration: {
  51833. name: string;
  51834. shader: string;
  51835. };
  51836. }
  51837. declare module "babylonjs/Shaders/pbr.vertex" {
  51838. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  51839. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51840. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51841. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51842. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51843. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51844. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  51845. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51846. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51847. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51848. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51849. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51850. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51851. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51852. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51853. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51854. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51855. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  51856. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51857. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51858. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51859. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  51860. /** @hidden */
  51861. export var pbrVertexShader: {
  51862. name: string;
  51863. shader: string;
  51864. };
  51865. }
  51866. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  51867. import { Nullable } from "babylonjs/types";
  51868. import { Scene } from "babylonjs/scene";
  51869. import { Matrix } from "babylonjs/Maths/math.vector";
  51870. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51872. import { Mesh } from "babylonjs/Meshes/mesh";
  51873. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  51874. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  51875. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  51876. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  51877. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  51878. import { Color3 } from "babylonjs/Maths/math.color";
  51879. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  51880. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  51881. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  51882. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51883. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51884. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51885. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  51886. import "babylonjs/Shaders/pbr.fragment";
  51887. import "babylonjs/Shaders/pbr.vertex";
  51888. /**
  51889. * Manages the defines for the PBR Material.
  51890. * @hidden
  51891. */
  51892. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51893. PBR: boolean;
  51894. MAINUV1: boolean;
  51895. MAINUV2: boolean;
  51896. UV1: boolean;
  51897. UV2: boolean;
  51898. ALBEDO: boolean;
  51899. ALBEDODIRECTUV: number;
  51900. VERTEXCOLOR: boolean;
  51901. AMBIENT: boolean;
  51902. AMBIENTDIRECTUV: number;
  51903. AMBIENTINGRAYSCALE: boolean;
  51904. OPACITY: boolean;
  51905. VERTEXALPHA: boolean;
  51906. OPACITYDIRECTUV: number;
  51907. OPACITYRGB: boolean;
  51908. ALPHATEST: boolean;
  51909. DEPTHPREPASS: boolean;
  51910. ALPHABLEND: boolean;
  51911. ALPHAFROMALBEDO: boolean;
  51912. ALPHATESTVALUE: string;
  51913. SPECULAROVERALPHA: boolean;
  51914. RADIANCEOVERALPHA: boolean;
  51915. ALPHAFRESNEL: boolean;
  51916. LINEARALPHAFRESNEL: boolean;
  51917. PREMULTIPLYALPHA: boolean;
  51918. EMISSIVE: boolean;
  51919. EMISSIVEDIRECTUV: number;
  51920. REFLECTIVITY: boolean;
  51921. REFLECTIVITYDIRECTUV: number;
  51922. SPECULARTERM: boolean;
  51923. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51924. MICROSURFACEAUTOMATIC: boolean;
  51925. LODBASEDMICROSFURACE: boolean;
  51926. MICROSURFACEMAP: boolean;
  51927. MICROSURFACEMAPDIRECTUV: number;
  51928. METALLICWORKFLOW: boolean;
  51929. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51930. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51931. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51932. AOSTOREINMETALMAPRED: boolean;
  51933. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51934. ENVIRONMENTBRDF: boolean;
  51935. ENVIRONMENTBRDF_RGBD: boolean;
  51936. NORMAL: boolean;
  51937. TANGENT: boolean;
  51938. BUMP: boolean;
  51939. BUMPDIRECTUV: number;
  51940. OBJECTSPACE_NORMALMAP: boolean;
  51941. PARALLAX: boolean;
  51942. PARALLAXOCCLUSION: boolean;
  51943. NORMALXYSCALE: boolean;
  51944. LIGHTMAP: boolean;
  51945. LIGHTMAPDIRECTUV: number;
  51946. USELIGHTMAPASSHADOWMAP: boolean;
  51947. GAMMALIGHTMAP: boolean;
  51948. RGBDLIGHTMAP: boolean;
  51949. REFLECTION: boolean;
  51950. REFLECTIONMAP_3D: boolean;
  51951. REFLECTIONMAP_SPHERICAL: boolean;
  51952. REFLECTIONMAP_PLANAR: boolean;
  51953. REFLECTIONMAP_CUBIC: boolean;
  51954. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51955. REFLECTIONMAP_PROJECTION: boolean;
  51956. REFLECTIONMAP_SKYBOX: boolean;
  51957. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  51958. REFLECTIONMAP_EXPLICIT: boolean;
  51959. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51960. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51961. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51962. INVERTCUBICMAP: boolean;
  51963. USESPHERICALFROMREFLECTIONMAP: boolean;
  51964. USEIRRADIANCEMAP: boolean;
  51965. SPHERICAL_HARMONICS: boolean;
  51966. USESPHERICALINVERTEX: boolean;
  51967. REFLECTIONMAP_OPPOSITEZ: boolean;
  51968. LODINREFLECTIONALPHA: boolean;
  51969. GAMMAREFLECTION: boolean;
  51970. RGBDREFLECTION: boolean;
  51971. LINEARSPECULARREFLECTION: boolean;
  51972. RADIANCEOCCLUSION: boolean;
  51973. HORIZONOCCLUSION: boolean;
  51974. INSTANCES: boolean;
  51975. NUM_BONE_INFLUENCERS: number;
  51976. BonesPerMesh: number;
  51977. BONETEXTURE: boolean;
  51978. NONUNIFORMSCALING: boolean;
  51979. MORPHTARGETS: boolean;
  51980. MORPHTARGETS_NORMAL: boolean;
  51981. MORPHTARGETS_TANGENT: boolean;
  51982. MORPHTARGETS_UV: boolean;
  51983. NUM_MORPH_INFLUENCERS: number;
  51984. IMAGEPROCESSING: boolean;
  51985. VIGNETTE: boolean;
  51986. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51987. VIGNETTEBLENDMODEOPAQUE: boolean;
  51988. TONEMAPPING: boolean;
  51989. TONEMAPPING_ACES: boolean;
  51990. CONTRAST: boolean;
  51991. COLORCURVES: boolean;
  51992. COLORGRADING: boolean;
  51993. COLORGRADING3D: boolean;
  51994. SAMPLER3DGREENDEPTH: boolean;
  51995. SAMPLER3DBGRMAP: boolean;
  51996. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51997. EXPOSURE: boolean;
  51998. MULTIVIEW: boolean;
  51999. USEPHYSICALLIGHTFALLOFF: boolean;
  52000. USEGLTFLIGHTFALLOFF: boolean;
  52001. TWOSIDEDLIGHTING: boolean;
  52002. SHADOWFLOAT: boolean;
  52003. CLIPPLANE: boolean;
  52004. CLIPPLANE2: boolean;
  52005. CLIPPLANE3: boolean;
  52006. CLIPPLANE4: boolean;
  52007. CLIPPLANE5: boolean;
  52008. CLIPPLANE6: boolean;
  52009. POINTSIZE: boolean;
  52010. FOG: boolean;
  52011. LOGARITHMICDEPTH: boolean;
  52012. FORCENORMALFORWARD: boolean;
  52013. SPECULARAA: boolean;
  52014. CLEARCOAT: boolean;
  52015. CLEARCOAT_DEFAULTIOR: boolean;
  52016. CLEARCOAT_TEXTURE: boolean;
  52017. CLEARCOAT_TEXTUREDIRECTUV: number;
  52018. CLEARCOAT_BUMP: boolean;
  52019. CLEARCOAT_BUMPDIRECTUV: number;
  52020. CLEARCOAT_TINT: boolean;
  52021. CLEARCOAT_TINT_TEXTURE: boolean;
  52022. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52023. ANISOTROPIC: boolean;
  52024. ANISOTROPIC_TEXTURE: boolean;
  52025. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52026. BRDF_V_HEIGHT_CORRELATED: boolean;
  52027. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52028. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52029. SHEEN: boolean;
  52030. SHEEN_TEXTURE: boolean;
  52031. SHEEN_TEXTUREDIRECTUV: number;
  52032. SHEEN_LINKWITHALBEDO: boolean;
  52033. SUBSURFACE: boolean;
  52034. SS_REFRACTION: boolean;
  52035. SS_TRANSLUCENCY: boolean;
  52036. SS_SCATERRING: boolean;
  52037. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52038. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52039. SS_REFRACTIONMAP_3D: boolean;
  52040. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52041. SS_LODINREFRACTIONALPHA: boolean;
  52042. SS_GAMMAREFRACTION: boolean;
  52043. SS_RGBDREFRACTION: boolean;
  52044. SS_LINEARSPECULARREFRACTION: boolean;
  52045. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52046. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52047. UNLIT: boolean;
  52048. DEBUGMODE: number;
  52049. /**
  52050. * Initializes the PBR Material defines.
  52051. */
  52052. constructor();
  52053. /**
  52054. * Resets the PBR Material defines.
  52055. */
  52056. reset(): void;
  52057. }
  52058. /**
  52059. * The Physically based material base class of BJS.
  52060. *
  52061. * This offers the main features of a standard PBR material.
  52062. * For more information, please refer to the documentation :
  52063. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52064. */
  52065. export abstract class PBRBaseMaterial extends PushMaterial {
  52066. /**
  52067. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52068. */
  52069. static readonly PBRMATERIAL_OPAQUE: number;
  52070. /**
  52071. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52072. */
  52073. static readonly PBRMATERIAL_ALPHATEST: number;
  52074. /**
  52075. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52076. */
  52077. static readonly PBRMATERIAL_ALPHABLEND: number;
  52078. /**
  52079. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52080. * They are also discarded below the alpha cutoff threshold to improve performances.
  52081. */
  52082. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52083. /**
  52084. * Defines the default value of how much AO map is occluding the analytical lights
  52085. * (point spot...).
  52086. */
  52087. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52088. /**
  52089. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52090. */
  52091. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52092. /**
  52093. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52094. * to enhance interoperability with other engines.
  52095. */
  52096. static readonly LIGHTFALLOFF_GLTF: number;
  52097. /**
  52098. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52099. * to enhance interoperability with other materials.
  52100. */
  52101. static readonly LIGHTFALLOFF_STANDARD: number;
  52102. /**
  52103. * Intensity of the direct lights e.g. the four lights available in your scene.
  52104. * This impacts both the direct diffuse and specular highlights.
  52105. */
  52106. protected _directIntensity: number;
  52107. /**
  52108. * Intensity of the emissive part of the material.
  52109. * This helps controlling the emissive effect without modifying the emissive color.
  52110. */
  52111. protected _emissiveIntensity: number;
  52112. /**
  52113. * Intensity of the environment e.g. how much the environment will light the object
  52114. * either through harmonics for rough material or through the refelction for shiny ones.
  52115. */
  52116. protected _environmentIntensity: number;
  52117. /**
  52118. * This is a special control allowing the reduction of the specular highlights coming from the
  52119. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52120. */
  52121. protected _specularIntensity: number;
  52122. /**
  52123. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52124. */
  52125. private _lightingInfos;
  52126. /**
  52127. * Debug Control allowing disabling the bump map on this material.
  52128. */
  52129. protected _disableBumpMap: boolean;
  52130. /**
  52131. * AKA Diffuse Texture in standard nomenclature.
  52132. */
  52133. protected _albedoTexture: Nullable<BaseTexture>;
  52134. /**
  52135. * AKA Occlusion Texture in other nomenclature.
  52136. */
  52137. protected _ambientTexture: Nullable<BaseTexture>;
  52138. /**
  52139. * AKA Occlusion Texture Intensity in other nomenclature.
  52140. */
  52141. protected _ambientTextureStrength: number;
  52142. /**
  52143. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52144. * 1 means it completely occludes it
  52145. * 0 mean it has no impact
  52146. */
  52147. protected _ambientTextureImpactOnAnalyticalLights: number;
  52148. /**
  52149. * Stores the alpha values in a texture.
  52150. */
  52151. protected _opacityTexture: Nullable<BaseTexture>;
  52152. /**
  52153. * Stores the reflection values in a texture.
  52154. */
  52155. protected _reflectionTexture: Nullable<BaseTexture>;
  52156. /**
  52157. * Stores the emissive values in a texture.
  52158. */
  52159. protected _emissiveTexture: Nullable<BaseTexture>;
  52160. /**
  52161. * AKA Specular texture in other nomenclature.
  52162. */
  52163. protected _reflectivityTexture: Nullable<BaseTexture>;
  52164. /**
  52165. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52166. */
  52167. protected _metallicTexture: Nullable<BaseTexture>;
  52168. /**
  52169. * Specifies the metallic scalar of the metallic/roughness workflow.
  52170. * Can also be used to scale the metalness values of the metallic texture.
  52171. */
  52172. protected _metallic: Nullable<number>;
  52173. /**
  52174. * Specifies the roughness scalar of the metallic/roughness workflow.
  52175. * Can also be used to scale the roughness values of the metallic texture.
  52176. */
  52177. protected _roughness: Nullable<number>;
  52178. /**
  52179. * Specifies the an F0 factor to help configuring the material F0.
  52180. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52181. * to 0.5 the previously hard coded value stays the same.
  52182. * Can also be used to scale the F0 values of the metallic texture.
  52183. */
  52184. protected _metallicF0Factor: number;
  52185. /**
  52186. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52187. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52188. * your expectation as it multiplies with the texture data.
  52189. */
  52190. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52191. /**
  52192. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52193. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52194. */
  52195. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52196. /**
  52197. * Stores surface normal data used to displace a mesh in a texture.
  52198. */
  52199. protected _bumpTexture: Nullable<BaseTexture>;
  52200. /**
  52201. * Stores the pre-calculated light information of a mesh in a texture.
  52202. */
  52203. protected _lightmapTexture: Nullable<BaseTexture>;
  52204. /**
  52205. * The color of a material in ambient lighting.
  52206. */
  52207. protected _ambientColor: Color3;
  52208. /**
  52209. * AKA Diffuse Color in other nomenclature.
  52210. */
  52211. protected _albedoColor: Color3;
  52212. /**
  52213. * AKA Specular Color in other nomenclature.
  52214. */
  52215. protected _reflectivityColor: Color3;
  52216. /**
  52217. * The color applied when light is reflected from a material.
  52218. */
  52219. protected _reflectionColor: Color3;
  52220. /**
  52221. * The color applied when light is emitted from a material.
  52222. */
  52223. protected _emissiveColor: Color3;
  52224. /**
  52225. * AKA Glossiness in other nomenclature.
  52226. */
  52227. protected _microSurface: number;
  52228. /**
  52229. * Specifies that the material will use the light map as a show map.
  52230. */
  52231. protected _useLightmapAsShadowmap: boolean;
  52232. /**
  52233. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52234. * makes the reflect vector face the model (under horizon).
  52235. */
  52236. protected _useHorizonOcclusion: boolean;
  52237. /**
  52238. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52239. * too much the area relying on ambient texture to define their ambient occlusion.
  52240. */
  52241. protected _useRadianceOcclusion: boolean;
  52242. /**
  52243. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52244. */
  52245. protected _useAlphaFromAlbedoTexture: boolean;
  52246. /**
  52247. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52248. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52249. */
  52250. protected _useSpecularOverAlpha: boolean;
  52251. /**
  52252. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52253. */
  52254. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52255. /**
  52256. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52257. */
  52258. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52259. /**
  52260. * Specifies if the metallic texture contains the roughness information in its green channel.
  52261. */
  52262. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52263. /**
  52264. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52265. */
  52266. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52267. /**
  52268. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52269. */
  52270. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52271. /**
  52272. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52273. */
  52274. protected _useAmbientInGrayScale: boolean;
  52275. /**
  52276. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52277. * The material will try to infer what glossiness each pixel should be.
  52278. */
  52279. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52280. /**
  52281. * Defines the falloff type used in this material.
  52282. * It by default is Physical.
  52283. */
  52284. protected _lightFalloff: number;
  52285. /**
  52286. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52287. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52288. */
  52289. protected _useRadianceOverAlpha: boolean;
  52290. /**
  52291. * Allows using an object space normal map (instead of tangent space).
  52292. */
  52293. protected _useObjectSpaceNormalMap: boolean;
  52294. /**
  52295. * Allows using the bump map in parallax mode.
  52296. */
  52297. protected _useParallax: boolean;
  52298. /**
  52299. * Allows using the bump map in parallax occlusion mode.
  52300. */
  52301. protected _useParallaxOcclusion: boolean;
  52302. /**
  52303. * Controls the scale bias of the parallax mode.
  52304. */
  52305. protected _parallaxScaleBias: number;
  52306. /**
  52307. * If sets to true, disables all the lights affecting the material.
  52308. */
  52309. protected _disableLighting: boolean;
  52310. /**
  52311. * Number of Simultaneous lights allowed on the material.
  52312. */
  52313. protected _maxSimultaneousLights: number;
  52314. /**
  52315. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52316. */
  52317. protected _invertNormalMapX: boolean;
  52318. /**
  52319. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52320. */
  52321. protected _invertNormalMapY: boolean;
  52322. /**
  52323. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52324. */
  52325. protected _twoSidedLighting: boolean;
  52326. /**
  52327. * Defines the alpha limits in alpha test mode.
  52328. */
  52329. protected _alphaCutOff: number;
  52330. /**
  52331. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52332. */
  52333. protected _forceAlphaTest: boolean;
  52334. /**
  52335. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52336. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52337. */
  52338. protected _useAlphaFresnel: boolean;
  52339. /**
  52340. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52341. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52342. */
  52343. protected _useLinearAlphaFresnel: boolean;
  52344. /**
  52345. * The transparency mode of the material.
  52346. */
  52347. protected _transparencyMode: Nullable<number>;
  52348. /**
  52349. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52350. * from cos thetav and roughness:
  52351. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52352. */
  52353. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52354. /**
  52355. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52356. */
  52357. protected _forceIrradianceInFragment: boolean;
  52358. /**
  52359. * Force normal to face away from face.
  52360. */
  52361. protected _forceNormalForward: boolean;
  52362. /**
  52363. * Enables specular anti aliasing in the PBR shader.
  52364. * It will both interacts on the Geometry for analytical and IBL lighting.
  52365. * It also prefilter the roughness map based on the bump values.
  52366. */
  52367. protected _enableSpecularAntiAliasing: boolean;
  52368. /**
  52369. * Default configuration related to image processing available in the PBR Material.
  52370. */
  52371. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52372. /**
  52373. * Keep track of the image processing observer to allow dispose and replace.
  52374. */
  52375. private _imageProcessingObserver;
  52376. /**
  52377. * Attaches a new image processing configuration to the PBR Material.
  52378. * @param configuration
  52379. */
  52380. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52381. /**
  52382. * Stores the available render targets.
  52383. */
  52384. private _renderTargets;
  52385. /**
  52386. * Sets the global ambient color for the material used in lighting calculations.
  52387. */
  52388. private _globalAmbientColor;
  52389. /**
  52390. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52391. */
  52392. private _useLogarithmicDepth;
  52393. /**
  52394. * If set to true, no lighting calculations will be applied.
  52395. */
  52396. private _unlit;
  52397. private _debugMode;
  52398. /**
  52399. * @hidden
  52400. * This is reserved for the inspector.
  52401. * Defines the material debug mode.
  52402. * It helps seeing only some components of the material while troubleshooting.
  52403. */
  52404. debugMode: number;
  52405. /**
  52406. * @hidden
  52407. * This is reserved for the inspector.
  52408. * Specify from where on screen the debug mode should start.
  52409. * The value goes from -1 (full screen) to 1 (not visible)
  52410. * It helps with side by side comparison against the final render
  52411. * This defaults to -1
  52412. */
  52413. private debugLimit;
  52414. /**
  52415. * @hidden
  52416. * This is reserved for the inspector.
  52417. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52418. * You can use the factor to better multiply the final value.
  52419. */
  52420. private debugFactor;
  52421. /**
  52422. * Defines the clear coat layer parameters for the material.
  52423. */
  52424. readonly clearCoat: PBRClearCoatConfiguration;
  52425. /**
  52426. * Defines the anisotropic parameters for the material.
  52427. */
  52428. readonly anisotropy: PBRAnisotropicConfiguration;
  52429. /**
  52430. * Defines the BRDF parameters for the material.
  52431. */
  52432. readonly brdf: PBRBRDFConfiguration;
  52433. /**
  52434. * Defines the Sheen parameters for the material.
  52435. */
  52436. readonly sheen: PBRSheenConfiguration;
  52437. /**
  52438. * Defines the SubSurface parameters for the material.
  52439. */
  52440. readonly subSurface: PBRSubSurfaceConfiguration;
  52441. /**
  52442. * Custom callback helping to override the default shader used in the material.
  52443. */
  52444. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  52445. protected _rebuildInParallel: boolean;
  52446. /**
  52447. * Instantiates a new PBRMaterial instance.
  52448. *
  52449. * @param name The material name
  52450. * @param scene The scene the material will be use in.
  52451. */
  52452. constructor(name: string, scene: Scene);
  52453. /**
  52454. * Gets a boolean indicating that current material needs to register RTT
  52455. */
  52456. get hasRenderTargetTextures(): boolean;
  52457. /**
  52458. * Gets the name of the material class.
  52459. */
  52460. getClassName(): string;
  52461. /**
  52462. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52463. */
  52464. get useLogarithmicDepth(): boolean;
  52465. /**
  52466. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52467. */
  52468. set useLogarithmicDepth(value: boolean);
  52469. /**
  52470. * Gets the current transparency mode.
  52471. */
  52472. get transparencyMode(): Nullable<number>;
  52473. /**
  52474. * Sets the transparency mode of the material.
  52475. *
  52476. * | Value | Type | Description |
  52477. * | ----- | ----------------------------------- | ----------- |
  52478. * | 0 | OPAQUE | |
  52479. * | 1 | ALPHATEST | |
  52480. * | 2 | ALPHABLEND | |
  52481. * | 3 | ALPHATESTANDBLEND | |
  52482. *
  52483. */
  52484. set transparencyMode(value: Nullable<number>);
  52485. /**
  52486. * Returns true if alpha blending should be disabled.
  52487. */
  52488. private get _disableAlphaBlending();
  52489. /**
  52490. * Specifies whether or not this material should be rendered in alpha blend mode.
  52491. */
  52492. needAlphaBlending(): boolean;
  52493. /**
  52494. * Specifies if the mesh will require alpha blending.
  52495. * @param mesh - BJS mesh.
  52496. */
  52497. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  52498. /**
  52499. * Specifies whether or not this material should be rendered in alpha test mode.
  52500. */
  52501. needAlphaTesting(): boolean;
  52502. /**
  52503. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52504. */
  52505. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52506. /**
  52507. * Gets the texture used for the alpha test.
  52508. */
  52509. getAlphaTestTexture(): Nullable<BaseTexture>;
  52510. /**
  52511. * Specifies that the submesh is ready to be used.
  52512. * @param mesh - BJS mesh.
  52513. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52514. * @param useInstances - Specifies that instances should be used.
  52515. * @returns - boolean indicating that the submesh is ready or not.
  52516. */
  52517. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52518. /**
  52519. * Specifies if the material uses metallic roughness workflow.
  52520. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52521. */
  52522. isMetallicWorkflow(): boolean;
  52523. private _prepareEffect;
  52524. private _prepareDefines;
  52525. /**
  52526. * Force shader compilation
  52527. */
  52528. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52529. /**
  52530. * Initializes the uniform buffer layout for the shader.
  52531. */
  52532. buildUniformLayout(): void;
  52533. /**
  52534. * Unbinds the material from the mesh
  52535. */
  52536. unbind(): void;
  52537. /**
  52538. * Binds the submesh data.
  52539. * @param world - The world matrix.
  52540. * @param mesh - The BJS mesh.
  52541. * @param subMesh - A submesh of the BJS mesh.
  52542. */
  52543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52544. /**
  52545. * Returns the animatable textures.
  52546. * @returns - Array of animatable textures.
  52547. */
  52548. getAnimatables(): IAnimatable[];
  52549. /**
  52550. * Returns the texture used for reflections.
  52551. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52552. */
  52553. private _getReflectionTexture;
  52554. /**
  52555. * Returns an array of the actively used textures.
  52556. * @returns - Array of BaseTextures
  52557. */
  52558. getActiveTextures(): BaseTexture[];
  52559. /**
  52560. * Checks to see if a texture is used in the material.
  52561. * @param texture - Base texture to use.
  52562. * @returns - Boolean specifying if a texture is used in the material.
  52563. */
  52564. hasTexture(texture: BaseTexture): boolean;
  52565. /**
  52566. * Disposes the resources of the material.
  52567. * @param forceDisposeEffect - Forces the disposal of effects.
  52568. * @param forceDisposeTextures - Forces the disposal of all textures.
  52569. */
  52570. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52571. }
  52572. }
  52573. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  52574. import { Nullable } from "babylonjs/types";
  52575. import { Scene } from "babylonjs/scene";
  52576. import { Color3 } from "babylonjs/Maths/math.color";
  52577. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52578. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52580. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52581. /**
  52582. * The Physically based material of BJS.
  52583. *
  52584. * This offers the main features of a standard PBR material.
  52585. * For more information, please refer to the documentation :
  52586. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52587. */
  52588. export class PBRMaterial extends PBRBaseMaterial {
  52589. /**
  52590. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52591. */
  52592. static readonly PBRMATERIAL_OPAQUE: number;
  52593. /**
  52594. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52595. */
  52596. static readonly PBRMATERIAL_ALPHATEST: number;
  52597. /**
  52598. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52599. */
  52600. static readonly PBRMATERIAL_ALPHABLEND: number;
  52601. /**
  52602. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52603. * They are also discarded below the alpha cutoff threshold to improve performances.
  52604. */
  52605. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52606. /**
  52607. * Defines the default value of how much AO map is occluding the analytical lights
  52608. * (point spot...).
  52609. */
  52610. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52611. /**
  52612. * Intensity of the direct lights e.g. the four lights available in your scene.
  52613. * This impacts both the direct diffuse and specular highlights.
  52614. */
  52615. directIntensity: number;
  52616. /**
  52617. * Intensity of the emissive part of the material.
  52618. * This helps controlling the emissive effect without modifying the emissive color.
  52619. */
  52620. emissiveIntensity: number;
  52621. /**
  52622. * Intensity of the environment e.g. how much the environment will light the object
  52623. * either through harmonics for rough material or through the refelction for shiny ones.
  52624. */
  52625. environmentIntensity: number;
  52626. /**
  52627. * This is a special control allowing the reduction of the specular highlights coming from the
  52628. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52629. */
  52630. specularIntensity: number;
  52631. /**
  52632. * Debug Control allowing disabling the bump map on this material.
  52633. */
  52634. disableBumpMap: boolean;
  52635. /**
  52636. * AKA Diffuse Texture in standard nomenclature.
  52637. */
  52638. albedoTexture: BaseTexture;
  52639. /**
  52640. * AKA Occlusion Texture in other nomenclature.
  52641. */
  52642. ambientTexture: BaseTexture;
  52643. /**
  52644. * AKA Occlusion Texture Intensity in other nomenclature.
  52645. */
  52646. ambientTextureStrength: number;
  52647. /**
  52648. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52649. * 1 means it completely occludes it
  52650. * 0 mean it has no impact
  52651. */
  52652. ambientTextureImpactOnAnalyticalLights: number;
  52653. /**
  52654. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52655. */
  52656. opacityTexture: BaseTexture;
  52657. /**
  52658. * Stores the reflection values in a texture.
  52659. */
  52660. reflectionTexture: Nullable<BaseTexture>;
  52661. /**
  52662. * Stores the emissive values in a texture.
  52663. */
  52664. emissiveTexture: BaseTexture;
  52665. /**
  52666. * AKA Specular texture in other nomenclature.
  52667. */
  52668. reflectivityTexture: BaseTexture;
  52669. /**
  52670. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52671. */
  52672. metallicTexture: BaseTexture;
  52673. /**
  52674. * Specifies the metallic scalar of the metallic/roughness workflow.
  52675. * Can also be used to scale the metalness values of the metallic texture.
  52676. */
  52677. metallic: Nullable<number>;
  52678. /**
  52679. * Specifies the roughness scalar of the metallic/roughness workflow.
  52680. * Can also be used to scale the roughness values of the metallic texture.
  52681. */
  52682. roughness: Nullable<number>;
  52683. /**
  52684. * Specifies the an F0 factor to help configuring the material F0.
  52685. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52686. * to 0.5 the previously hard coded value stays the same.
  52687. * Can also be used to scale the F0 values of the metallic texture.
  52688. */
  52689. metallicF0Factor: number;
  52690. /**
  52691. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52692. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52693. * your expectation as it multiplies with the texture data.
  52694. */
  52695. useMetallicF0FactorFromMetallicTexture: boolean;
  52696. /**
  52697. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52698. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52699. */
  52700. microSurfaceTexture: BaseTexture;
  52701. /**
  52702. * Stores surface normal data used to displace a mesh in a texture.
  52703. */
  52704. bumpTexture: BaseTexture;
  52705. /**
  52706. * Stores the pre-calculated light information of a mesh in a texture.
  52707. */
  52708. lightmapTexture: BaseTexture;
  52709. /**
  52710. * Stores the refracted light information in a texture.
  52711. */
  52712. get refractionTexture(): Nullable<BaseTexture>;
  52713. set refractionTexture(value: Nullable<BaseTexture>);
  52714. /**
  52715. * The color of a material in ambient lighting.
  52716. */
  52717. ambientColor: Color3;
  52718. /**
  52719. * AKA Diffuse Color in other nomenclature.
  52720. */
  52721. albedoColor: Color3;
  52722. /**
  52723. * AKA Specular Color in other nomenclature.
  52724. */
  52725. reflectivityColor: Color3;
  52726. /**
  52727. * The color reflected from the material.
  52728. */
  52729. reflectionColor: Color3;
  52730. /**
  52731. * The color emitted from the material.
  52732. */
  52733. emissiveColor: Color3;
  52734. /**
  52735. * AKA Glossiness in other nomenclature.
  52736. */
  52737. microSurface: number;
  52738. /**
  52739. * source material index of refraction (IOR)' / 'destination material IOR.
  52740. */
  52741. get indexOfRefraction(): number;
  52742. set indexOfRefraction(value: number);
  52743. /**
  52744. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52745. */
  52746. get invertRefractionY(): boolean;
  52747. set invertRefractionY(value: boolean);
  52748. /**
  52749. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52750. * Materials half opaque for instance using refraction could benefit from this control.
  52751. */
  52752. get linkRefractionWithTransparency(): boolean;
  52753. set linkRefractionWithTransparency(value: boolean);
  52754. /**
  52755. * If true, the light map contains occlusion information instead of lighting info.
  52756. */
  52757. useLightmapAsShadowmap: boolean;
  52758. /**
  52759. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52760. */
  52761. useAlphaFromAlbedoTexture: boolean;
  52762. /**
  52763. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52764. */
  52765. forceAlphaTest: boolean;
  52766. /**
  52767. * Defines the alpha limits in alpha test mode.
  52768. */
  52769. alphaCutOff: number;
  52770. /**
  52771. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52772. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52773. */
  52774. useSpecularOverAlpha: boolean;
  52775. /**
  52776. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52777. */
  52778. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52779. /**
  52780. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52781. */
  52782. useRoughnessFromMetallicTextureAlpha: boolean;
  52783. /**
  52784. * Specifies if the metallic texture contains the roughness information in its green channel.
  52785. */
  52786. useRoughnessFromMetallicTextureGreen: boolean;
  52787. /**
  52788. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52789. */
  52790. useMetallnessFromMetallicTextureBlue: boolean;
  52791. /**
  52792. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52793. */
  52794. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52795. /**
  52796. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52797. */
  52798. useAmbientInGrayScale: boolean;
  52799. /**
  52800. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52801. * The material will try to infer what glossiness each pixel should be.
  52802. */
  52803. useAutoMicroSurfaceFromReflectivityMap: 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. get usePhysicalLightFalloff(): boolean;
  52810. /**
  52811. * BJS is using an harcoded light falloff based on a manually sets up range.
  52812. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52813. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52814. */
  52815. set usePhysicalLightFalloff(value: boolean);
  52816. /**
  52817. * In order to support the falloff compatibility with gltf, a special mode has been added
  52818. * to reproduce the gltf light falloff.
  52819. */
  52820. get useGLTFLightFalloff(): boolean;
  52821. /**
  52822. * In order to support the falloff compatibility with gltf, a special mode has been added
  52823. * to reproduce the gltf light falloff.
  52824. */
  52825. set useGLTFLightFalloff(value: boolean);
  52826. /**
  52827. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52828. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52829. */
  52830. useRadianceOverAlpha: boolean;
  52831. /**
  52832. * Allows using an object space normal map (instead of tangent space).
  52833. */
  52834. useObjectSpaceNormalMap: boolean;
  52835. /**
  52836. * Allows using the bump map in parallax mode.
  52837. */
  52838. useParallax: boolean;
  52839. /**
  52840. * Allows using the bump map in parallax occlusion mode.
  52841. */
  52842. useParallaxOcclusion: boolean;
  52843. /**
  52844. * Controls the scale bias of the parallax mode.
  52845. */
  52846. parallaxScaleBias: number;
  52847. /**
  52848. * If sets to true, disables all the lights affecting the material.
  52849. */
  52850. disableLighting: boolean;
  52851. /**
  52852. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52853. */
  52854. forceIrradianceInFragment: boolean;
  52855. /**
  52856. * Number of Simultaneous lights allowed on the material.
  52857. */
  52858. maxSimultaneousLights: number;
  52859. /**
  52860. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52861. */
  52862. invertNormalMapX: boolean;
  52863. /**
  52864. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52865. */
  52866. invertNormalMapY: boolean;
  52867. /**
  52868. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52869. */
  52870. twoSidedLighting: boolean;
  52871. /**
  52872. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52873. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52874. */
  52875. useAlphaFresnel: boolean;
  52876. /**
  52877. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52878. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52879. */
  52880. useLinearAlphaFresnel: boolean;
  52881. /**
  52882. * Let user defines the brdf lookup texture used for IBL.
  52883. * A default 8bit version is embedded but you could point at :
  52884. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52885. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52886. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52887. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52888. */
  52889. environmentBRDFTexture: Nullable<BaseTexture>;
  52890. /**
  52891. * Force normal to face away from face.
  52892. */
  52893. forceNormalForward: boolean;
  52894. /**
  52895. * Enables specular anti aliasing in the PBR shader.
  52896. * It will both interacts on the Geometry for analytical and IBL lighting.
  52897. * It also prefilter the roughness map based on the bump values.
  52898. */
  52899. enableSpecularAntiAliasing: boolean;
  52900. /**
  52901. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52902. * makes the reflect vector face the model (under horizon).
  52903. */
  52904. useHorizonOcclusion: boolean;
  52905. /**
  52906. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52907. * too much the area relying on ambient texture to define their ambient occlusion.
  52908. */
  52909. useRadianceOcclusion: boolean;
  52910. /**
  52911. * If set to true, no lighting calculations will be applied.
  52912. */
  52913. unlit: boolean;
  52914. /**
  52915. * Gets the image processing configuration used either in this material.
  52916. */
  52917. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52918. /**
  52919. * Sets the Default image processing configuration used either in the this material.
  52920. *
  52921. * If sets to null, the scene one is in use.
  52922. */
  52923. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52924. /**
  52925. * Gets wether the color curves effect is enabled.
  52926. */
  52927. get cameraColorCurvesEnabled(): boolean;
  52928. /**
  52929. * Sets wether the color curves effect is enabled.
  52930. */
  52931. set cameraColorCurvesEnabled(value: boolean);
  52932. /**
  52933. * Gets wether the color grading effect is enabled.
  52934. */
  52935. get cameraColorGradingEnabled(): boolean;
  52936. /**
  52937. * Gets wether the color grading effect is enabled.
  52938. */
  52939. set cameraColorGradingEnabled(value: boolean);
  52940. /**
  52941. * Gets wether tonemapping is enabled or not.
  52942. */
  52943. get cameraToneMappingEnabled(): boolean;
  52944. /**
  52945. * Sets wether tonemapping is enabled or not
  52946. */
  52947. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): number;
  52954. /**
  52955. * The camera exposure used on this material.
  52956. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52957. * This corresponds to a photographic exposure.
  52958. */
  52959. set cameraExposure(value: number);
  52960. /**
  52961. * Gets The camera contrast used on this material.
  52962. */
  52963. get cameraContrast(): number;
  52964. /**
  52965. * Sets The camera contrast used on this material.
  52966. */
  52967. set cameraContrast(value: number);
  52968. /**
  52969. * Gets the Color Grading 2D Lookup Texture.
  52970. */
  52971. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52972. /**
  52973. * Sets the Color Grading 2D Lookup Texture.
  52974. */
  52975. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52976. /**
  52977. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52978. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52979. * 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;
  52980. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52981. */
  52982. get cameraColorCurves(): Nullable<ColorCurves>;
  52983. /**
  52984. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52985. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52986. * 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;
  52987. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52988. */
  52989. set cameraColorCurves(value: Nullable<ColorCurves>);
  52990. /**
  52991. * Instantiates a new PBRMaterial instance.
  52992. *
  52993. * @param name The material name
  52994. * @param scene The scene the material will be use in.
  52995. */
  52996. constructor(name: string, scene: Scene);
  52997. /**
  52998. * Returns the name of this material class.
  52999. */
  53000. getClassName(): string;
  53001. /**
  53002. * Makes a duplicate of the current material.
  53003. * @param name - name to use for the new material.
  53004. */
  53005. clone(name: string): PBRMaterial;
  53006. /**
  53007. * Serializes this PBR Material.
  53008. * @returns - An object with the serialized material.
  53009. */
  53010. serialize(): any;
  53011. /**
  53012. * Parses a PBR Material from a serialized object.
  53013. * @param source - Serialized object.
  53014. * @param scene - BJS scene instance.
  53015. * @param rootUrl - url for the scene object
  53016. * @returns - PBRMaterial
  53017. */
  53018. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53019. }
  53020. }
  53021. declare module "babylonjs/Misc/dds" {
  53022. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53023. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53024. import { Nullable } from "babylonjs/types";
  53025. import { Scene } from "babylonjs/scene";
  53026. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53027. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53028. /**
  53029. * Direct draw surface info
  53030. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53031. */
  53032. export interface DDSInfo {
  53033. /**
  53034. * Width of the texture
  53035. */
  53036. width: number;
  53037. /**
  53038. * Width of the texture
  53039. */
  53040. height: number;
  53041. /**
  53042. * Number of Mipmaps for the texture
  53043. * @see https://en.wikipedia.org/wiki/Mipmap
  53044. */
  53045. mipmapCount: number;
  53046. /**
  53047. * If the textures format is a known fourCC format
  53048. * @see https://www.fourcc.org/
  53049. */
  53050. isFourCC: boolean;
  53051. /**
  53052. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53053. */
  53054. isRGB: boolean;
  53055. /**
  53056. * If the texture is a lumincance format
  53057. */
  53058. isLuminance: boolean;
  53059. /**
  53060. * If this is a cube texture
  53061. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53062. */
  53063. isCube: boolean;
  53064. /**
  53065. * If the texture is a compressed format eg. FOURCC_DXT1
  53066. */
  53067. isCompressed: boolean;
  53068. /**
  53069. * The dxgiFormat of the texture
  53070. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53071. */
  53072. dxgiFormat: number;
  53073. /**
  53074. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53075. */
  53076. textureType: number;
  53077. /**
  53078. * Sphericle polynomial created for the dds texture
  53079. */
  53080. sphericalPolynomial?: SphericalPolynomial;
  53081. }
  53082. /**
  53083. * Class used to provide DDS decompression tools
  53084. */
  53085. export class DDSTools {
  53086. /**
  53087. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53088. */
  53089. static StoreLODInAlphaChannel: boolean;
  53090. /**
  53091. * Gets DDS information from an array buffer
  53092. * @param arrayBuffer defines the array buffer to read data from
  53093. * @returns the DDS information
  53094. */
  53095. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53096. private static _FloatView;
  53097. private static _Int32View;
  53098. private static _ToHalfFloat;
  53099. private static _FromHalfFloat;
  53100. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53101. private static _GetHalfFloatRGBAArrayBuffer;
  53102. private static _GetFloatRGBAArrayBuffer;
  53103. private static _GetFloatAsUIntRGBAArrayBuffer;
  53104. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53105. private static _GetRGBAArrayBuffer;
  53106. private static _ExtractLongWordOrder;
  53107. private static _GetRGBArrayBuffer;
  53108. private static _GetLuminanceArrayBuffer;
  53109. /**
  53110. * Uploads DDS Levels to a Babylon Texture
  53111. * @hidden
  53112. */
  53113. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53114. }
  53115. module "babylonjs/Engines/thinEngine" {
  53116. interface ThinEngine {
  53117. /**
  53118. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53119. * @param rootUrl defines the url where the file to load is located
  53120. * @param scene defines the current scene
  53121. * @param lodScale defines scale to apply to the mip map selection
  53122. * @param lodOffset defines offset to apply to the mip map selection
  53123. * @param onLoad defines an optional callback raised when the texture is loaded
  53124. * @param onError defines an optional callback raised if there is an issue to load the texture
  53125. * @param format defines the format of the data
  53126. * @param forcedExtension defines the extension to use to pick the right loader
  53127. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53128. * @returns the cube texture as an InternalTexture
  53129. */
  53130. 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;
  53131. }
  53132. }
  53133. }
  53134. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53135. import { Nullable } from "babylonjs/types";
  53136. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53137. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53138. /**
  53139. * Implementation of the DDS Texture Loader.
  53140. * @hidden
  53141. */
  53142. export class _DDSTextureLoader implements IInternalTextureLoader {
  53143. /**
  53144. * Defines wether the loader supports cascade loading the different faces.
  53145. */
  53146. readonly supportCascades: boolean;
  53147. /**
  53148. * This returns if the loader support the current file information.
  53149. * @param extension defines the file extension of the file being loaded
  53150. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53151. * @param fallback defines the fallback internal texture if any
  53152. * @param isBase64 defines whether the texture is encoded as a base64
  53153. * @param isBuffer defines whether the texture data are stored as a buffer
  53154. * @returns true if the loader can load the specified file
  53155. */
  53156. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53157. /**
  53158. * Transform the url before loading if required.
  53159. * @param rootUrl the url of the texture
  53160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53161. * @returns the transformed texture
  53162. */
  53163. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53164. /**
  53165. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53166. * @param rootUrl the url of the texture
  53167. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53168. * @returns the fallback texture
  53169. */
  53170. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53171. /**
  53172. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53173. * @param data contains the texture data
  53174. * @param texture defines the BabylonJS internal texture
  53175. * @param createPolynomials will be true if polynomials have been requested
  53176. * @param onLoad defines the callback to trigger once the texture is ready
  53177. * @param onError defines the callback to trigger in case of error
  53178. */
  53179. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53180. /**
  53181. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53182. * @param data contains the texture data
  53183. * @param texture defines the BabylonJS internal texture
  53184. * @param callback defines the method to call once ready to upload
  53185. */
  53186. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53187. }
  53188. }
  53189. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53190. import { Nullable } from "babylonjs/types";
  53191. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53192. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53193. /**
  53194. * Implementation of the ENV Texture Loader.
  53195. * @hidden
  53196. */
  53197. export class _ENVTextureLoader implements IInternalTextureLoader {
  53198. /**
  53199. * Defines wether the loader supports cascade loading the different faces.
  53200. */
  53201. readonly supportCascades: boolean;
  53202. /**
  53203. * This returns if the loader support the current file information.
  53204. * @param extension defines the file extension of the file being loaded
  53205. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53206. * @param fallback defines the fallback internal texture if any
  53207. * @param isBase64 defines whether the texture is encoded as a base64
  53208. * @param isBuffer defines whether the texture data are stored as a buffer
  53209. * @returns true if the loader can load the specified file
  53210. */
  53211. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53212. /**
  53213. * Transform the url before loading if required.
  53214. * @param rootUrl the url of the texture
  53215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53216. * @returns the transformed texture
  53217. */
  53218. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53219. /**
  53220. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53221. * @param rootUrl the url of the texture
  53222. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53223. * @returns the fallback texture
  53224. */
  53225. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53226. /**
  53227. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53228. * @param data contains the texture data
  53229. * @param texture defines the BabylonJS internal texture
  53230. * @param createPolynomials will be true if polynomials have been requested
  53231. * @param onLoad defines the callback to trigger once the texture is ready
  53232. * @param onError defines the callback to trigger in case of error
  53233. */
  53234. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53235. /**
  53236. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53237. * @param data contains the texture data
  53238. * @param texture defines the BabylonJS internal texture
  53239. * @param callback defines the method to call once ready to upload
  53240. */
  53241. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53242. }
  53243. }
  53244. declare module "babylonjs/Misc/khronosTextureContainer" {
  53245. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53246. /**
  53247. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53248. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53249. */
  53250. export class KhronosTextureContainer {
  53251. /** contents of the KTX container file */
  53252. arrayBuffer: any;
  53253. private static HEADER_LEN;
  53254. private static COMPRESSED_2D;
  53255. private static COMPRESSED_3D;
  53256. private static TEX_2D;
  53257. private static TEX_3D;
  53258. /**
  53259. * Gets the openGL type
  53260. */
  53261. glType: number;
  53262. /**
  53263. * Gets the openGL type size
  53264. */
  53265. glTypeSize: number;
  53266. /**
  53267. * Gets the openGL format
  53268. */
  53269. glFormat: number;
  53270. /**
  53271. * Gets the openGL internal format
  53272. */
  53273. glInternalFormat: number;
  53274. /**
  53275. * Gets the base internal format
  53276. */
  53277. glBaseInternalFormat: number;
  53278. /**
  53279. * Gets image width in pixel
  53280. */
  53281. pixelWidth: number;
  53282. /**
  53283. * Gets image height in pixel
  53284. */
  53285. pixelHeight: number;
  53286. /**
  53287. * Gets image depth in pixels
  53288. */
  53289. pixelDepth: number;
  53290. /**
  53291. * Gets the number of array elements
  53292. */
  53293. numberOfArrayElements: number;
  53294. /**
  53295. * Gets the number of faces
  53296. */
  53297. numberOfFaces: number;
  53298. /**
  53299. * Gets the number of mipmap levels
  53300. */
  53301. numberOfMipmapLevels: number;
  53302. /**
  53303. * Gets the bytes of key value data
  53304. */
  53305. bytesOfKeyValueData: number;
  53306. /**
  53307. * Gets the load type
  53308. */
  53309. loadType: number;
  53310. /**
  53311. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53312. */
  53313. isInvalid: boolean;
  53314. /**
  53315. * Creates a new KhronosTextureContainer
  53316. * @param arrayBuffer contents of the KTX container file
  53317. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53318. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53319. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53320. */
  53321. constructor(
  53322. /** contents of the KTX container file */
  53323. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53324. /**
  53325. * Uploads KTX content to a Babylon Texture.
  53326. * It is assumed that the texture has already been created & is currently bound
  53327. * @hidden
  53328. */
  53329. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53330. private _upload2DCompressedLevels;
  53331. }
  53332. }
  53333. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  53334. import { Nullable } from "babylonjs/types";
  53335. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53336. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53337. /**
  53338. * Implementation of the KTX Texture Loader.
  53339. * @hidden
  53340. */
  53341. export class _KTXTextureLoader implements IInternalTextureLoader {
  53342. /**
  53343. * Defines wether the loader supports cascade loading the different faces.
  53344. */
  53345. readonly supportCascades: boolean;
  53346. /**
  53347. * This returns if the loader support the current file information.
  53348. * @param extension defines the file extension of the file being loaded
  53349. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53350. * @param fallback defines the fallback internal texture if any
  53351. * @param isBase64 defines whether the texture is encoded as a base64
  53352. * @param isBuffer defines whether the texture data are stored as a buffer
  53353. * @returns true if the loader can load the specified file
  53354. */
  53355. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53356. /**
  53357. * Transform the url before loading if required.
  53358. * @param rootUrl the url of the texture
  53359. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53360. * @returns the transformed texture
  53361. */
  53362. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53363. /**
  53364. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53365. * @param rootUrl the url of the texture
  53366. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53367. * @returns the fallback texture
  53368. */
  53369. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53370. /**
  53371. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53372. * @param data contains the texture data
  53373. * @param texture defines the BabylonJS internal texture
  53374. * @param createPolynomials will be true if polynomials have been requested
  53375. * @param onLoad defines the callback to trigger once the texture is ready
  53376. * @param onError defines the callback to trigger in case of error
  53377. */
  53378. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53379. /**
  53380. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53381. * @param data contains the texture data
  53382. * @param texture defines the BabylonJS internal texture
  53383. * @param callback defines the method to call once ready to upload
  53384. */
  53385. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53386. }
  53387. }
  53388. declare module "babylonjs/Helpers/sceneHelpers" {
  53389. import { Nullable } from "babylonjs/types";
  53390. import { Mesh } from "babylonjs/Meshes/mesh";
  53391. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53392. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  53393. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  53394. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53395. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53396. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53397. import "babylonjs/Meshes/Builders/boxBuilder";
  53398. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  53399. /** @hidden */
  53400. export var _forceSceneHelpersToBundle: boolean;
  53401. module "babylonjs/scene" {
  53402. interface Scene {
  53403. /**
  53404. * Creates a default light for the scene.
  53405. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53406. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53407. */
  53408. createDefaultLight(replace?: boolean): void;
  53409. /**
  53410. * Creates a default camera for the scene.
  53411. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53412. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53413. * @param replace has default false, when true replaces the active camera in the scene
  53414. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53415. */
  53416. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53417. /**
  53418. * Creates a default camera and a default light.
  53419. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53420. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53421. * @param replace has the default false, when true replaces the active camera/light in the scene
  53422. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53423. */
  53424. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53425. /**
  53426. * Creates a new sky box
  53427. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53428. * @param environmentTexture defines the texture to use as environment texture
  53429. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53430. * @param scale defines the overall scale of the skybox
  53431. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53432. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53433. * @returns a new mesh holding the sky box
  53434. */
  53435. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53436. /**
  53437. * Creates a new environment
  53438. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53439. * @param options defines the options you can use to configure the environment
  53440. * @returns the new EnvironmentHelper
  53441. */
  53442. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53443. /**
  53444. * Creates a new VREXperienceHelper
  53445. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53446. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53447. * @returns a new VREXperienceHelper
  53448. */
  53449. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53450. /**
  53451. * Creates a new WebXRDefaultExperience
  53452. * @see http://doc.babylonjs.com/how_to/webxr
  53453. * @param options experience options
  53454. * @returns a promise for a new WebXRDefaultExperience
  53455. */
  53456. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53457. }
  53458. }
  53459. }
  53460. declare module "babylonjs/Helpers/videoDome" {
  53461. import { Scene } from "babylonjs/scene";
  53462. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53463. import { Mesh } from "babylonjs/Meshes/mesh";
  53464. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  53465. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  53466. import "babylonjs/Meshes/Builders/sphereBuilder";
  53467. /**
  53468. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53469. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53470. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53471. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53472. */
  53473. export class VideoDome extends TransformNode {
  53474. /**
  53475. * Define the video source as a Monoscopic panoramic 360 video.
  53476. */
  53477. static readonly MODE_MONOSCOPIC: number;
  53478. /**
  53479. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53480. */
  53481. static readonly MODE_TOPBOTTOM: number;
  53482. /**
  53483. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53484. */
  53485. static readonly MODE_SIDEBYSIDE: number;
  53486. private _halfDome;
  53487. private _useDirectMapping;
  53488. /**
  53489. * The video texture being displayed on the sphere
  53490. */
  53491. protected _videoTexture: VideoTexture;
  53492. /**
  53493. * Gets the video texture being displayed on the sphere
  53494. */
  53495. get videoTexture(): VideoTexture;
  53496. /**
  53497. * The skybox material
  53498. */
  53499. protected _material: BackgroundMaterial;
  53500. /**
  53501. * The surface used for the skybox
  53502. */
  53503. protected _mesh: Mesh;
  53504. /**
  53505. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53506. */
  53507. private _halfDomeMask;
  53508. /**
  53509. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53510. * Also see the options.resolution property.
  53511. */
  53512. get fovMultiplier(): number;
  53513. set fovMultiplier(value: number);
  53514. private _videoMode;
  53515. /**
  53516. * Gets or set the current video mode for the video. It can be:
  53517. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53518. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53519. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53520. */
  53521. get videoMode(): number;
  53522. set videoMode(value: number);
  53523. /**
  53524. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53525. *
  53526. */
  53527. get halfDome(): boolean;
  53528. /**
  53529. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53530. */
  53531. set halfDome(enabled: boolean);
  53532. /**
  53533. * Oberserver used in Stereoscopic VR Mode.
  53534. */
  53535. private _onBeforeCameraRenderObserver;
  53536. /**
  53537. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53538. * @param name Element's name, child elements will append suffixes for their own names.
  53539. * @param urlsOrVideo defines the url(s) or the video element to use
  53540. * @param options An object containing optional or exposed sub element properties
  53541. */
  53542. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53543. resolution?: number;
  53544. clickToPlay?: boolean;
  53545. autoPlay?: boolean;
  53546. loop?: boolean;
  53547. size?: number;
  53548. poster?: string;
  53549. faceForward?: boolean;
  53550. useDirectMapping?: boolean;
  53551. halfDomeMode?: boolean;
  53552. }, scene: Scene);
  53553. private _changeVideoMode;
  53554. /**
  53555. * Releases resources associated with this node.
  53556. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53557. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53558. */
  53559. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53560. }
  53561. }
  53562. declare module "babylonjs/Helpers/index" {
  53563. export * from "babylonjs/Helpers/environmentHelper";
  53564. export * from "babylonjs/Helpers/photoDome";
  53565. export * from "babylonjs/Helpers/sceneHelpers";
  53566. export * from "babylonjs/Helpers/videoDome";
  53567. }
  53568. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  53569. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53570. import { IDisposable } from "babylonjs/scene";
  53571. import { Engine } from "babylonjs/Engines/engine";
  53572. /**
  53573. * This class can be used to get instrumentation data from a Babylon engine
  53574. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53575. */
  53576. export class EngineInstrumentation implements IDisposable {
  53577. /**
  53578. * Define the instrumented engine.
  53579. */
  53580. engine: Engine;
  53581. private _captureGPUFrameTime;
  53582. private _gpuFrameTimeToken;
  53583. private _gpuFrameTime;
  53584. private _captureShaderCompilationTime;
  53585. private _shaderCompilationTime;
  53586. private _onBeginFrameObserver;
  53587. private _onEndFrameObserver;
  53588. private _onBeforeShaderCompilationObserver;
  53589. private _onAfterShaderCompilationObserver;
  53590. /**
  53591. * Gets the perf counter used for GPU frame time
  53592. */
  53593. get gpuFrameTimeCounter(): PerfCounter;
  53594. /**
  53595. * Gets the GPU frame time capture status
  53596. */
  53597. get captureGPUFrameTime(): boolean;
  53598. /**
  53599. * Enable or disable the GPU frame time capture
  53600. */
  53601. set captureGPUFrameTime(value: boolean);
  53602. /**
  53603. * Gets the perf counter used for shader compilation time
  53604. */
  53605. get shaderCompilationTimeCounter(): PerfCounter;
  53606. /**
  53607. * Gets the shader compilation time capture status
  53608. */
  53609. get captureShaderCompilationTime(): boolean;
  53610. /**
  53611. * Enable or disable the shader compilation time capture
  53612. */
  53613. set captureShaderCompilationTime(value: boolean);
  53614. /**
  53615. * Instantiates a new engine instrumentation.
  53616. * This class can be used to get instrumentation data from a Babylon engine
  53617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53618. * @param engine Defines the engine to instrument
  53619. */
  53620. constructor(
  53621. /**
  53622. * Define the instrumented engine.
  53623. */
  53624. engine: Engine);
  53625. /**
  53626. * Dispose and release associated resources.
  53627. */
  53628. dispose(): void;
  53629. }
  53630. }
  53631. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  53632. import { Scene, IDisposable } from "babylonjs/scene";
  53633. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53634. /**
  53635. * This class can be used to get instrumentation data from a Babylon engine
  53636. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53637. */
  53638. export class SceneInstrumentation implements IDisposable {
  53639. /**
  53640. * Defines the scene to instrument
  53641. */
  53642. scene: Scene;
  53643. private _captureActiveMeshesEvaluationTime;
  53644. private _activeMeshesEvaluationTime;
  53645. private _captureRenderTargetsRenderTime;
  53646. private _renderTargetsRenderTime;
  53647. private _captureFrameTime;
  53648. private _frameTime;
  53649. private _captureRenderTime;
  53650. private _renderTime;
  53651. private _captureInterFrameTime;
  53652. private _interFrameTime;
  53653. private _captureParticlesRenderTime;
  53654. private _particlesRenderTime;
  53655. private _captureSpritesRenderTime;
  53656. private _spritesRenderTime;
  53657. private _capturePhysicsTime;
  53658. private _physicsTime;
  53659. private _captureAnimationsTime;
  53660. private _animationsTime;
  53661. private _captureCameraRenderTime;
  53662. private _cameraRenderTime;
  53663. private _onBeforeActiveMeshesEvaluationObserver;
  53664. private _onAfterActiveMeshesEvaluationObserver;
  53665. private _onBeforeRenderTargetsRenderObserver;
  53666. private _onAfterRenderTargetsRenderObserver;
  53667. private _onAfterRenderObserver;
  53668. private _onBeforeDrawPhaseObserver;
  53669. private _onAfterDrawPhaseObserver;
  53670. private _onBeforeAnimationsObserver;
  53671. private _onBeforeParticlesRenderingObserver;
  53672. private _onAfterParticlesRenderingObserver;
  53673. private _onBeforeSpritesRenderingObserver;
  53674. private _onAfterSpritesRenderingObserver;
  53675. private _onBeforePhysicsObserver;
  53676. private _onAfterPhysicsObserver;
  53677. private _onAfterAnimationsObserver;
  53678. private _onBeforeCameraRenderObserver;
  53679. private _onAfterCameraRenderObserver;
  53680. /**
  53681. * Gets the perf counter used for active meshes evaluation time
  53682. */
  53683. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53684. /**
  53685. * Gets the active meshes evaluation time capture status
  53686. */
  53687. get captureActiveMeshesEvaluationTime(): boolean;
  53688. /**
  53689. * Enable or disable the active meshes evaluation time capture
  53690. */
  53691. set captureActiveMeshesEvaluationTime(value: boolean);
  53692. /**
  53693. * Gets the perf counter used for render targets render time
  53694. */
  53695. get renderTargetsRenderTimeCounter(): PerfCounter;
  53696. /**
  53697. * Gets the render targets render time capture status
  53698. */
  53699. get captureRenderTargetsRenderTime(): boolean;
  53700. /**
  53701. * Enable or disable the render targets render time capture
  53702. */
  53703. set captureRenderTargetsRenderTime(value: boolean);
  53704. /**
  53705. * Gets the perf counter used for particles render time
  53706. */
  53707. get particlesRenderTimeCounter(): PerfCounter;
  53708. /**
  53709. * Gets the particles render time capture status
  53710. */
  53711. get captureParticlesRenderTime(): boolean;
  53712. /**
  53713. * Enable or disable the particles render time capture
  53714. */
  53715. set captureParticlesRenderTime(value: boolean);
  53716. /**
  53717. * Gets the perf counter used for sprites render time
  53718. */
  53719. get spritesRenderTimeCounter(): PerfCounter;
  53720. /**
  53721. * Gets the sprites render time capture status
  53722. */
  53723. get captureSpritesRenderTime(): boolean;
  53724. /**
  53725. * Enable or disable the sprites render time capture
  53726. */
  53727. set captureSpritesRenderTime(value: boolean);
  53728. /**
  53729. * Gets the perf counter used for physics time
  53730. */
  53731. get physicsTimeCounter(): PerfCounter;
  53732. /**
  53733. * Gets the physics time capture status
  53734. */
  53735. get capturePhysicsTime(): boolean;
  53736. /**
  53737. * Enable or disable the physics time capture
  53738. */
  53739. set capturePhysicsTime(value: boolean);
  53740. /**
  53741. * Gets the perf counter used for animations time
  53742. */
  53743. get animationsTimeCounter(): PerfCounter;
  53744. /**
  53745. * Gets the animations time capture status
  53746. */
  53747. get captureAnimationsTime(): boolean;
  53748. /**
  53749. * Enable or disable the animations time capture
  53750. */
  53751. set captureAnimationsTime(value: boolean);
  53752. /**
  53753. * Gets the perf counter used for frame time capture
  53754. */
  53755. get frameTimeCounter(): PerfCounter;
  53756. /**
  53757. * Gets the frame time capture status
  53758. */
  53759. get captureFrameTime(): boolean;
  53760. /**
  53761. * Enable or disable the frame time capture
  53762. */
  53763. set captureFrameTime(value: boolean);
  53764. /**
  53765. * Gets the perf counter used for inter-frames time capture
  53766. */
  53767. get interFrameTimeCounter(): PerfCounter;
  53768. /**
  53769. * Gets the inter-frames time capture status
  53770. */
  53771. get captureInterFrameTime(): boolean;
  53772. /**
  53773. * Enable or disable the inter-frames time capture
  53774. */
  53775. set captureInterFrameTime(value: boolean);
  53776. /**
  53777. * Gets the perf counter used for render time capture
  53778. */
  53779. get renderTimeCounter(): PerfCounter;
  53780. /**
  53781. * Gets the render time capture status
  53782. */
  53783. get captureRenderTime(): boolean;
  53784. /**
  53785. * Enable or disable the render time capture
  53786. */
  53787. set captureRenderTime(value: boolean);
  53788. /**
  53789. * Gets the perf counter used for camera render time capture
  53790. */
  53791. get cameraRenderTimeCounter(): PerfCounter;
  53792. /**
  53793. * Gets the camera render time capture status
  53794. */
  53795. get captureCameraRenderTime(): boolean;
  53796. /**
  53797. * Enable or disable the camera render time capture
  53798. */
  53799. set captureCameraRenderTime(value: boolean);
  53800. /**
  53801. * Gets the perf counter used for draw calls
  53802. */
  53803. get drawCallsCounter(): PerfCounter;
  53804. /**
  53805. * Instantiates a new scene instrumentation.
  53806. * This class can be used to get instrumentation data from a Babylon engine
  53807. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53808. * @param scene Defines the scene to instrument
  53809. */
  53810. constructor(
  53811. /**
  53812. * Defines the scene to instrument
  53813. */
  53814. scene: Scene);
  53815. /**
  53816. * Dispose and release associated resources.
  53817. */
  53818. dispose(): void;
  53819. }
  53820. }
  53821. declare module "babylonjs/Instrumentation/index" {
  53822. export * from "babylonjs/Instrumentation/engineInstrumentation";
  53823. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  53824. export * from "babylonjs/Instrumentation/timeToken";
  53825. }
  53826. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  53827. /** @hidden */
  53828. export var glowMapGenerationPixelShader: {
  53829. name: string;
  53830. shader: string;
  53831. };
  53832. }
  53833. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  53834. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53837. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53839. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53840. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53841. /** @hidden */
  53842. export var glowMapGenerationVertexShader: {
  53843. name: string;
  53844. shader: string;
  53845. };
  53846. }
  53847. declare module "babylonjs/Layers/effectLayer" {
  53848. import { Observable } from "babylonjs/Misc/observable";
  53849. import { Nullable } from "babylonjs/types";
  53850. import { Camera } from "babylonjs/Cameras/camera";
  53851. import { Scene } from "babylonjs/scene";
  53852. import { ISize } from "babylonjs/Maths/math.size";
  53853. import { Color4 } from "babylonjs/Maths/math.color";
  53854. import { Engine } from "babylonjs/Engines/engine";
  53855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53857. import { Mesh } from "babylonjs/Meshes/mesh";
  53858. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53860. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53861. import { Effect } from "babylonjs/Materials/effect";
  53862. import { Material } from "babylonjs/Materials/material";
  53863. import "babylonjs/Shaders/glowMapGeneration.fragment";
  53864. import "babylonjs/Shaders/glowMapGeneration.vertex";
  53865. /**
  53866. * Effect layer options. This helps customizing the behaviour
  53867. * of the effect layer.
  53868. */
  53869. export interface IEffectLayerOptions {
  53870. /**
  53871. * Multiplication factor apply to the canvas size to compute the render target size
  53872. * used to generated the objects (the smaller the faster).
  53873. */
  53874. mainTextureRatio: number;
  53875. /**
  53876. * Enforces a fixed size texture to ensure effect stability across devices.
  53877. */
  53878. mainTextureFixedSize?: number;
  53879. /**
  53880. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53881. */
  53882. alphaBlendingMode: number;
  53883. /**
  53884. * The camera attached to the layer.
  53885. */
  53886. camera: Nullable<Camera>;
  53887. /**
  53888. * The rendering group to draw the layer in.
  53889. */
  53890. renderingGroupId: number;
  53891. }
  53892. /**
  53893. * The effect layer Helps adding post process effect blended with the main pass.
  53894. *
  53895. * This can be for instance use to generate glow or higlight effects on the scene.
  53896. *
  53897. * The effect layer class can not be used directly and is intented to inherited from to be
  53898. * customized per effects.
  53899. */
  53900. export abstract class EffectLayer {
  53901. private _vertexBuffers;
  53902. private _indexBuffer;
  53903. private _cachedDefines;
  53904. private _effectLayerMapGenerationEffect;
  53905. private _effectLayerOptions;
  53906. private _mergeEffect;
  53907. protected _scene: Scene;
  53908. protected _engine: Engine;
  53909. protected _maxSize: number;
  53910. protected _mainTextureDesiredSize: ISize;
  53911. protected _mainTexture: RenderTargetTexture;
  53912. protected _shouldRender: boolean;
  53913. protected _postProcesses: PostProcess[];
  53914. protected _textures: BaseTexture[];
  53915. protected _emissiveTextureAndColor: {
  53916. texture: Nullable<BaseTexture>;
  53917. color: Color4;
  53918. };
  53919. /**
  53920. * The name of the layer
  53921. */
  53922. name: string;
  53923. /**
  53924. * The clear color of the texture used to generate the glow map.
  53925. */
  53926. neutralColor: Color4;
  53927. /**
  53928. * Specifies wether the highlight layer is enabled or not.
  53929. */
  53930. isEnabled: boolean;
  53931. /**
  53932. * Gets the camera attached to the layer.
  53933. */
  53934. get camera(): Nullable<Camera>;
  53935. /**
  53936. * Gets the rendering group id the layer should render in.
  53937. */
  53938. get renderingGroupId(): number;
  53939. set renderingGroupId(renderingGroupId: number);
  53940. /**
  53941. * An event triggered when the effect layer has been disposed.
  53942. */
  53943. onDisposeObservable: Observable<EffectLayer>;
  53944. /**
  53945. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53946. */
  53947. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53948. /**
  53949. * An event triggered when the generated texture is being merged in the scene.
  53950. */
  53951. onBeforeComposeObservable: Observable<EffectLayer>;
  53952. /**
  53953. * An event triggered when the mesh is rendered into the effect render target.
  53954. */
  53955. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53956. /**
  53957. * An event triggered after the mesh has been rendered into the effect render target.
  53958. */
  53959. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53960. /**
  53961. * An event triggered when the generated texture has been merged in the scene.
  53962. */
  53963. onAfterComposeObservable: Observable<EffectLayer>;
  53964. /**
  53965. * An event triggered when the efffect layer changes its size.
  53966. */
  53967. onSizeChangedObservable: Observable<EffectLayer>;
  53968. /** @hidden */
  53969. static _SceneComponentInitialization: (scene: Scene) => void;
  53970. /**
  53971. * Instantiates a new effect Layer and references it in the scene.
  53972. * @param name The name of the layer
  53973. * @param scene The scene to use the layer in
  53974. */
  53975. constructor(
  53976. /** The Friendly of the effect in the scene */
  53977. name: string, scene: Scene);
  53978. /**
  53979. * Get the effect name of the layer.
  53980. * @return The effect name
  53981. */
  53982. abstract getEffectName(): string;
  53983. /**
  53984. * Checks for the readiness of the element composing the layer.
  53985. * @param subMesh the mesh to check for
  53986. * @param useInstances specify wether or not to use instances to render the mesh
  53987. * @return true if ready otherwise, false
  53988. */
  53989. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53990. /**
  53991. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53992. * @returns true if the effect requires stencil during the main canvas render pass.
  53993. */
  53994. abstract needStencil(): boolean;
  53995. /**
  53996. * Create the merge effect. This is the shader use to blit the information back
  53997. * to the main canvas at the end of the scene rendering.
  53998. * @returns The effect containing the shader used to merge the effect on the main canvas
  53999. */
  54000. protected abstract _createMergeEffect(): Effect;
  54001. /**
  54002. * Creates the render target textures and post processes used in the effect layer.
  54003. */
  54004. protected abstract _createTextureAndPostProcesses(): void;
  54005. /**
  54006. * Implementation specific of rendering the generating effect on the main canvas.
  54007. * @param effect The effect used to render through
  54008. */
  54009. protected abstract _internalRender(effect: Effect): void;
  54010. /**
  54011. * Sets the required values for both the emissive texture and and the main color.
  54012. */
  54013. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54014. /**
  54015. * Free any resources and references associated to a mesh.
  54016. * Internal use
  54017. * @param mesh The mesh to free.
  54018. */
  54019. abstract _disposeMesh(mesh: Mesh): void;
  54020. /**
  54021. * Serializes this layer (Glow or Highlight for example)
  54022. * @returns a serialized layer object
  54023. */
  54024. abstract serialize?(): any;
  54025. /**
  54026. * Initializes the effect layer with the required options.
  54027. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54028. */
  54029. protected _init(options: Partial<IEffectLayerOptions>): void;
  54030. /**
  54031. * Generates the index buffer of the full screen quad blending to the main canvas.
  54032. */
  54033. private _generateIndexBuffer;
  54034. /**
  54035. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54036. */
  54037. private _generateVertexBuffer;
  54038. /**
  54039. * Sets the main texture desired size which is the closest power of two
  54040. * of the engine canvas size.
  54041. */
  54042. private _setMainTextureSize;
  54043. /**
  54044. * Creates the main texture for the effect layer.
  54045. */
  54046. protected _createMainTexture(): void;
  54047. /**
  54048. * Adds specific effects defines.
  54049. * @param defines The defines to add specifics to.
  54050. */
  54051. protected _addCustomEffectDefines(defines: string[]): void;
  54052. /**
  54053. * Checks for the readiness of the element composing the layer.
  54054. * @param subMesh the mesh to check for
  54055. * @param useInstances specify wether or not to use instances to render the mesh
  54056. * @param emissiveTexture the associated emissive texture used to generate the glow
  54057. * @return true if ready otherwise, false
  54058. */
  54059. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54060. /**
  54061. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54062. */
  54063. render(): void;
  54064. /**
  54065. * Determine if a given mesh will be used in the current effect.
  54066. * @param mesh mesh to test
  54067. * @returns true if the mesh will be used
  54068. */
  54069. hasMesh(mesh: AbstractMesh): boolean;
  54070. /**
  54071. * Returns true if the layer contains information to display, otherwise false.
  54072. * @returns true if the glow layer should be rendered
  54073. */
  54074. shouldRender(): boolean;
  54075. /**
  54076. * Returns true if the mesh should render, otherwise false.
  54077. * @param mesh The mesh to render
  54078. * @returns true if it should render otherwise false
  54079. */
  54080. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54081. /**
  54082. * Returns true if the mesh can be rendered, otherwise false.
  54083. * @param mesh The mesh to render
  54084. * @param material The material used on the mesh
  54085. * @returns true if it can be rendered otherwise false
  54086. */
  54087. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54088. /**
  54089. * Returns true if the mesh should render, otherwise false.
  54090. * @param mesh The mesh to render
  54091. * @returns true if it should render otherwise false
  54092. */
  54093. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54094. /**
  54095. * Renders the submesh passed in parameter to the generation map.
  54096. */
  54097. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54098. /**
  54099. * Defines wether the current material of the mesh should be use to render the effect.
  54100. * @param mesh defines the current mesh to render
  54101. */
  54102. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54103. /**
  54104. * Rebuild the required buffers.
  54105. * @hidden Internal use only.
  54106. */
  54107. _rebuild(): void;
  54108. /**
  54109. * Dispose only the render target textures and post process.
  54110. */
  54111. private _disposeTextureAndPostProcesses;
  54112. /**
  54113. * Dispose the highlight layer and free resources.
  54114. */
  54115. dispose(): void;
  54116. /**
  54117. * Gets the class name of the effect layer
  54118. * @returns the string with the class name of the effect layer
  54119. */
  54120. getClassName(): string;
  54121. /**
  54122. * Creates an effect layer from parsed effect layer data
  54123. * @param parsedEffectLayer defines effect layer data
  54124. * @param scene defines the current scene
  54125. * @param rootUrl defines the root URL containing the effect layer information
  54126. * @returns a parsed effect Layer
  54127. */
  54128. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54129. }
  54130. }
  54131. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54132. import { Scene } from "babylonjs/scene";
  54133. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54134. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54135. import { AbstractScene } from "babylonjs/abstractScene";
  54136. module "babylonjs/abstractScene" {
  54137. interface AbstractScene {
  54138. /**
  54139. * The list of effect layers (highlights/glow) added to the scene
  54140. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54141. * @see http://doc.babylonjs.com/how_to/glow_layer
  54142. */
  54143. effectLayers: Array<EffectLayer>;
  54144. /**
  54145. * Removes the given effect layer from this scene.
  54146. * @param toRemove defines the effect layer to remove
  54147. * @returns the index of the removed effect layer
  54148. */
  54149. removeEffectLayer(toRemove: EffectLayer): number;
  54150. /**
  54151. * Adds the given effect layer to this scene
  54152. * @param newEffectLayer defines the effect layer to add
  54153. */
  54154. addEffectLayer(newEffectLayer: EffectLayer): void;
  54155. }
  54156. }
  54157. /**
  54158. * Defines the layer scene component responsible to manage any effect layers
  54159. * in a given scene.
  54160. */
  54161. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54162. /**
  54163. * The component name helpfull to identify the component in the list of scene components.
  54164. */
  54165. readonly name: string;
  54166. /**
  54167. * The scene the component belongs to.
  54168. */
  54169. scene: Scene;
  54170. private _engine;
  54171. private _renderEffects;
  54172. private _needStencil;
  54173. private _previousStencilState;
  54174. /**
  54175. * Creates a new instance of the component for the given scene
  54176. * @param scene Defines the scene to register the component in
  54177. */
  54178. constructor(scene: Scene);
  54179. /**
  54180. * Registers the component in a given scene
  54181. */
  54182. register(): void;
  54183. /**
  54184. * Rebuilds the elements related to this component in case of
  54185. * context lost for instance.
  54186. */
  54187. rebuild(): void;
  54188. /**
  54189. * Serializes the component data to the specified json object
  54190. * @param serializationObject The object to serialize to
  54191. */
  54192. serialize(serializationObject: any): void;
  54193. /**
  54194. * Adds all the elements from the container to the scene
  54195. * @param container the container holding the elements
  54196. */
  54197. addFromContainer(container: AbstractScene): void;
  54198. /**
  54199. * Removes all the elements in the container from the scene
  54200. * @param container contains the elements to remove
  54201. * @param dispose if the removed element should be disposed (default: false)
  54202. */
  54203. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54204. /**
  54205. * Disposes the component and the associated ressources.
  54206. */
  54207. dispose(): void;
  54208. private _isReadyForMesh;
  54209. private _renderMainTexture;
  54210. private _setStencil;
  54211. private _setStencilBack;
  54212. private _draw;
  54213. private _drawCamera;
  54214. private _drawRenderingGroup;
  54215. }
  54216. }
  54217. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  54218. /** @hidden */
  54219. export var glowMapMergePixelShader: {
  54220. name: string;
  54221. shader: string;
  54222. };
  54223. }
  54224. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  54225. /** @hidden */
  54226. export var glowMapMergeVertexShader: {
  54227. name: string;
  54228. shader: string;
  54229. };
  54230. }
  54231. declare module "babylonjs/Layers/glowLayer" {
  54232. import { Nullable } from "babylonjs/types";
  54233. import { Camera } from "babylonjs/Cameras/camera";
  54234. import { Scene } from "babylonjs/scene";
  54235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54237. import { Mesh } from "babylonjs/Meshes/mesh";
  54238. import { Texture } from "babylonjs/Materials/Textures/texture";
  54239. import { Effect } from "babylonjs/Materials/effect";
  54240. import { Material } from "babylonjs/Materials/material";
  54241. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54242. import { Color4 } from "babylonjs/Maths/math.color";
  54243. import "babylonjs/Shaders/glowMapMerge.fragment";
  54244. import "babylonjs/Shaders/glowMapMerge.vertex";
  54245. import "babylonjs/Layers/effectLayerSceneComponent";
  54246. module "babylonjs/abstractScene" {
  54247. interface AbstractScene {
  54248. /**
  54249. * Return a the first highlight layer of the scene with a given name.
  54250. * @param name The name of the highlight layer to look for.
  54251. * @return The highlight layer if found otherwise null.
  54252. */
  54253. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  54254. }
  54255. }
  54256. /**
  54257. * Glow layer options. This helps customizing the behaviour
  54258. * of the glow layer.
  54259. */
  54260. export interface IGlowLayerOptions {
  54261. /**
  54262. * Multiplication factor apply to the canvas size to compute the render target size
  54263. * used to generated the glowing objects (the smaller the faster).
  54264. */
  54265. mainTextureRatio: number;
  54266. /**
  54267. * Enforces a fixed size texture to ensure resize independant blur.
  54268. */
  54269. mainTextureFixedSize?: number;
  54270. /**
  54271. * How big is the kernel of the blur texture.
  54272. */
  54273. blurKernelSize: number;
  54274. /**
  54275. * The camera attached to the layer.
  54276. */
  54277. camera: Nullable<Camera>;
  54278. /**
  54279. * Enable MSAA by chosing the number of samples.
  54280. */
  54281. mainTextureSamples?: number;
  54282. /**
  54283. * The rendering group to draw the layer in.
  54284. */
  54285. renderingGroupId: number;
  54286. }
  54287. /**
  54288. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  54289. *
  54290. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  54291. *
  54292. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  54293. */
  54294. export class GlowLayer extends EffectLayer {
  54295. /**
  54296. * Effect Name of the layer.
  54297. */
  54298. static readonly EffectName: string;
  54299. /**
  54300. * The default blur kernel size used for the glow.
  54301. */
  54302. static DefaultBlurKernelSize: number;
  54303. /**
  54304. * The default texture size ratio used for the glow.
  54305. */
  54306. static DefaultTextureRatio: number;
  54307. /**
  54308. * Sets the kernel size of the blur.
  54309. */
  54310. set blurKernelSize(value: number);
  54311. /**
  54312. * Gets the kernel size of the blur.
  54313. */
  54314. get blurKernelSize(): number;
  54315. /**
  54316. * Sets the glow intensity.
  54317. */
  54318. set intensity(value: number);
  54319. /**
  54320. * Gets the glow intensity.
  54321. */
  54322. get intensity(): number;
  54323. private _options;
  54324. private _intensity;
  54325. private _horizontalBlurPostprocess1;
  54326. private _verticalBlurPostprocess1;
  54327. private _horizontalBlurPostprocess2;
  54328. private _verticalBlurPostprocess2;
  54329. private _blurTexture1;
  54330. private _blurTexture2;
  54331. private _postProcesses1;
  54332. private _postProcesses2;
  54333. private _includedOnlyMeshes;
  54334. private _excludedMeshes;
  54335. private _meshesUsingTheirOwnMaterials;
  54336. /**
  54337. * Callback used to let the user override the color selection on a per mesh basis
  54338. */
  54339. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54340. /**
  54341. * Callback used to let the user override the texture selection on a per mesh basis
  54342. */
  54343. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54344. /**
  54345. * Instantiates a new glow Layer and references it to the scene.
  54346. * @param name The name of the layer
  54347. * @param scene The scene to use the layer in
  54348. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54349. */
  54350. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54351. /**
  54352. * Get the effect name of the layer.
  54353. * @return The effect name
  54354. */
  54355. getEffectName(): string;
  54356. /**
  54357. * Create the merge effect. This is the shader use to blit the information back
  54358. * to the main canvas at the end of the scene rendering.
  54359. */
  54360. protected _createMergeEffect(): Effect;
  54361. /**
  54362. * Creates the render target textures and post processes used in the glow layer.
  54363. */
  54364. protected _createTextureAndPostProcesses(): void;
  54365. /**
  54366. * Checks for the readiness of the element composing the layer.
  54367. * @param subMesh the mesh to check for
  54368. * @param useInstances specify wether or not to use instances to render the mesh
  54369. * @param emissiveTexture the associated emissive texture used to generate the glow
  54370. * @return true if ready otherwise, false
  54371. */
  54372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54373. /**
  54374. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54375. */
  54376. needStencil(): boolean;
  54377. /**
  54378. * Returns true if the mesh can be rendered, otherwise false.
  54379. * @param mesh The mesh to render
  54380. * @param material The material used on the mesh
  54381. * @returns true if it can be rendered otherwise false
  54382. */
  54383. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54384. /**
  54385. * Implementation specific of rendering the generating effect on the main canvas.
  54386. * @param effect The effect used to render through
  54387. */
  54388. protected _internalRender(effect: Effect): void;
  54389. /**
  54390. * Sets the required values for both the emissive texture and and the main color.
  54391. */
  54392. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54393. /**
  54394. * Returns true if the mesh should render, otherwise false.
  54395. * @param mesh The mesh to render
  54396. * @returns true if it should render otherwise false
  54397. */
  54398. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54399. /**
  54400. * Adds specific effects defines.
  54401. * @param defines The defines to add specifics to.
  54402. */
  54403. protected _addCustomEffectDefines(defines: string[]): void;
  54404. /**
  54405. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54406. * @param mesh The mesh to exclude from the glow layer
  54407. */
  54408. addExcludedMesh(mesh: Mesh): void;
  54409. /**
  54410. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54411. * @param mesh The mesh to remove
  54412. */
  54413. removeExcludedMesh(mesh: Mesh): void;
  54414. /**
  54415. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54416. * @param mesh The mesh to include in the glow layer
  54417. */
  54418. addIncludedOnlyMesh(mesh: Mesh): void;
  54419. /**
  54420. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54421. * @param mesh The mesh to remove
  54422. */
  54423. removeIncludedOnlyMesh(mesh: Mesh): void;
  54424. /**
  54425. * Determine if a given mesh will be used in the glow layer
  54426. * @param mesh The mesh to test
  54427. * @returns true if the mesh will be highlighted by the current glow layer
  54428. */
  54429. hasMesh(mesh: AbstractMesh): boolean;
  54430. /**
  54431. * Defines wether the current material of the mesh should be use to render the effect.
  54432. * @param mesh defines the current mesh to render
  54433. */
  54434. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54435. /**
  54436. * Add a mesh to be rendered through its own material and not with emissive only.
  54437. * @param mesh The mesh for which we need to use its material
  54438. */
  54439. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54440. /**
  54441. * Remove a mesh from being rendered through its own material and not with emissive only.
  54442. * @param mesh The mesh for which we need to not use its material
  54443. */
  54444. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54445. /**
  54446. * Free any resources and references associated to a mesh.
  54447. * Internal use
  54448. * @param mesh The mesh to free.
  54449. * @hidden
  54450. */
  54451. _disposeMesh(mesh: Mesh): void;
  54452. /**
  54453. * Gets the class name of the effect layer
  54454. * @returns the string with the class name of the effect layer
  54455. */
  54456. getClassName(): string;
  54457. /**
  54458. * Serializes this glow layer
  54459. * @returns a serialized glow layer object
  54460. */
  54461. serialize(): any;
  54462. /**
  54463. * Creates a Glow Layer from parsed glow layer data
  54464. * @param parsedGlowLayer defines glow layer data
  54465. * @param scene defines the current scene
  54466. * @param rootUrl defines the root URL containing the glow layer information
  54467. * @returns a parsed Glow Layer
  54468. */
  54469. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54470. }
  54471. }
  54472. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  54473. /** @hidden */
  54474. export var glowBlurPostProcessPixelShader: {
  54475. name: string;
  54476. shader: string;
  54477. };
  54478. }
  54479. declare module "babylonjs/Layers/highlightLayer" {
  54480. import { Observable } from "babylonjs/Misc/observable";
  54481. import { Nullable } from "babylonjs/types";
  54482. import { Camera } from "babylonjs/Cameras/camera";
  54483. import { Scene } from "babylonjs/scene";
  54484. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54486. import { Mesh } from "babylonjs/Meshes/mesh";
  54487. import { Effect } from "babylonjs/Materials/effect";
  54488. import { Material } from "babylonjs/Materials/material";
  54489. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54490. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  54491. import "babylonjs/Shaders/glowMapMerge.fragment";
  54492. import "babylonjs/Shaders/glowMapMerge.vertex";
  54493. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  54494. module "babylonjs/abstractScene" {
  54495. interface AbstractScene {
  54496. /**
  54497. * Return a the first highlight layer of the scene with a given name.
  54498. * @param name The name of the highlight layer to look for.
  54499. * @return The highlight layer if found otherwise null.
  54500. */
  54501. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54502. }
  54503. }
  54504. /**
  54505. * Highlight layer options. This helps customizing the behaviour
  54506. * of the highlight layer.
  54507. */
  54508. export interface IHighlightLayerOptions {
  54509. /**
  54510. * Multiplication factor apply to the canvas size to compute the render target size
  54511. * used to generated the glowing objects (the smaller the faster).
  54512. */
  54513. mainTextureRatio: number;
  54514. /**
  54515. * Enforces a fixed size texture to ensure resize independant blur.
  54516. */
  54517. mainTextureFixedSize?: number;
  54518. /**
  54519. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54520. * of the picture to blur (the smaller the faster).
  54521. */
  54522. blurTextureSizeRatio: number;
  54523. /**
  54524. * How big in texel of the blur texture is the vertical blur.
  54525. */
  54526. blurVerticalSize: number;
  54527. /**
  54528. * How big in texel of the blur texture is the horizontal blur.
  54529. */
  54530. blurHorizontalSize: number;
  54531. /**
  54532. * Alpha blending mode used to apply the blur. Default is combine.
  54533. */
  54534. alphaBlendingMode: number;
  54535. /**
  54536. * The camera attached to the layer.
  54537. */
  54538. camera: Nullable<Camera>;
  54539. /**
  54540. * Should we display highlight as a solid stroke?
  54541. */
  54542. isStroke?: boolean;
  54543. /**
  54544. * The rendering group to draw the layer in.
  54545. */
  54546. renderingGroupId: number;
  54547. }
  54548. /**
  54549. * The highlight layer Helps adding a glow effect around a mesh.
  54550. *
  54551. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54552. * glowy meshes to your scene.
  54553. *
  54554. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54555. */
  54556. export class HighlightLayer extends EffectLayer {
  54557. name: string;
  54558. /**
  54559. * Effect Name of the highlight layer.
  54560. */
  54561. static readonly EffectName: string;
  54562. /**
  54563. * The neutral color used during the preparation of the glow effect.
  54564. * This is black by default as the blend operation is a blend operation.
  54565. */
  54566. static NeutralColor: Color4;
  54567. /**
  54568. * Stencil value used for glowing meshes.
  54569. */
  54570. static GlowingMeshStencilReference: number;
  54571. /**
  54572. * Stencil value used for the other meshes in the scene.
  54573. */
  54574. static NormalMeshStencilReference: number;
  54575. /**
  54576. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54577. */
  54578. innerGlow: boolean;
  54579. /**
  54580. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54581. */
  54582. outerGlow: boolean;
  54583. /**
  54584. * Specifies the horizontal size of the blur.
  54585. */
  54586. set blurHorizontalSize(value: number);
  54587. /**
  54588. * Specifies the vertical size of the blur.
  54589. */
  54590. set blurVerticalSize(value: number);
  54591. /**
  54592. * Gets the horizontal size of the blur.
  54593. */
  54594. get blurHorizontalSize(): number;
  54595. /**
  54596. * Gets the vertical size of the blur.
  54597. */
  54598. get blurVerticalSize(): number;
  54599. /**
  54600. * An event triggered when the highlight layer is being blurred.
  54601. */
  54602. onBeforeBlurObservable: Observable<HighlightLayer>;
  54603. /**
  54604. * An event triggered when the highlight layer has been blurred.
  54605. */
  54606. onAfterBlurObservable: Observable<HighlightLayer>;
  54607. private _instanceGlowingMeshStencilReference;
  54608. private _options;
  54609. private _downSamplePostprocess;
  54610. private _horizontalBlurPostprocess;
  54611. private _verticalBlurPostprocess;
  54612. private _blurTexture;
  54613. private _meshes;
  54614. private _excludedMeshes;
  54615. /**
  54616. * Instantiates a new highlight Layer and references it to the scene..
  54617. * @param name The name of the layer
  54618. * @param scene The scene to use the layer in
  54619. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54620. */
  54621. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54622. /**
  54623. * Get the effect name of the layer.
  54624. * @return The effect name
  54625. */
  54626. getEffectName(): string;
  54627. /**
  54628. * Create the merge effect. This is the shader use to blit the information back
  54629. * to the main canvas at the end of the scene rendering.
  54630. */
  54631. protected _createMergeEffect(): Effect;
  54632. /**
  54633. * Creates the render target textures and post processes used in the highlight layer.
  54634. */
  54635. protected _createTextureAndPostProcesses(): void;
  54636. /**
  54637. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54638. */
  54639. needStencil(): boolean;
  54640. /**
  54641. * Checks for the readiness of the element composing the layer.
  54642. * @param subMesh the mesh to check for
  54643. * @param useInstances specify wether or not to use instances to render the mesh
  54644. * @param emissiveTexture the associated emissive texture used to generate the glow
  54645. * @return true if ready otherwise, false
  54646. */
  54647. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54648. /**
  54649. * Implementation specific of rendering the generating effect on the main canvas.
  54650. * @param effect The effect used to render through
  54651. */
  54652. protected _internalRender(effect: Effect): void;
  54653. /**
  54654. * Returns true if the layer contains information to display, otherwise false.
  54655. */
  54656. shouldRender(): boolean;
  54657. /**
  54658. * Returns true if the mesh should render, otherwise false.
  54659. * @param mesh The mesh to render
  54660. * @returns true if it should render otherwise false
  54661. */
  54662. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54663. /**
  54664. * Sets the required values for both the emissive texture and and the main color.
  54665. */
  54666. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54667. /**
  54668. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54669. * @param mesh The mesh to exclude from the highlight layer
  54670. */
  54671. addExcludedMesh(mesh: Mesh): void;
  54672. /**
  54673. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54674. * @param mesh The mesh to highlight
  54675. */
  54676. removeExcludedMesh(mesh: Mesh): void;
  54677. /**
  54678. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54679. * @param mesh mesh to test
  54680. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54681. */
  54682. hasMesh(mesh: AbstractMesh): boolean;
  54683. /**
  54684. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54685. * @param mesh The mesh to highlight
  54686. * @param color The color of the highlight
  54687. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54688. */
  54689. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54690. /**
  54691. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54692. * @param mesh The mesh to highlight
  54693. */
  54694. removeMesh(mesh: Mesh): void;
  54695. /**
  54696. * Force the stencil to the normal expected value for none glowing parts
  54697. */
  54698. private _defaultStencilReference;
  54699. /**
  54700. * Free any resources and references associated to a mesh.
  54701. * Internal use
  54702. * @param mesh The mesh to free.
  54703. * @hidden
  54704. */
  54705. _disposeMesh(mesh: Mesh): void;
  54706. /**
  54707. * Dispose the highlight layer and free resources.
  54708. */
  54709. dispose(): void;
  54710. /**
  54711. * Gets the class name of the effect layer
  54712. * @returns the string with the class name of the effect layer
  54713. */
  54714. getClassName(): string;
  54715. /**
  54716. * Serializes this Highlight layer
  54717. * @returns a serialized Highlight layer object
  54718. */
  54719. serialize(): any;
  54720. /**
  54721. * Creates a Highlight layer from parsed Highlight layer data
  54722. * @param parsedHightlightLayer defines the Highlight layer data
  54723. * @param scene defines the current scene
  54724. * @param rootUrl defines the root URL containing the Highlight layer information
  54725. * @returns a parsed Highlight layer
  54726. */
  54727. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54728. }
  54729. }
  54730. declare module "babylonjs/Layers/layerSceneComponent" {
  54731. import { Scene } from "babylonjs/scene";
  54732. import { ISceneComponent } from "babylonjs/sceneComponent";
  54733. import { Layer } from "babylonjs/Layers/layer";
  54734. import { AbstractScene } from "babylonjs/abstractScene";
  54735. module "babylonjs/abstractScene" {
  54736. interface AbstractScene {
  54737. /**
  54738. * The list of layers (background and foreground) of the scene
  54739. */
  54740. layers: Array<Layer>;
  54741. }
  54742. }
  54743. /**
  54744. * Defines the layer scene component responsible to manage any layers
  54745. * in a given scene.
  54746. */
  54747. export class LayerSceneComponent implements ISceneComponent {
  54748. /**
  54749. * The component name helpfull to identify the component in the list of scene components.
  54750. */
  54751. readonly name: string;
  54752. /**
  54753. * The scene the component belongs to.
  54754. */
  54755. scene: Scene;
  54756. private _engine;
  54757. /**
  54758. * Creates a new instance of the component for the given scene
  54759. * @param scene Defines the scene to register the component in
  54760. */
  54761. constructor(scene: Scene);
  54762. /**
  54763. * Registers the component in a given scene
  54764. */
  54765. register(): void;
  54766. /**
  54767. * Rebuilds the elements related to this component in case of
  54768. * context lost for instance.
  54769. */
  54770. rebuild(): void;
  54771. /**
  54772. * Disposes the component and the associated ressources.
  54773. */
  54774. dispose(): void;
  54775. private _draw;
  54776. private _drawCameraPredicate;
  54777. private _drawCameraBackground;
  54778. private _drawCameraForeground;
  54779. private _drawRenderTargetPredicate;
  54780. private _drawRenderTargetBackground;
  54781. private _drawRenderTargetForeground;
  54782. /**
  54783. * Adds all the elements from the container to the scene
  54784. * @param container the container holding the elements
  54785. */
  54786. addFromContainer(container: AbstractScene): void;
  54787. /**
  54788. * Removes all the elements in the container from the scene
  54789. * @param container contains the elements to remove
  54790. * @param dispose if the removed element should be disposed (default: false)
  54791. */
  54792. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54793. }
  54794. }
  54795. declare module "babylonjs/Shaders/layer.fragment" {
  54796. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54797. /** @hidden */
  54798. export var layerPixelShader: {
  54799. name: string;
  54800. shader: string;
  54801. };
  54802. }
  54803. declare module "babylonjs/Shaders/layer.vertex" {
  54804. /** @hidden */
  54805. export var layerVertexShader: {
  54806. name: string;
  54807. shader: string;
  54808. };
  54809. }
  54810. declare module "babylonjs/Layers/layer" {
  54811. import { Observable } from "babylonjs/Misc/observable";
  54812. import { Nullable } from "babylonjs/types";
  54813. import { Scene } from "babylonjs/scene";
  54814. import { Vector2 } from "babylonjs/Maths/math.vector";
  54815. import { Color4 } from "babylonjs/Maths/math.color";
  54816. import { Texture } from "babylonjs/Materials/Textures/texture";
  54817. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54818. import "babylonjs/Shaders/layer.fragment";
  54819. import "babylonjs/Shaders/layer.vertex";
  54820. /**
  54821. * This represents a full screen 2d layer.
  54822. * This can be useful to display a picture in the background of your scene for instance.
  54823. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54824. */
  54825. export class Layer {
  54826. /**
  54827. * Define the name of the layer.
  54828. */
  54829. name: string;
  54830. /**
  54831. * Define the texture the layer should display.
  54832. */
  54833. texture: Nullable<Texture>;
  54834. /**
  54835. * Is the layer in background or foreground.
  54836. */
  54837. isBackground: boolean;
  54838. /**
  54839. * Define the color of the layer (instead of texture).
  54840. */
  54841. color: Color4;
  54842. /**
  54843. * Define the scale of the layer in order to zoom in out of the texture.
  54844. */
  54845. scale: Vector2;
  54846. /**
  54847. * Define an offset for the layer in order to shift the texture.
  54848. */
  54849. offset: Vector2;
  54850. /**
  54851. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54852. */
  54853. alphaBlendingMode: number;
  54854. /**
  54855. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54856. * Alpha test will not mix with the background color in case of transparency.
  54857. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54858. */
  54859. alphaTest: boolean;
  54860. /**
  54861. * Define a mask to restrict the layer to only some of the scene cameras.
  54862. */
  54863. layerMask: number;
  54864. /**
  54865. * Define the list of render target the layer is visible into.
  54866. */
  54867. renderTargetTextures: RenderTargetTexture[];
  54868. /**
  54869. * Define if the layer is only used in renderTarget or if it also
  54870. * renders in the main frame buffer of the canvas.
  54871. */
  54872. renderOnlyInRenderTargetTextures: boolean;
  54873. private _scene;
  54874. private _vertexBuffers;
  54875. private _indexBuffer;
  54876. private _effect;
  54877. private _previousDefines;
  54878. /**
  54879. * An event triggered when the layer is disposed.
  54880. */
  54881. onDisposeObservable: Observable<Layer>;
  54882. private _onDisposeObserver;
  54883. /**
  54884. * Back compatibility with callback before the onDisposeObservable existed.
  54885. * The set callback will be triggered when the layer has been disposed.
  54886. */
  54887. set onDispose(callback: () => void);
  54888. /**
  54889. * An event triggered before rendering the scene
  54890. */
  54891. onBeforeRenderObservable: Observable<Layer>;
  54892. private _onBeforeRenderObserver;
  54893. /**
  54894. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54895. * The set callback will be triggered just before rendering the layer.
  54896. */
  54897. set onBeforeRender(callback: () => void);
  54898. /**
  54899. * An event triggered after rendering the scene
  54900. */
  54901. onAfterRenderObservable: Observable<Layer>;
  54902. private _onAfterRenderObserver;
  54903. /**
  54904. * Back compatibility with callback before the onAfterRenderObservable existed.
  54905. * The set callback will be triggered just after rendering the layer.
  54906. */
  54907. set onAfterRender(callback: () => void);
  54908. /**
  54909. * Instantiates a new layer.
  54910. * This represents a full screen 2d layer.
  54911. * This can be useful to display a picture in the background of your scene for instance.
  54912. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54913. * @param name Define the name of the layer in the scene
  54914. * @param imgUrl Define the url of the texture to display in the layer
  54915. * @param scene Define the scene the layer belongs to
  54916. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54917. * @param color Defines a color for the layer
  54918. */
  54919. constructor(
  54920. /**
  54921. * Define the name of the layer.
  54922. */
  54923. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54924. private _createIndexBuffer;
  54925. /** @hidden */
  54926. _rebuild(): void;
  54927. /**
  54928. * Renders the layer in the scene.
  54929. */
  54930. render(): void;
  54931. /**
  54932. * Disposes and releases the associated ressources.
  54933. */
  54934. dispose(): void;
  54935. }
  54936. }
  54937. declare module "babylonjs/Layers/index" {
  54938. export * from "babylonjs/Layers/effectLayer";
  54939. export * from "babylonjs/Layers/effectLayerSceneComponent";
  54940. export * from "babylonjs/Layers/glowLayer";
  54941. export * from "babylonjs/Layers/highlightLayer";
  54942. export * from "babylonjs/Layers/layer";
  54943. export * from "babylonjs/Layers/layerSceneComponent";
  54944. }
  54945. declare module "babylonjs/Shaders/lensFlare.fragment" {
  54946. /** @hidden */
  54947. export var lensFlarePixelShader: {
  54948. name: string;
  54949. shader: string;
  54950. };
  54951. }
  54952. declare module "babylonjs/Shaders/lensFlare.vertex" {
  54953. /** @hidden */
  54954. export var lensFlareVertexShader: {
  54955. name: string;
  54956. shader: string;
  54957. };
  54958. }
  54959. declare module "babylonjs/LensFlares/lensFlareSystem" {
  54960. import { Scene } from "babylonjs/scene";
  54961. import { Vector3 } from "babylonjs/Maths/math.vector";
  54962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54963. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  54964. import "babylonjs/Shaders/lensFlare.fragment";
  54965. import "babylonjs/Shaders/lensFlare.vertex";
  54966. import { Viewport } from "babylonjs/Maths/math.viewport";
  54967. /**
  54968. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54969. * It is usually composed of several `lensFlare`.
  54970. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54971. */
  54972. export class LensFlareSystem {
  54973. /**
  54974. * Define the name of the lens flare system
  54975. */
  54976. name: string;
  54977. /**
  54978. * List of lens flares used in this system.
  54979. */
  54980. lensFlares: LensFlare[];
  54981. /**
  54982. * Define a limit from the border the lens flare can be visible.
  54983. */
  54984. borderLimit: number;
  54985. /**
  54986. * Define a viewport border we do not want to see the lens flare in.
  54987. */
  54988. viewportBorder: number;
  54989. /**
  54990. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54991. */
  54992. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54993. /**
  54994. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54995. */
  54996. layerMask: number;
  54997. /**
  54998. * Define the id of the lens flare system in the scene.
  54999. * (equal to name by default)
  55000. */
  55001. id: string;
  55002. private _scene;
  55003. private _emitter;
  55004. private _vertexBuffers;
  55005. private _indexBuffer;
  55006. private _effect;
  55007. private _positionX;
  55008. private _positionY;
  55009. private _isEnabled;
  55010. /** @hidden */
  55011. static _SceneComponentInitialization: (scene: Scene) => void;
  55012. /**
  55013. * Instantiates a lens flare system.
  55014. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55015. * It is usually composed of several `lensFlare`.
  55016. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55017. * @param name Define the name of the lens flare system in the scene
  55018. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55019. * @param scene Define the scene the lens flare system belongs to
  55020. */
  55021. constructor(
  55022. /**
  55023. * Define the name of the lens flare system
  55024. */
  55025. name: string, emitter: any, scene: Scene);
  55026. /**
  55027. * Define if the lens flare system is enabled.
  55028. */
  55029. get isEnabled(): boolean;
  55030. set isEnabled(value: boolean);
  55031. /**
  55032. * Get the scene the effects belongs to.
  55033. * @returns the scene holding the lens flare system
  55034. */
  55035. getScene(): Scene;
  55036. /**
  55037. * Get 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. * @returns the emitter of the lens flare system
  55040. */
  55041. getEmitter(): any;
  55042. /**
  55043. * Set the emitter of the lens flare system.
  55044. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55045. * @param newEmitter Define the new emitter of the system
  55046. */
  55047. setEmitter(newEmitter: any): void;
  55048. /**
  55049. * Get the lens flare system emitter position.
  55050. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55051. * @returns the position
  55052. */
  55053. getEmitterPosition(): Vector3;
  55054. /**
  55055. * @hidden
  55056. */
  55057. computeEffectivePosition(globalViewport: Viewport): boolean;
  55058. /** @hidden */
  55059. _isVisible(): boolean;
  55060. /**
  55061. * @hidden
  55062. */
  55063. render(): boolean;
  55064. /**
  55065. * Dispose and release the lens flare with its associated resources.
  55066. */
  55067. dispose(): void;
  55068. /**
  55069. * Parse a lens flare system from a JSON repressentation
  55070. * @param parsedLensFlareSystem Define the JSON to parse
  55071. * @param scene Define the scene the parsed system should be instantiated in
  55072. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55073. * @returns the parsed system
  55074. */
  55075. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55076. /**
  55077. * Serialize the current Lens Flare System into a JSON representation.
  55078. * @returns the serialized JSON
  55079. */
  55080. serialize(): any;
  55081. }
  55082. }
  55083. declare module "babylonjs/LensFlares/lensFlare" {
  55084. import { Nullable } from "babylonjs/types";
  55085. import { Color3 } from "babylonjs/Maths/math.color";
  55086. import { Texture } from "babylonjs/Materials/Textures/texture";
  55087. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55088. /**
  55089. * This represents one of the lens effect in a `lensFlareSystem`.
  55090. * It controls one of the indiviual texture used in the effect.
  55091. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55092. */
  55093. export class LensFlare {
  55094. /**
  55095. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55096. */
  55097. size: number;
  55098. /**
  55099. * 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.
  55100. */
  55101. position: number;
  55102. /**
  55103. * Define the lens color.
  55104. */
  55105. color: Color3;
  55106. /**
  55107. * Define the lens texture.
  55108. */
  55109. texture: Nullable<Texture>;
  55110. /**
  55111. * Define the alpha mode to render this particular lens.
  55112. */
  55113. alphaMode: number;
  55114. private _system;
  55115. /**
  55116. * Creates a new Lens Flare.
  55117. * This represents one of the lens effect in a `lensFlareSystem`.
  55118. * It controls one of the indiviual texture used in the effect.
  55119. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55120. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55121. * @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.
  55122. * @param color Define the lens color
  55123. * @param imgUrl Define the lens texture url
  55124. * @param system Define the `lensFlareSystem` this flare is part of
  55125. * @returns The newly created Lens Flare
  55126. */
  55127. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55128. /**
  55129. * Instantiates a new Lens Flare.
  55130. * This represents one of the lens effect in a `lensFlareSystem`.
  55131. * It controls one of the indiviual texture used in the effect.
  55132. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55133. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55134. * @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.
  55135. * @param color Define the lens color
  55136. * @param imgUrl Define the lens texture url
  55137. * @param system Define the `lensFlareSystem` this flare is part of
  55138. */
  55139. constructor(
  55140. /**
  55141. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55142. */
  55143. size: number,
  55144. /**
  55145. * 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.
  55146. */
  55147. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55148. /**
  55149. * Dispose and release the lens flare with its associated resources.
  55150. */
  55151. dispose(): void;
  55152. }
  55153. }
  55154. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55155. import { Nullable } from "babylonjs/types";
  55156. import { Scene } from "babylonjs/scene";
  55157. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55158. import { AbstractScene } from "babylonjs/abstractScene";
  55159. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55160. module "babylonjs/abstractScene" {
  55161. interface AbstractScene {
  55162. /**
  55163. * The list of lens flare system added to the scene
  55164. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55165. */
  55166. lensFlareSystems: Array<LensFlareSystem>;
  55167. /**
  55168. * Removes the given lens flare system from this scene.
  55169. * @param toRemove The lens flare system to remove
  55170. * @returns The index of the removed lens flare system
  55171. */
  55172. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55173. /**
  55174. * Adds the given lens flare system to this scene
  55175. * @param newLensFlareSystem The lens flare system to add
  55176. */
  55177. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55178. /**
  55179. * Gets a lens flare system using its name
  55180. * @param name defines the name to look for
  55181. * @returns the lens flare system or null if not found
  55182. */
  55183. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55184. /**
  55185. * Gets a lens flare system using its id
  55186. * @param id defines the id to look for
  55187. * @returns the lens flare system or null if not found
  55188. */
  55189. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55190. }
  55191. }
  55192. /**
  55193. * Defines the lens flare scene component responsible to manage any lens flares
  55194. * in a given scene.
  55195. */
  55196. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  55197. /**
  55198. * The component name helpfull to identify the component in the list of scene components.
  55199. */
  55200. readonly name: string;
  55201. /**
  55202. * The scene the component belongs to.
  55203. */
  55204. scene: Scene;
  55205. /**
  55206. * Creates a new instance of the component for the given scene
  55207. * @param scene Defines the scene to register the component in
  55208. */
  55209. constructor(scene: Scene);
  55210. /**
  55211. * Registers the component in a given scene
  55212. */
  55213. register(): void;
  55214. /**
  55215. * Rebuilds the elements related to this component in case of
  55216. * context lost for instance.
  55217. */
  55218. rebuild(): void;
  55219. /**
  55220. * Adds all the elements from the container to the scene
  55221. * @param container the container holding the elements
  55222. */
  55223. addFromContainer(container: AbstractScene): void;
  55224. /**
  55225. * Removes all the elements in the container from the scene
  55226. * @param container contains the elements to remove
  55227. * @param dispose if the removed element should be disposed (default: false)
  55228. */
  55229. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55230. /**
  55231. * Serializes the component data to the specified json object
  55232. * @param serializationObject The object to serialize to
  55233. */
  55234. serialize(serializationObject: any): void;
  55235. /**
  55236. * Disposes the component and the associated ressources.
  55237. */
  55238. dispose(): void;
  55239. private _draw;
  55240. }
  55241. }
  55242. declare module "babylonjs/LensFlares/index" {
  55243. export * from "babylonjs/LensFlares/lensFlare";
  55244. export * from "babylonjs/LensFlares/lensFlareSystem";
  55245. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  55246. }
  55247. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  55248. import { Scene } from "babylonjs/scene";
  55249. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55250. import { AbstractScene } from "babylonjs/abstractScene";
  55251. /**
  55252. * Defines the shadow generator component responsible to manage any shadow generators
  55253. * in a given scene.
  55254. */
  55255. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55256. /**
  55257. * The component name helpfull to identify the component in the list of scene components.
  55258. */
  55259. readonly name: string;
  55260. /**
  55261. * The scene the component belongs to.
  55262. */
  55263. scene: Scene;
  55264. /**
  55265. * Creates a new instance of the component for the given scene
  55266. * @param scene Defines the scene to register the component in
  55267. */
  55268. constructor(scene: Scene);
  55269. /**
  55270. * Registers the component in a given scene
  55271. */
  55272. register(): void;
  55273. /**
  55274. * Rebuilds the elements related to this component in case of
  55275. * context lost for instance.
  55276. */
  55277. rebuild(): void;
  55278. /**
  55279. * Serializes the component data to the specified json object
  55280. * @param serializationObject The object to serialize to
  55281. */
  55282. serialize(serializationObject: any): void;
  55283. /**
  55284. * Adds all the elements from the container to the scene
  55285. * @param container the container holding the elements
  55286. */
  55287. addFromContainer(container: AbstractScene): void;
  55288. /**
  55289. * Removes all the elements in the container from the scene
  55290. * @param container contains the elements to remove
  55291. * @param dispose if the removed element should be disposed (default: false)
  55292. */
  55293. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55294. /**
  55295. * Rebuilds the elements related to this component in case of
  55296. * context lost for instance.
  55297. */
  55298. dispose(): void;
  55299. private _gatherRenderTargets;
  55300. }
  55301. }
  55302. declare module "babylonjs/Lights/Shadows/index" {
  55303. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  55304. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  55305. }
  55306. declare module "babylonjs/Lights/pointLight" {
  55307. import { Scene } from "babylonjs/scene";
  55308. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55310. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55311. import { Effect } from "babylonjs/Materials/effect";
  55312. /**
  55313. * A point light is a light defined by an unique point in world space.
  55314. * The light is emitted in every direction from this point.
  55315. * A good example of a point light is a standard light bulb.
  55316. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55317. */
  55318. export class PointLight extends ShadowLight {
  55319. private _shadowAngle;
  55320. /**
  55321. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55322. * This specifies what angle the shadow will use to be created.
  55323. *
  55324. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55325. */
  55326. get shadowAngle(): number;
  55327. /**
  55328. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55329. * This specifies what angle the shadow will use to be created.
  55330. *
  55331. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55332. */
  55333. set shadowAngle(value: number);
  55334. /**
  55335. * Gets the direction if it has been set.
  55336. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55337. */
  55338. get direction(): Vector3;
  55339. /**
  55340. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55341. */
  55342. set direction(value: Vector3);
  55343. /**
  55344. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55345. * A PointLight emits the light in every direction.
  55346. * It can cast shadows.
  55347. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55348. * ```javascript
  55349. * var pointLight = new PointLight("pl", camera.position, scene);
  55350. * ```
  55351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55352. * @param name The light friendly name
  55353. * @param position The position of the point light in the scene
  55354. * @param scene The scene the lights belongs to
  55355. */
  55356. constructor(name: string, position: Vector3, scene: Scene);
  55357. /**
  55358. * Returns the string "PointLight"
  55359. * @returns the class name
  55360. */
  55361. getClassName(): string;
  55362. /**
  55363. * Returns the integer 0.
  55364. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55365. */
  55366. getTypeID(): number;
  55367. /**
  55368. * Specifies wether or not the shadowmap should be a cube texture.
  55369. * @returns true if the shadowmap needs to be a cube texture.
  55370. */
  55371. needCube(): boolean;
  55372. /**
  55373. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55374. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55375. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55376. */
  55377. getShadowDirection(faceIndex?: number): Vector3;
  55378. /**
  55379. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55380. * - fov = PI / 2
  55381. * - aspect ratio : 1.0
  55382. * - z-near and far equal to the active camera minZ and maxZ.
  55383. * Returns the PointLight.
  55384. */
  55385. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55386. protected _buildUniformLayout(): void;
  55387. /**
  55388. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55389. * @param effect The effect to update
  55390. * @param lightIndex The index of the light in the effect to update
  55391. * @returns The point light
  55392. */
  55393. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55394. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55395. /**
  55396. * Prepares the list of defines specific to the light type.
  55397. * @param defines the list of defines
  55398. * @param lightIndex defines the index of the light for the effect
  55399. */
  55400. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55401. }
  55402. }
  55403. declare module "babylonjs/Lights/index" {
  55404. export * from "babylonjs/Lights/light";
  55405. export * from "babylonjs/Lights/shadowLight";
  55406. export * from "babylonjs/Lights/Shadows/index";
  55407. export * from "babylonjs/Lights/directionalLight";
  55408. export * from "babylonjs/Lights/hemisphericLight";
  55409. export * from "babylonjs/Lights/pointLight";
  55410. export * from "babylonjs/Lights/spotLight";
  55411. }
  55412. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  55413. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55414. /**
  55415. * Header information of HDR texture files.
  55416. */
  55417. export interface HDRInfo {
  55418. /**
  55419. * The height of the texture in pixels.
  55420. */
  55421. height: number;
  55422. /**
  55423. * The width of the texture in pixels.
  55424. */
  55425. width: number;
  55426. /**
  55427. * The index of the beginning of the data in the binary file.
  55428. */
  55429. dataPosition: number;
  55430. }
  55431. /**
  55432. * This groups tools to convert HDR texture to native colors array.
  55433. */
  55434. export class HDRTools {
  55435. private static Ldexp;
  55436. private static Rgbe2float;
  55437. private static readStringLine;
  55438. /**
  55439. * Reads header information from an RGBE texture stored in a native array.
  55440. * More information on this format are available here:
  55441. * https://en.wikipedia.org/wiki/RGBE_image_format
  55442. *
  55443. * @param uint8array The binary file stored in native array.
  55444. * @return The header information.
  55445. */
  55446. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55447. /**
  55448. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55449. * This RGBE texture needs to store the information as a panorama.
  55450. *
  55451. * More information on this format are available here:
  55452. * https://en.wikipedia.org/wiki/RGBE_image_format
  55453. *
  55454. * @param buffer The binary file stored in an array buffer.
  55455. * @param size The expected size of the extracted cubemap.
  55456. * @return The Cube Map information.
  55457. */
  55458. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55459. /**
  55460. * Returns the pixels data extracted from an RGBE texture.
  55461. * This pixels will be stored left to right up to down in the R G B order in one array.
  55462. *
  55463. * More information on this format are available here:
  55464. * https://en.wikipedia.org/wiki/RGBE_image_format
  55465. *
  55466. * @param uint8array The binary file stored in an array buffer.
  55467. * @param hdrInfo The header information of the file.
  55468. * @return The pixels data in RGB right to left up to down order.
  55469. */
  55470. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55471. private static RGBE_ReadPixels_RLE;
  55472. }
  55473. }
  55474. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  55475. import { Nullable } from "babylonjs/types";
  55476. import { Scene } from "babylonjs/scene";
  55477. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55478. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55479. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55480. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  55481. /**
  55482. * This represents a texture coming from an HDR input.
  55483. *
  55484. * The only supported format is currently panorama picture stored in RGBE format.
  55485. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55486. */
  55487. export class HDRCubeTexture extends BaseTexture {
  55488. private static _facesMapping;
  55489. private _generateHarmonics;
  55490. private _noMipmap;
  55491. private _textureMatrix;
  55492. private _size;
  55493. private _onLoad;
  55494. private _onError;
  55495. /**
  55496. * The texture URL.
  55497. */
  55498. url: string;
  55499. /**
  55500. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55501. */
  55502. coordinatesMode: number;
  55503. protected _isBlocking: boolean;
  55504. /**
  55505. * Sets wether or not the texture is blocking during loading.
  55506. */
  55507. set isBlocking(value: boolean);
  55508. /**
  55509. * Gets wether or not the texture is blocking during loading.
  55510. */
  55511. get isBlocking(): boolean;
  55512. protected _rotationY: number;
  55513. /**
  55514. * Sets texture matrix rotation angle around Y axis in radians.
  55515. */
  55516. set rotationY(value: number);
  55517. /**
  55518. * Gets texture matrix rotation angle around Y axis radians.
  55519. */
  55520. get rotationY(): number;
  55521. /**
  55522. * Gets or sets the center of the bounding box associated with the cube texture
  55523. * It must define where the camera used to render the texture was set
  55524. */
  55525. boundingBoxPosition: Vector3;
  55526. private _boundingBoxSize;
  55527. /**
  55528. * Gets or sets the size of the bounding box associated with the cube texture
  55529. * When defined, the cubemap will switch to local mode
  55530. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55531. * @example https://www.babylonjs-playground.com/#RNASML
  55532. */
  55533. set boundingBoxSize(value: Vector3);
  55534. get boundingBoxSize(): Vector3;
  55535. /**
  55536. * Instantiates an HDRTexture from the following parameters.
  55537. *
  55538. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55539. * @param scene The scene the texture will be used in
  55540. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55541. * @param noMipmap Forces to not generate the mipmap if true
  55542. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55543. * @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)
  55544. * @param reserved Reserved flag for internal use.
  55545. */
  55546. 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>);
  55547. /**
  55548. * Get the current class name of the texture useful for serialization or dynamic coding.
  55549. * @returns "HDRCubeTexture"
  55550. */
  55551. getClassName(): string;
  55552. /**
  55553. * Occurs when the file is raw .hdr file.
  55554. */
  55555. private loadTexture;
  55556. clone(): HDRCubeTexture;
  55557. delayLoad(): void;
  55558. /**
  55559. * Get the texture reflection matrix used to rotate/transform the reflection.
  55560. * @returns the reflection matrix
  55561. */
  55562. getReflectionTextureMatrix(): Matrix;
  55563. /**
  55564. * Set the texture reflection matrix used to rotate/transform the reflection.
  55565. * @param value Define the reflection matrix to set
  55566. */
  55567. setReflectionTextureMatrix(value: Matrix): void;
  55568. /**
  55569. * Parses a JSON representation of an HDR Texture in order to create the texture
  55570. * @param parsedTexture Define the JSON representation
  55571. * @param scene Define the scene the texture should be created in
  55572. * @param rootUrl Define the root url in case we need to load relative dependencies
  55573. * @returns the newly created texture after parsing
  55574. */
  55575. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55576. serialize(): any;
  55577. }
  55578. }
  55579. declare module "babylonjs/Physics/physicsEngine" {
  55580. import { Nullable } from "babylonjs/types";
  55581. import { Vector3 } from "babylonjs/Maths/math.vector";
  55582. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  55583. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  55584. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  55585. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55586. /**
  55587. * Class used to control physics engine
  55588. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55589. */
  55590. export class PhysicsEngine implements IPhysicsEngine {
  55591. private _physicsPlugin;
  55592. /**
  55593. * Global value used to control the smallest number supported by the simulation
  55594. */
  55595. static Epsilon: number;
  55596. private _impostors;
  55597. private _joints;
  55598. private _subTimeStep;
  55599. /**
  55600. * Gets the gravity vector used by the simulation
  55601. */
  55602. gravity: Vector3;
  55603. /**
  55604. * Factory used to create the default physics plugin.
  55605. * @returns The default physics plugin
  55606. */
  55607. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55608. /**
  55609. * Creates a new Physics Engine
  55610. * @param gravity defines the gravity vector used by the simulation
  55611. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55612. */
  55613. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55614. /**
  55615. * Sets the gravity vector used by the simulation
  55616. * @param gravity defines the gravity vector to use
  55617. */
  55618. setGravity(gravity: Vector3): void;
  55619. /**
  55620. * Set the time step of the physics engine.
  55621. * Default is 1/60.
  55622. * To slow it down, enter 1/600 for example.
  55623. * To speed it up, 1/30
  55624. * @param newTimeStep defines the new timestep to apply to this world.
  55625. */
  55626. setTimeStep(newTimeStep?: number): void;
  55627. /**
  55628. * Get the time step of the physics engine.
  55629. * @returns the current time step
  55630. */
  55631. getTimeStep(): number;
  55632. /**
  55633. * Set the sub time step of the physics engine.
  55634. * Default is 0 meaning there is no sub steps
  55635. * To increase physics resolution precision, set a small value (like 1 ms)
  55636. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55637. */
  55638. setSubTimeStep(subTimeStep?: number): void;
  55639. /**
  55640. * Get the sub time step of the physics engine.
  55641. * @returns the current sub time step
  55642. */
  55643. getSubTimeStep(): number;
  55644. /**
  55645. * Release all resources
  55646. */
  55647. dispose(): void;
  55648. /**
  55649. * Gets the name of the current physics plugin
  55650. * @returns the name of the plugin
  55651. */
  55652. getPhysicsPluginName(): string;
  55653. /**
  55654. * Adding a new impostor for the impostor tracking.
  55655. * This will be done by the impostor itself.
  55656. * @param impostor the impostor to add
  55657. */
  55658. addImpostor(impostor: PhysicsImpostor): void;
  55659. /**
  55660. * Remove an impostor from the engine.
  55661. * This impostor and its mesh will not longer be updated by the physics engine.
  55662. * @param impostor the impostor to remove
  55663. */
  55664. removeImpostor(impostor: PhysicsImpostor): void;
  55665. /**
  55666. * Add a joint to the physics engine
  55667. * @param mainImpostor defines the main impostor to which the joint is added.
  55668. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55669. * @param joint defines the joint that will connect both impostors.
  55670. */
  55671. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55672. /**
  55673. * Removes a joint from the simulation
  55674. * @param mainImpostor defines the impostor used with the joint
  55675. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55676. * @param joint defines the joint to remove
  55677. */
  55678. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55679. /**
  55680. * Called by the scene. No need to call it.
  55681. * @param delta defines the timespam between frames
  55682. */
  55683. _step(delta: number): void;
  55684. /**
  55685. * Gets the current plugin used to run the simulation
  55686. * @returns current plugin
  55687. */
  55688. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55689. /**
  55690. * Gets the list of physic impostors
  55691. * @returns an array of PhysicsImpostor
  55692. */
  55693. getImpostors(): Array<PhysicsImpostor>;
  55694. /**
  55695. * Gets the impostor for a physics enabled object
  55696. * @param object defines the object impersonated by the impostor
  55697. * @returns the PhysicsImpostor or null if not found
  55698. */
  55699. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55700. /**
  55701. * Gets the impostor for a physics body object
  55702. * @param body defines physics body used by the impostor
  55703. * @returns the PhysicsImpostor or null if not found
  55704. */
  55705. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55706. /**
  55707. * Does a raycast in the physics world
  55708. * @param from when should the ray start?
  55709. * @param to when should the ray end?
  55710. * @returns PhysicsRaycastResult
  55711. */
  55712. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55713. }
  55714. }
  55715. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  55716. import { Nullable } from "babylonjs/types";
  55717. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55719. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55720. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55721. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55722. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55723. /** @hidden */
  55724. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55725. private _useDeltaForWorldStep;
  55726. world: any;
  55727. name: string;
  55728. private _physicsMaterials;
  55729. private _fixedTimeStep;
  55730. private _cannonRaycastResult;
  55731. private _raycastResult;
  55732. private _physicsBodysToRemoveAfterStep;
  55733. BJSCANNON: any;
  55734. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55735. setGravity(gravity: Vector3): void;
  55736. setTimeStep(timeStep: number): void;
  55737. getTimeStep(): number;
  55738. executeStep(delta: number): void;
  55739. private _removeMarkedPhysicsBodiesFromWorld;
  55740. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55741. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55742. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55743. private _processChildMeshes;
  55744. removePhysicsBody(impostor: PhysicsImpostor): void;
  55745. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55746. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55747. private _addMaterial;
  55748. private _checkWithEpsilon;
  55749. private _createShape;
  55750. private _createHeightmap;
  55751. private _minus90X;
  55752. private _plus90X;
  55753. private _tmpPosition;
  55754. private _tmpDeltaPosition;
  55755. private _tmpUnityRotation;
  55756. private _updatePhysicsBodyTransformation;
  55757. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55758. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55759. isSupported(): boolean;
  55760. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55761. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55762. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55763. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55764. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55765. getBodyMass(impostor: PhysicsImpostor): number;
  55766. getBodyFriction(impostor: PhysicsImpostor): number;
  55767. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55768. getBodyRestitution(impostor: PhysicsImpostor): number;
  55769. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55770. sleepBody(impostor: PhysicsImpostor): void;
  55771. wakeUpBody(impostor: PhysicsImpostor): void;
  55772. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55773. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55774. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55775. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55776. getRadius(impostor: PhysicsImpostor): number;
  55777. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55778. dispose(): void;
  55779. private _extendNamespace;
  55780. /**
  55781. * Does a raycast in the physics world
  55782. * @param from when should the ray start?
  55783. * @param to when should the ray end?
  55784. * @returns PhysicsRaycastResult
  55785. */
  55786. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55787. }
  55788. }
  55789. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  55790. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55791. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55792. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55794. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55795. import { Nullable } from "babylonjs/types";
  55796. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55797. /** @hidden */
  55798. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55799. world: any;
  55800. name: string;
  55801. BJSOIMO: any;
  55802. private _raycastResult;
  55803. constructor(iterations?: number, oimoInjection?: any);
  55804. setGravity(gravity: Vector3): void;
  55805. setTimeStep(timeStep: number): void;
  55806. getTimeStep(): number;
  55807. private _tmpImpostorsArray;
  55808. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55809. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55810. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55811. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55812. private _tmpPositionVector;
  55813. removePhysicsBody(impostor: PhysicsImpostor): void;
  55814. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55815. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55816. isSupported(): boolean;
  55817. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55818. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55819. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55820. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55821. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55822. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55823. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55824. getBodyMass(impostor: PhysicsImpostor): number;
  55825. getBodyFriction(impostor: PhysicsImpostor): number;
  55826. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55827. getBodyRestitution(impostor: PhysicsImpostor): number;
  55828. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55829. sleepBody(impostor: PhysicsImpostor): void;
  55830. wakeUpBody(impostor: PhysicsImpostor): void;
  55831. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55832. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55833. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55834. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55835. getRadius(impostor: PhysicsImpostor): number;
  55836. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55837. dispose(): void;
  55838. /**
  55839. * Does a raycast in the physics world
  55840. * @param from when should the ray start?
  55841. * @param to when should the ray end?
  55842. * @returns PhysicsRaycastResult
  55843. */
  55844. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55845. }
  55846. }
  55847. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  55848. import { Nullable } from "babylonjs/types";
  55849. import { Scene } from "babylonjs/scene";
  55850. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  55851. import { Color4 } from "babylonjs/Maths/math.color";
  55852. import { Mesh } from "babylonjs/Meshes/mesh";
  55853. /**
  55854. * Class containing static functions to help procedurally build meshes
  55855. */
  55856. export class RibbonBuilder {
  55857. /**
  55858. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55859. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55860. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55861. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55862. * * 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
  55863. * * 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
  55864. * * 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
  55865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55867. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55868. * * 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
  55869. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55870. * * 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
  55871. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55873. * @param name defines the name of the mesh
  55874. * @param options defines the options used to create the mesh
  55875. * @param scene defines the hosting scene
  55876. * @returns the ribbon mesh
  55877. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55879. */
  55880. static CreateRibbon(name: string, options: {
  55881. pathArray: Vector3[][];
  55882. closeArray?: boolean;
  55883. closePath?: boolean;
  55884. offset?: number;
  55885. updatable?: boolean;
  55886. sideOrientation?: number;
  55887. frontUVs?: Vector4;
  55888. backUVs?: Vector4;
  55889. instance?: Mesh;
  55890. invertUV?: boolean;
  55891. uvs?: Vector2[];
  55892. colors?: Color4[];
  55893. }, scene?: Nullable<Scene>): Mesh;
  55894. }
  55895. }
  55896. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  55897. import { Nullable } from "babylonjs/types";
  55898. import { Scene } from "babylonjs/scene";
  55899. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55900. import { Mesh } from "babylonjs/Meshes/mesh";
  55901. /**
  55902. * Class containing static functions to help procedurally build meshes
  55903. */
  55904. export class ShapeBuilder {
  55905. /**
  55906. * 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.
  55907. * * 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.
  55908. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55909. * * 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.
  55910. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55911. * * 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
  55912. * * 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
  55913. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55916. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55918. * @param name defines the name of the mesh
  55919. * @param options defines the options used to create the mesh
  55920. * @param scene defines the hosting scene
  55921. * @returns the extruded shape mesh
  55922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55924. */
  55925. static ExtrudeShape(name: string, options: {
  55926. shape: Vector3[];
  55927. path: Vector3[];
  55928. scale?: number;
  55929. rotation?: number;
  55930. cap?: number;
  55931. updatable?: boolean;
  55932. sideOrientation?: number;
  55933. frontUVs?: Vector4;
  55934. backUVs?: Vector4;
  55935. instance?: Mesh;
  55936. invertUV?: boolean;
  55937. }, scene?: Nullable<Scene>): Mesh;
  55938. /**
  55939. * Creates an custom extruded shape mesh.
  55940. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55941. * * 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.
  55942. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55943. * * 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
  55944. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55945. * * 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
  55946. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55947. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55948. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55949. * * 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
  55950. * * 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
  55951. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55954. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55956. * @param name defines the name of the mesh
  55957. * @param options defines the options used to create the mesh
  55958. * @param scene defines the hosting scene
  55959. * @returns the custom extruded shape mesh
  55960. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55961. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55962. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55963. */
  55964. static ExtrudeShapeCustom(name: string, options: {
  55965. shape: Vector3[];
  55966. path: Vector3[];
  55967. scaleFunction?: any;
  55968. rotationFunction?: any;
  55969. ribbonCloseArray?: boolean;
  55970. ribbonClosePath?: boolean;
  55971. cap?: number;
  55972. updatable?: boolean;
  55973. sideOrientation?: number;
  55974. frontUVs?: Vector4;
  55975. backUVs?: Vector4;
  55976. instance?: Mesh;
  55977. invertUV?: boolean;
  55978. }, scene?: Nullable<Scene>): Mesh;
  55979. private static _ExtrudeShapeGeneric;
  55980. }
  55981. }
  55982. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  55983. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  55984. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55985. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55986. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55987. import { Nullable } from "babylonjs/types";
  55988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55989. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55990. /**
  55991. * AmmoJS Physics plugin
  55992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55993. * @see https://github.com/kripken/ammo.js/
  55994. */
  55995. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55996. private _useDeltaForWorldStep;
  55997. /**
  55998. * Reference to the Ammo library
  55999. */
  56000. bjsAMMO: any;
  56001. /**
  56002. * Created ammoJS world which physics bodies are added to
  56003. */
  56004. world: any;
  56005. /**
  56006. * Name of the plugin
  56007. */
  56008. name: string;
  56009. private _timeStep;
  56010. private _fixedTimeStep;
  56011. private _maxSteps;
  56012. private _tmpQuaternion;
  56013. private _tmpAmmoTransform;
  56014. private _tmpAmmoQuaternion;
  56015. private _tmpAmmoConcreteContactResultCallback;
  56016. private _collisionConfiguration;
  56017. private _dispatcher;
  56018. private _overlappingPairCache;
  56019. private _solver;
  56020. private _softBodySolver;
  56021. private _tmpAmmoVectorA;
  56022. private _tmpAmmoVectorB;
  56023. private _tmpAmmoVectorC;
  56024. private _tmpAmmoVectorD;
  56025. private _tmpContactCallbackResult;
  56026. private _tmpAmmoVectorRCA;
  56027. private _tmpAmmoVectorRCB;
  56028. private _raycastResult;
  56029. private static readonly DISABLE_COLLISION_FLAG;
  56030. private static readonly KINEMATIC_FLAG;
  56031. private static readonly DISABLE_DEACTIVATION_FLAG;
  56032. /**
  56033. * Initializes the ammoJS plugin
  56034. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56035. * @param ammoInjection can be used to inject your own ammo reference
  56036. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56037. */
  56038. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56039. /**
  56040. * Sets the gravity of the physics world (m/(s^2))
  56041. * @param gravity Gravity to set
  56042. */
  56043. setGravity(gravity: Vector3): void;
  56044. /**
  56045. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56046. * @param timeStep timestep to use in seconds
  56047. */
  56048. setTimeStep(timeStep: number): void;
  56049. /**
  56050. * 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)
  56051. * @param fixedTimeStep fixedTimeStep to use in seconds
  56052. */
  56053. setFixedTimeStep(fixedTimeStep: number): void;
  56054. /**
  56055. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56056. * @param maxSteps the maximum number of steps by the physics engine per frame
  56057. */
  56058. setMaxSteps(maxSteps: number): void;
  56059. /**
  56060. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56061. * @returns the current timestep in seconds
  56062. */
  56063. getTimeStep(): number;
  56064. /**
  56065. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56066. */
  56067. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56068. private _isImpostorInContact;
  56069. private _isImpostorPairInContact;
  56070. private _stepSimulation;
  56071. /**
  56072. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56073. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56074. * After the step the babylon meshes are set to the position of the physics imposters
  56075. * @param delta amount of time to step forward
  56076. * @param impostors array of imposters to update before/after the step
  56077. */
  56078. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56079. /**
  56080. * Update babylon mesh to match physics world object
  56081. * @param impostor imposter to match
  56082. */
  56083. private _afterSoftStep;
  56084. /**
  56085. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56086. * @param impostor imposter to match
  56087. */
  56088. private _ropeStep;
  56089. /**
  56090. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56091. * @param impostor imposter to match
  56092. */
  56093. private _softbodyOrClothStep;
  56094. private _tmpVector;
  56095. private _tmpMatrix;
  56096. /**
  56097. * Applies an impulse on the imposter
  56098. * @param impostor imposter to apply impulse to
  56099. * @param force amount of force to be applied to the imposter
  56100. * @param contactPoint the location to apply the impulse on the imposter
  56101. */
  56102. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56103. /**
  56104. * Applies a force on the imposter
  56105. * @param impostor imposter to apply force
  56106. * @param force amount of force to be applied to the imposter
  56107. * @param contactPoint the location to apply the force on the imposter
  56108. */
  56109. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56110. /**
  56111. * Creates a physics body using the plugin
  56112. * @param impostor the imposter to create the physics body on
  56113. */
  56114. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56115. /**
  56116. * Removes the physics body from the imposter and disposes of the body's memory
  56117. * @param impostor imposter to remove the physics body from
  56118. */
  56119. removePhysicsBody(impostor: PhysicsImpostor): void;
  56120. /**
  56121. * Generates a joint
  56122. * @param impostorJoint the imposter joint to create the joint with
  56123. */
  56124. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56125. /**
  56126. * Removes a joint
  56127. * @param impostorJoint the imposter joint to remove the joint from
  56128. */
  56129. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56130. private _addMeshVerts;
  56131. /**
  56132. * Initialise the soft body vertices to match its object's (mesh) vertices
  56133. * Softbody vertices (nodes) are in world space and to match this
  56134. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56135. * @param impostor to create the softbody for
  56136. */
  56137. private _softVertexData;
  56138. /**
  56139. * Create an impostor's soft body
  56140. * @param impostor to create the softbody for
  56141. */
  56142. private _createSoftbody;
  56143. /**
  56144. * Create cloth for an impostor
  56145. * @param impostor to create the softbody for
  56146. */
  56147. private _createCloth;
  56148. /**
  56149. * Create rope for an impostor
  56150. * @param impostor to create the softbody for
  56151. */
  56152. private _createRope;
  56153. /**
  56154. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56155. * @param impostor to create the custom physics shape for
  56156. */
  56157. private _createCustom;
  56158. private _addHullVerts;
  56159. private _createShape;
  56160. /**
  56161. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56162. * @param impostor imposter containing the physics body and babylon object
  56163. */
  56164. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56165. /**
  56166. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56167. * @param impostor imposter containing the physics body and babylon object
  56168. * @param newPosition new position
  56169. * @param newRotation new rotation
  56170. */
  56171. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56172. /**
  56173. * If this plugin is supported
  56174. * @returns true if its supported
  56175. */
  56176. isSupported(): boolean;
  56177. /**
  56178. * Sets the linear velocity of the physics body
  56179. * @param impostor imposter to set the velocity on
  56180. * @param velocity velocity to set
  56181. */
  56182. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56183. /**
  56184. * Sets the angular velocity of the physics body
  56185. * @param impostor imposter to set the velocity on
  56186. * @param velocity velocity to set
  56187. */
  56188. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56189. /**
  56190. * gets the linear velocity
  56191. * @param impostor imposter to get linear velocity from
  56192. * @returns linear velocity
  56193. */
  56194. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56195. /**
  56196. * gets the angular velocity
  56197. * @param impostor imposter to get angular velocity from
  56198. * @returns angular velocity
  56199. */
  56200. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56201. /**
  56202. * Sets the mass of physics body
  56203. * @param impostor imposter to set the mass on
  56204. * @param mass mass to set
  56205. */
  56206. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56207. /**
  56208. * Gets the mass of the physics body
  56209. * @param impostor imposter to get the mass from
  56210. * @returns mass
  56211. */
  56212. getBodyMass(impostor: PhysicsImpostor): number;
  56213. /**
  56214. * Gets friction of the impostor
  56215. * @param impostor impostor to get friction from
  56216. * @returns friction value
  56217. */
  56218. getBodyFriction(impostor: PhysicsImpostor): number;
  56219. /**
  56220. * Sets friction of the impostor
  56221. * @param impostor impostor to set friction on
  56222. * @param friction friction value
  56223. */
  56224. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56225. /**
  56226. * Gets restitution of the impostor
  56227. * @param impostor impostor to get restitution from
  56228. * @returns restitution value
  56229. */
  56230. getBodyRestitution(impostor: PhysicsImpostor): number;
  56231. /**
  56232. * Sets resitution of the impostor
  56233. * @param impostor impostor to set resitution on
  56234. * @param restitution resitution value
  56235. */
  56236. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56237. /**
  56238. * Gets pressure inside the impostor
  56239. * @param impostor impostor to get pressure from
  56240. * @returns pressure value
  56241. */
  56242. getBodyPressure(impostor: PhysicsImpostor): number;
  56243. /**
  56244. * Sets pressure inside a soft body impostor
  56245. * Cloth and rope must remain 0 pressure
  56246. * @param impostor impostor to set pressure on
  56247. * @param pressure pressure value
  56248. */
  56249. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56250. /**
  56251. * Gets stiffness of the impostor
  56252. * @param impostor impostor to get stiffness from
  56253. * @returns pressure value
  56254. */
  56255. getBodyStiffness(impostor: PhysicsImpostor): number;
  56256. /**
  56257. * Sets stiffness of the impostor
  56258. * @param impostor impostor to set stiffness on
  56259. * @param stiffness stiffness value from 0 to 1
  56260. */
  56261. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56262. /**
  56263. * Gets velocityIterations of the impostor
  56264. * @param impostor impostor to get velocity iterations from
  56265. * @returns velocityIterations value
  56266. */
  56267. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56268. /**
  56269. * Sets velocityIterations of the impostor
  56270. * @param impostor impostor to set velocity iterations on
  56271. * @param velocityIterations velocityIterations value
  56272. */
  56273. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56274. /**
  56275. * Gets positionIterations of the impostor
  56276. * @param impostor impostor to get position iterations from
  56277. * @returns positionIterations value
  56278. */
  56279. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56280. /**
  56281. * Sets positionIterations of the impostor
  56282. * @param impostor impostor to set position on
  56283. * @param positionIterations positionIterations value
  56284. */
  56285. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56286. /**
  56287. * Append an anchor to a cloth object
  56288. * @param impostor is the cloth impostor to add anchor to
  56289. * @param otherImpostor is the rigid impostor to anchor to
  56290. * @param width ratio across width from 0 to 1
  56291. * @param height ratio up height from 0 to 1
  56292. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56293. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56294. */
  56295. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56296. /**
  56297. * Append an hook to a rope object
  56298. * @param impostor is the rope impostor to add hook to
  56299. * @param otherImpostor is the rigid impostor to hook to
  56300. * @param length ratio along the rope from 0 to 1
  56301. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56302. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56303. */
  56304. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56305. /**
  56306. * Sleeps the physics body and stops it from being active
  56307. * @param impostor impostor to sleep
  56308. */
  56309. sleepBody(impostor: PhysicsImpostor): void;
  56310. /**
  56311. * Activates the physics body
  56312. * @param impostor impostor to activate
  56313. */
  56314. wakeUpBody(impostor: PhysicsImpostor): void;
  56315. /**
  56316. * Updates the distance parameters of the joint
  56317. * @param joint joint to update
  56318. * @param maxDistance maximum distance of the joint
  56319. * @param minDistance minimum distance of the joint
  56320. */
  56321. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56322. /**
  56323. * Sets a motor on the joint
  56324. * @param joint joint to set motor on
  56325. * @param speed speed of the motor
  56326. * @param maxForce maximum force of the motor
  56327. * @param motorIndex index of the motor
  56328. */
  56329. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56330. /**
  56331. * Sets the motors limit
  56332. * @param joint joint to set limit on
  56333. * @param upperLimit upper limit
  56334. * @param lowerLimit lower limit
  56335. */
  56336. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56337. /**
  56338. * Syncs the position and rotation of a mesh with the impostor
  56339. * @param mesh mesh to sync
  56340. * @param impostor impostor to update the mesh with
  56341. */
  56342. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56343. /**
  56344. * Gets the radius of the impostor
  56345. * @param impostor impostor to get radius from
  56346. * @returns the radius
  56347. */
  56348. getRadius(impostor: PhysicsImpostor): number;
  56349. /**
  56350. * Gets the box size of the impostor
  56351. * @param impostor impostor to get box size from
  56352. * @param result the resulting box size
  56353. */
  56354. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56355. /**
  56356. * Disposes of the impostor
  56357. */
  56358. dispose(): void;
  56359. /**
  56360. * Does a raycast in the physics world
  56361. * @param from when should the ray start?
  56362. * @param to when should the ray end?
  56363. * @returns PhysicsRaycastResult
  56364. */
  56365. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56366. }
  56367. }
  56368. declare module "babylonjs/Probes/reflectionProbe" {
  56369. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56370. import { Vector3 } from "babylonjs/Maths/math.vector";
  56371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56372. import { Nullable } from "babylonjs/types";
  56373. import { Scene } from "babylonjs/scene";
  56374. module "babylonjs/abstractScene" {
  56375. interface AbstractScene {
  56376. /**
  56377. * The list of reflection probes added to the scene
  56378. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56379. */
  56380. reflectionProbes: Array<ReflectionProbe>;
  56381. /**
  56382. * Removes the given reflection probe from this scene.
  56383. * @param toRemove The reflection probe to remove
  56384. * @returns The index of the removed reflection probe
  56385. */
  56386. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56387. /**
  56388. * Adds the given reflection probe to this scene.
  56389. * @param newReflectionProbe The reflection probe to add
  56390. */
  56391. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56392. }
  56393. }
  56394. /**
  56395. * Class used to generate realtime reflection / refraction cube textures
  56396. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56397. */
  56398. export class ReflectionProbe {
  56399. /** defines the name of the probe */
  56400. name: string;
  56401. private _scene;
  56402. private _renderTargetTexture;
  56403. private _projectionMatrix;
  56404. private _viewMatrix;
  56405. private _target;
  56406. private _add;
  56407. private _attachedMesh;
  56408. private _invertYAxis;
  56409. /** Gets or sets probe position (center of the cube map) */
  56410. position: Vector3;
  56411. /**
  56412. * Creates a new reflection probe
  56413. * @param name defines the name of the probe
  56414. * @param size defines the texture resolution (for each face)
  56415. * @param scene defines the hosting scene
  56416. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56417. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56418. */
  56419. constructor(
  56420. /** defines the name of the probe */
  56421. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56422. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56423. get samples(): number;
  56424. set samples(value: number);
  56425. /** Gets or sets the refresh rate to use (on every frame by default) */
  56426. get refreshRate(): number;
  56427. set refreshRate(value: number);
  56428. /**
  56429. * Gets the hosting scene
  56430. * @returns a Scene
  56431. */
  56432. getScene(): Scene;
  56433. /** Gets the internal CubeTexture used to render to */
  56434. get cubeTexture(): RenderTargetTexture;
  56435. /** Gets the list of meshes to render */
  56436. get renderList(): Nullable<AbstractMesh[]>;
  56437. /**
  56438. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56439. * @param mesh defines the mesh to attach to
  56440. */
  56441. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56442. /**
  56443. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56444. * @param renderingGroupId The rendering group id corresponding to its index
  56445. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56446. */
  56447. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56448. /**
  56449. * Clean all associated resources
  56450. */
  56451. dispose(): void;
  56452. /**
  56453. * Converts the reflection probe information to a readable string for debug purpose.
  56454. * @param fullDetails Supports for multiple levels of logging within scene loading
  56455. * @returns the human readable reflection probe info
  56456. */
  56457. toString(fullDetails?: boolean): string;
  56458. /**
  56459. * Get the class name of the relfection probe.
  56460. * @returns "ReflectionProbe"
  56461. */
  56462. getClassName(): string;
  56463. /**
  56464. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56465. * @returns The JSON representation of the texture
  56466. */
  56467. serialize(): any;
  56468. /**
  56469. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56470. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56471. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56472. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56473. * @returns The parsed reflection probe if successful
  56474. */
  56475. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56476. }
  56477. }
  56478. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  56479. /** @hidden */
  56480. export var _BabylonLoaderRegistered: boolean;
  56481. /**
  56482. * Helps setting up some configuration for the babylon file loader.
  56483. */
  56484. export class BabylonFileLoaderConfiguration {
  56485. /**
  56486. * The loader does not allow injecting custom physix engine into the plugins.
  56487. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56488. * So you could set this variable to your engine import to make it work.
  56489. */
  56490. static LoaderInjectedPhysicsEngine: any;
  56491. }
  56492. }
  56493. declare module "babylonjs/Loading/Plugins/index" {
  56494. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  56495. }
  56496. declare module "babylonjs/Loading/index" {
  56497. export * from "babylonjs/Loading/loadingScreen";
  56498. export * from "babylonjs/Loading/Plugins/index";
  56499. export * from "babylonjs/Loading/sceneLoader";
  56500. export * from "babylonjs/Loading/sceneLoaderFlags";
  56501. }
  56502. declare module "babylonjs/Materials/Background/index" {
  56503. export * from "babylonjs/Materials/Background/backgroundMaterial";
  56504. }
  56505. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  56506. import { Scene } from "babylonjs/scene";
  56507. import { Color3 } from "babylonjs/Maths/math.color";
  56508. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56510. /**
  56511. * The Physically based simple base material of BJS.
  56512. *
  56513. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56514. * It is used as the base class for both the specGloss and metalRough conventions.
  56515. */
  56516. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56517. /**
  56518. * Number of Simultaneous lights allowed on the material.
  56519. */
  56520. maxSimultaneousLights: number;
  56521. /**
  56522. * If sets to true, disables all the lights affecting the material.
  56523. */
  56524. disableLighting: boolean;
  56525. /**
  56526. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56527. */
  56528. environmentTexture: BaseTexture;
  56529. /**
  56530. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56531. */
  56532. invertNormalMapX: boolean;
  56533. /**
  56534. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56535. */
  56536. invertNormalMapY: boolean;
  56537. /**
  56538. * Normal map used in the model.
  56539. */
  56540. normalTexture: BaseTexture;
  56541. /**
  56542. * Emissivie color used to self-illuminate the model.
  56543. */
  56544. emissiveColor: Color3;
  56545. /**
  56546. * Emissivie texture used to self-illuminate the model.
  56547. */
  56548. emissiveTexture: BaseTexture;
  56549. /**
  56550. * Occlusion Channel Strenght.
  56551. */
  56552. occlusionStrength: number;
  56553. /**
  56554. * Occlusion Texture of the material (adding extra occlusion effects).
  56555. */
  56556. occlusionTexture: BaseTexture;
  56557. /**
  56558. * Defines the alpha limits in alpha test mode.
  56559. */
  56560. alphaCutOff: number;
  56561. /**
  56562. * Gets the current double sided mode.
  56563. */
  56564. get doubleSided(): boolean;
  56565. /**
  56566. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56567. */
  56568. set doubleSided(value: boolean);
  56569. /**
  56570. * Stores the pre-calculated light information of a mesh in a texture.
  56571. */
  56572. lightmapTexture: BaseTexture;
  56573. /**
  56574. * If true, the light map contains occlusion information instead of lighting info.
  56575. */
  56576. useLightmapAsShadowmap: boolean;
  56577. /**
  56578. * Instantiates a new PBRMaterial instance.
  56579. *
  56580. * @param name The material name
  56581. * @param scene The scene the material will be use in.
  56582. */
  56583. constructor(name: string, scene: Scene);
  56584. getClassName(): string;
  56585. }
  56586. }
  56587. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  56588. import { Scene } from "babylonjs/scene";
  56589. import { Color3 } from "babylonjs/Maths/math.color";
  56590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56591. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56592. /**
  56593. * The PBR material of BJS following the metal roughness convention.
  56594. *
  56595. * This fits to the PBR convention in the GLTF definition:
  56596. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56597. */
  56598. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56599. /**
  56600. * The base color has two different interpretations depending on the value of metalness.
  56601. * When the material is a metal, the base color is the specific measured reflectance value
  56602. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56603. * of the material.
  56604. */
  56605. baseColor: Color3;
  56606. /**
  56607. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56608. * well as opacity information in the alpha channel.
  56609. */
  56610. baseTexture: BaseTexture;
  56611. /**
  56612. * Specifies the metallic scalar value of the material.
  56613. * Can also be used to scale the metalness values of the metallic texture.
  56614. */
  56615. metallic: number;
  56616. /**
  56617. * Specifies the roughness scalar value of the material.
  56618. * Can also be used to scale the roughness values of the metallic texture.
  56619. */
  56620. roughness: number;
  56621. /**
  56622. * Texture containing both the metallic value in the B channel and the
  56623. * roughness value in the G channel to keep better precision.
  56624. */
  56625. metallicRoughnessTexture: BaseTexture;
  56626. /**
  56627. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56628. *
  56629. * @param name The material name
  56630. * @param scene The scene the material will be use in.
  56631. */
  56632. constructor(name: string, scene: Scene);
  56633. /**
  56634. * Return the currrent class name of the material.
  56635. */
  56636. getClassName(): string;
  56637. /**
  56638. * Makes a duplicate of the current material.
  56639. * @param name - name to use for the new material.
  56640. */
  56641. clone(name: string): PBRMetallicRoughnessMaterial;
  56642. /**
  56643. * Serialize the material to a parsable JSON object.
  56644. */
  56645. serialize(): any;
  56646. /**
  56647. * Parses a JSON object correponding to the serialize function.
  56648. */
  56649. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56650. }
  56651. }
  56652. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  56653. import { Scene } from "babylonjs/scene";
  56654. import { Color3 } from "babylonjs/Maths/math.color";
  56655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56656. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56657. /**
  56658. * The PBR material of BJS following the specular glossiness convention.
  56659. *
  56660. * This fits to the PBR convention in the GLTF definition:
  56661. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56662. */
  56663. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56664. /**
  56665. * Specifies the diffuse color of the material.
  56666. */
  56667. diffuseColor: Color3;
  56668. /**
  56669. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56670. * channel.
  56671. */
  56672. diffuseTexture: BaseTexture;
  56673. /**
  56674. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56675. */
  56676. specularColor: Color3;
  56677. /**
  56678. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56679. */
  56680. glossiness: number;
  56681. /**
  56682. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56683. */
  56684. specularGlossinessTexture: BaseTexture;
  56685. /**
  56686. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56687. *
  56688. * @param name The material name
  56689. * @param scene The scene the material will be use in.
  56690. */
  56691. constructor(name: string, scene: Scene);
  56692. /**
  56693. * Return the currrent class name of the material.
  56694. */
  56695. getClassName(): string;
  56696. /**
  56697. * Makes a duplicate of the current material.
  56698. * @param name - name to use for the new material.
  56699. */
  56700. clone(name: string): PBRSpecularGlossinessMaterial;
  56701. /**
  56702. * Serialize the material to a parsable JSON object.
  56703. */
  56704. serialize(): any;
  56705. /**
  56706. * Parses a JSON object correponding to the serialize function.
  56707. */
  56708. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56709. }
  56710. }
  56711. declare module "babylonjs/Materials/PBR/index" {
  56712. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56713. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56714. export * from "babylonjs/Materials/PBR/pbrMaterial";
  56715. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  56716. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  56717. }
  56718. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  56719. import { Nullable } from "babylonjs/types";
  56720. import { Scene } from "babylonjs/scene";
  56721. import { Matrix } from "babylonjs/Maths/math.vector";
  56722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56723. /**
  56724. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56725. * It can help converting any input color in a desired output one. This can then be used to create effects
  56726. * from sepia, black and white to sixties or futuristic rendering...
  56727. *
  56728. * The only supported format is currently 3dl.
  56729. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56730. */
  56731. export class ColorGradingTexture extends BaseTexture {
  56732. /**
  56733. * The current texture matrix. (will always be identity in color grading texture)
  56734. */
  56735. private _textureMatrix;
  56736. /**
  56737. * The texture URL.
  56738. */
  56739. url: string;
  56740. /**
  56741. * Empty line regex stored for GC.
  56742. */
  56743. private static _noneEmptyLineRegex;
  56744. private _engine;
  56745. /**
  56746. * Instantiates a ColorGradingTexture from the following parameters.
  56747. *
  56748. * @param url The location of the color gradind data (currently only supporting 3dl)
  56749. * @param scene The scene the texture will be used in
  56750. */
  56751. constructor(url: string, scene: Scene);
  56752. /**
  56753. * Returns the texture matrix used in most of the material.
  56754. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56755. */
  56756. getTextureMatrix(): Matrix;
  56757. /**
  56758. * Occurs when the file being loaded is a .3dl LUT file.
  56759. */
  56760. private load3dlTexture;
  56761. /**
  56762. * Starts the loading process of the texture.
  56763. */
  56764. private loadTexture;
  56765. /**
  56766. * Clones the color gradind texture.
  56767. */
  56768. clone(): ColorGradingTexture;
  56769. /**
  56770. * Called during delayed load for textures.
  56771. */
  56772. delayLoad(): void;
  56773. /**
  56774. * Parses a color grading texture serialized by Babylon.
  56775. * @param parsedTexture The texture information being parsedTexture
  56776. * @param scene The scene to load the texture in
  56777. * @param rootUrl The root url of the data assets to load
  56778. * @return A color gradind texture
  56779. */
  56780. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56781. /**
  56782. * Serializes the LUT texture to json format.
  56783. */
  56784. serialize(): any;
  56785. }
  56786. }
  56787. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  56788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56789. import { Scene } from "babylonjs/scene";
  56790. import { Nullable } from "babylonjs/types";
  56791. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56792. /**
  56793. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56794. */
  56795. export class EquiRectangularCubeTexture extends BaseTexture {
  56796. /** The six faces of the cube. */
  56797. private static _FacesMapping;
  56798. private _noMipmap;
  56799. private _onLoad;
  56800. private _onError;
  56801. /** The size of the cubemap. */
  56802. private _size;
  56803. /** The buffer of the image. */
  56804. private _buffer;
  56805. /** The width of the input image. */
  56806. private _width;
  56807. /** The height of the input image. */
  56808. private _height;
  56809. /** The URL to the image. */
  56810. url: string;
  56811. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56812. coordinatesMode: number;
  56813. /**
  56814. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56815. * @param url The location of the image
  56816. * @param scene The scene the texture will be used in
  56817. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56818. * @param noMipmap Forces to not generate the mipmap if true
  56819. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56820. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56821. * @param onLoad — defines a callback called when texture is loaded
  56822. * @param onError — defines a callback called if there is an error
  56823. */
  56824. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56825. /**
  56826. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56827. */
  56828. private loadImage;
  56829. /**
  56830. * Convert the image buffer into a cubemap and create a CubeTexture.
  56831. */
  56832. private loadTexture;
  56833. /**
  56834. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56835. * @param buffer The ArrayBuffer that should be converted.
  56836. * @returns The buffer as Float32Array.
  56837. */
  56838. private getFloat32ArrayFromArrayBuffer;
  56839. /**
  56840. * Get the current class name of the texture useful for serialization or dynamic coding.
  56841. * @returns "EquiRectangularCubeTexture"
  56842. */
  56843. getClassName(): string;
  56844. /**
  56845. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56846. * @returns A clone of the current EquiRectangularCubeTexture.
  56847. */
  56848. clone(): EquiRectangularCubeTexture;
  56849. }
  56850. }
  56851. declare module "babylonjs/Misc/tga" {
  56852. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56853. /**
  56854. * Based on jsTGALoader - Javascript loader for TGA file
  56855. * By Vincent Thibault
  56856. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56857. */
  56858. export class TGATools {
  56859. private static _TYPE_INDEXED;
  56860. private static _TYPE_RGB;
  56861. private static _TYPE_GREY;
  56862. private static _TYPE_RLE_INDEXED;
  56863. private static _TYPE_RLE_RGB;
  56864. private static _TYPE_RLE_GREY;
  56865. private static _ORIGIN_MASK;
  56866. private static _ORIGIN_SHIFT;
  56867. private static _ORIGIN_BL;
  56868. private static _ORIGIN_BR;
  56869. private static _ORIGIN_UL;
  56870. private static _ORIGIN_UR;
  56871. /**
  56872. * Gets the header of a TGA file
  56873. * @param data defines the TGA data
  56874. * @returns the header
  56875. */
  56876. static GetTGAHeader(data: Uint8Array): any;
  56877. /**
  56878. * Uploads TGA content to a Babylon Texture
  56879. * @hidden
  56880. */
  56881. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56882. /** @hidden */
  56883. 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;
  56884. /** @hidden */
  56885. 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;
  56886. /** @hidden */
  56887. 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;
  56888. /** @hidden */
  56889. 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;
  56890. /** @hidden */
  56891. 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;
  56892. /** @hidden */
  56893. 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;
  56894. }
  56895. }
  56896. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  56897. import { Nullable } from "babylonjs/types";
  56898. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56899. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56900. /**
  56901. * Implementation of the TGA Texture Loader.
  56902. * @hidden
  56903. */
  56904. export class _TGATextureLoader implements IInternalTextureLoader {
  56905. /**
  56906. * Defines wether the loader supports cascade loading the different faces.
  56907. */
  56908. readonly supportCascades: boolean;
  56909. /**
  56910. * This returns if the loader support the current file information.
  56911. * @param extension defines the file extension of the file being loaded
  56912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56913. * @param fallback defines the fallback internal texture if any
  56914. * @param isBase64 defines whether the texture is encoded as a base64
  56915. * @param isBuffer defines whether the texture data are stored as a buffer
  56916. * @returns true if the loader can load the specified file
  56917. */
  56918. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56919. /**
  56920. * Transform the url before loading if required.
  56921. * @param rootUrl the url of the texture
  56922. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56923. * @returns the transformed texture
  56924. */
  56925. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56926. /**
  56927. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56928. * @param rootUrl the url of the texture
  56929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56930. * @returns the fallback texture
  56931. */
  56932. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56933. /**
  56934. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56935. * @param data contains the texture data
  56936. * @param texture defines the BabylonJS internal texture
  56937. * @param createPolynomials will be true if polynomials have been requested
  56938. * @param onLoad defines the callback to trigger once the texture is ready
  56939. * @param onError defines the callback to trigger in case of error
  56940. */
  56941. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56942. /**
  56943. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56944. * @param data contains the texture data
  56945. * @param texture defines the BabylonJS internal texture
  56946. * @param callback defines the method to call once ready to upload
  56947. */
  56948. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56949. }
  56950. }
  56951. declare module "babylonjs/Misc/basis" {
  56952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56953. /**
  56954. * Info about the .basis files
  56955. */
  56956. class BasisFileInfo {
  56957. /**
  56958. * If the file has alpha
  56959. */
  56960. hasAlpha: boolean;
  56961. /**
  56962. * Info about each image of the basis file
  56963. */
  56964. images: Array<{
  56965. levels: Array<{
  56966. width: number;
  56967. height: number;
  56968. transcodedPixels: ArrayBufferView;
  56969. }>;
  56970. }>;
  56971. }
  56972. /**
  56973. * Result of transcoding a basis file
  56974. */
  56975. class TranscodeResult {
  56976. /**
  56977. * Info about the .basis file
  56978. */
  56979. fileInfo: BasisFileInfo;
  56980. /**
  56981. * Format to use when loading the file
  56982. */
  56983. format: number;
  56984. }
  56985. /**
  56986. * Configuration options for the Basis transcoder
  56987. */
  56988. export class BasisTranscodeConfiguration {
  56989. /**
  56990. * Supported compression formats used to determine the supported output format of the transcoder
  56991. */
  56992. supportedCompressionFormats?: {
  56993. /**
  56994. * etc1 compression format
  56995. */
  56996. etc1?: boolean;
  56997. /**
  56998. * s3tc compression format
  56999. */
  57000. s3tc?: boolean;
  57001. /**
  57002. * pvrtc compression format
  57003. */
  57004. pvrtc?: boolean;
  57005. /**
  57006. * etc2 compression format
  57007. */
  57008. etc2?: boolean;
  57009. };
  57010. /**
  57011. * If mipmap levels should be loaded for transcoded images (Default: true)
  57012. */
  57013. loadMipmapLevels?: boolean;
  57014. /**
  57015. * Index of a single image to load (Default: all images)
  57016. */
  57017. loadSingleImage?: number;
  57018. }
  57019. /**
  57020. * Used to load .Basis files
  57021. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57022. */
  57023. export class BasisTools {
  57024. private static _IgnoreSupportedFormats;
  57025. /**
  57026. * URL to use when loading the basis transcoder
  57027. */
  57028. static JSModuleURL: string;
  57029. /**
  57030. * URL to use when loading the wasm module for the transcoder
  57031. */
  57032. static WasmModuleURL: string;
  57033. /**
  57034. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57035. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57036. * @returns internal format corresponding to the Basis format
  57037. */
  57038. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57039. private static _WorkerPromise;
  57040. private static _Worker;
  57041. private static _actionId;
  57042. private static _CreateWorkerAsync;
  57043. /**
  57044. * Transcodes a loaded image file to compressed pixel data
  57045. * @param imageData image data to transcode
  57046. * @param config configuration options for the transcoding
  57047. * @returns a promise resulting in the transcoded image
  57048. */
  57049. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57050. /**
  57051. * Loads a texture from the transcode result
  57052. * @param texture texture load to
  57053. * @param transcodeResult the result of transcoding the basis file to load from
  57054. */
  57055. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57056. }
  57057. }
  57058. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57059. import { Nullable } from "babylonjs/types";
  57060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57061. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57062. /**
  57063. * Loader for .basis file format
  57064. */
  57065. export class _BasisTextureLoader implements IInternalTextureLoader {
  57066. /**
  57067. * Defines whether the loader supports cascade loading the different faces.
  57068. */
  57069. readonly supportCascades: boolean;
  57070. /**
  57071. * This returns if the loader support the current file information.
  57072. * @param extension defines the file extension of the file being loaded
  57073. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57074. * @param fallback defines the fallback internal texture if any
  57075. * @param isBase64 defines whether the texture is encoded as a base64
  57076. * @param isBuffer defines whether the texture data are stored as a buffer
  57077. * @returns true if the loader can load the specified file
  57078. */
  57079. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57080. /**
  57081. * Transform the url before loading if required.
  57082. * @param rootUrl the url of the texture
  57083. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57084. * @returns the transformed texture
  57085. */
  57086. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57087. /**
  57088. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57089. * @param rootUrl the url of the texture
  57090. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57091. * @returns the fallback texture
  57092. */
  57093. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57094. /**
  57095. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57096. * @param data contains the texture data
  57097. * @param texture defines the BabylonJS internal texture
  57098. * @param createPolynomials will be true if polynomials have been requested
  57099. * @param onLoad defines the callback to trigger once the texture is ready
  57100. * @param onError defines the callback to trigger in case of error
  57101. */
  57102. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57103. /**
  57104. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57105. * @param data contains the texture data
  57106. * @param texture defines the BabylonJS internal texture
  57107. * @param callback defines the method to call once ready to upload
  57108. */
  57109. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57110. }
  57111. }
  57112. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57113. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57114. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57115. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57116. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57117. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57118. }
  57119. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57120. import { Scene } from "babylonjs/scene";
  57121. import { Texture } from "babylonjs/Materials/Textures/texture";
  57122. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57123. /**
  57124. * 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.
  57125. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57126. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57127. */
  57128. export class CustomProceduralTexture extends ProceduralTexture {
  57129. private _animate;
  57130. private _time;
  57131. private _config;
  57132. private _texturePath;
  57133. /**
  57134. * Instantiates a new Custom Procedural Texture.
  57135. * 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.
  57136. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57137. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57138. * @param name Define the name of the texture
  57139. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57140. * @param size Define the size of the texture to create
  57141. * @param scene Define the scene the texture belongs to
  57142. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57143. * @param generateMipMaps Define if the texture should creates mip maps or not
  57144. */
  57145. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57146. private _loadJson;
  57147. /**
  57148. * Is the texture ready to be used ? (rendered at least once)
  57149. * @returns true if ready, otherwise, false.
  57150. */
  57151. isReady(): boolean;
  57152. /**
  57153. * Render the texture to its associated render target.
  57154. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57155. */
  57156. render(useCameraPostProcess?: boolean): void;
  57157. /**
  57158. * Update the list of dependant textures samplers in the shader.
  57159. */
  57160. updateTextures(): void;
  57161. /**
  57162. * Update the uniform values of the procedural texture in the shader.
  57163. */
  57164. updateShaderUniforms(): void;
  57165. /**
  57166. * Define if the texture animates or not.
  57167. */
  57168. get animate(): boolean;
  57169. set animate(value: boolean);
  57170. }
  57171. }
  57172. declare module "babylonjs/Shaders/noise.fragment" {
  57173. /** @hidden */
  57174. export var noisePixelShader: {
  57175. name: string;
  57176. shader: string;
  57177. };
  57178. }
  57179. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57180. import { Nullable } from "babylonjs/types";
  57181. import { Scene } from "babylonjs/scene";
  57182. import { Texture } from "babylonjs/Materials/Textures/texture";
  57183. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57184. import "babylonjs/Shaders/noise.fragment";
  57185. /**
  57186. * Class used to generate noise procedural textures
  57187. */
  57188. export class NoiseProceduralTexture extends ProceduralTexture {
  57189. private _time;
  57190. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57191. brightness: number;
  57192. /** Defines the number of octaves to process */
  57193. octaves: number;
  57194. /** Defines the level of persistence (0.8 by default) */
  57195. persistence: number;
  57196. /** Gets or sets animation speed factor (default is 1) */
  57197. animationSpeedFactor: number;
  57198. /**
  57199. * Creates a new NoiseProceduralTexture
  57200. * @param name defines the name fo the texture
  57201. * @param size defines the size of the texture (default is 256)
  57202. * @param scene defines the hosting scene
  57203. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57204. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57205. */
  57206. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57207. private _updateShaderUniforms;
  57208. protected _getDefines(): string;
  57209. /** Generate the current state of the procedural texture */
  57210. render(useCameraPostProcess?: boolean): void;
  57211. /**
  57212. * Serializes this noise procedural texture
  57213. * @returns a serialized noise procedural texture object
  57214. */
  57215. serialize(): any;
  57216. /**
  57217. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57218. * @param parsedTexture defines parsed texture data
  57219. * @param scene defines the current scene
  57220. * @param rootUrl defines the root URL containing noise procedural texture information
  57221. * @returns a parsed NoiseProceduralTexture
  57222. */
  57223. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57224. }
  57225. }
  57226. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  57227. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  57228. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  57229. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57230. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  57231. }
  57232. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  57233. import { Nullable } from "babylonjs/types";
  57234. import { Scene } from "babylonjs/scene";
  57235. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57236. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57237. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57238. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57239. /**
  57240. * Raw cube texture where the raw buffers are passed in
  57241. */
  57242. export class RawCubeTexture extends CubeTexture {
  57243. /**
  57244. * Creates a cube texture where the raw buffers are passed in.
  57245. * @param scene defines the scene the texture is attached to
  57246. * @param data defines the array of data to use to create each face
  57247. * @param size defines the size of the textures
  57248. * @param format defines the format of the data
  57249. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57250. * @param generateMipMaps defines if the engine should generate the mip levels
  57251. * @param invertY defines if data must be stored with Y axis inverted
  57252. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57253. * @param compression defines the compression used (null by default)
  57254. */
  57255. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57256. /**
  57257. * Updates the raw cube texture.
  57258. * @param data defines the data to store
  57259. * @param format defines the data format
  57260. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57261. * @param invertY defines if data must be stored with Y axis inverted
  57262. * @param compression defines the compression used (null by default)
  57263. * @param level defines which level of the texture to update
  57264. */
  57265. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57266. /**
  57267. * Updates a raw cube texture with RGBD encoded data.
  57268. * @param data defines the array of data [mipmap][face] to use to create each face
  57269. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57270. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57271. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57272. * @returns a promsie that resolves when the operation is complete
  57273. */
  57274. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57275. /**
  57276. * Clones the raw cube texture.
  57277. * @return a new cube texture
  57278. */
  57279. clone(): CubeTexture;
  57280. /** @hidden */
  57281. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57282. }
  57283. }
  57284. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  57285. import { Scene } from "babylonjs/scene";
  57286. import { Texture } from "babylonjs/Materials/Textures/texture";
  57287. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57288. /**
  57289. * Class used to store 3D textures containing user data
  57290. */
  57291. export class RawTexture3D extends Texture {
  57292. /** Gets or sets the texture format to use */
  57293. format: number;
  57294. private _engine;
  57295. /**
  57296. * Create a new RawTexture3D
  57297. * @param data defines the data of the texture
  57298. * @param width defines the width of the texture
  57299. * @param height defines the height of the texture
  57300. * @param depth defines the depth of the texture
  57301. * @param format defines the texture format to use
  57302. * @param scene defines the hosting scene
  57303. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57304. * @param invertY defines if texture must be stored with Y axis inverted
  57305. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57306. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57307. */
  57308. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57309. /** Gets or sets the texture format to use */
  57310. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57311. /**
  57312. * Update the texture with new data
  57313. * @param data defines the data to store in the texture
  57314. */
  57315. update(data: ArrayBufferView): void;
  57316. }
  57317. }
  57318. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  57319. import { Scene } from "babylonjs/scene";
  57320. import { Texture } from "babylonjs/Materials/Textures/texture";
  57321. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57322. /**
  57323. * Class used to store 2D array textures containing user data
  57324. */
  57325. export class RawTexture2DArray extends Texture {
  57326. /** Gets or sets the texture format to use */
  57327. format: number;
  57328. private _engine;
  57329. /**
  57330. * Create a new RawTexture2DArray
  57331. * @param data defines the data of the texture
  57332. * @param width defines the width of the texture
  57333. * @param height defines the height of the texture
  57334. * @param depth defines the number of layers of the texture
  57335. * @param format defines the texture format to use
  57336. * @param scene defines the hosting scene
  57337. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57338. * @param invertY defines if texture must be stored with Y axis inverted
  57339. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57340. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57341. */
  57342. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57343. /** Gets or sets the texture format to use */
  57344. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57345. /**
  57346. * Update the texture with new data
  57347. * @param data defines the data to store in the texture
  57348. */
  57349. update(data: ArrayBufferView): void;
  57350. }
  57351. }
  57352. declare module "babylonjs/Materials/Textures/refractionTexture" {
  57353. import { Scene } from "babylonjs/scene";
  57354. import { Plane } from "babylonjs/Maths/math.plane";
  57355. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57356. /**
  57357. * Creates a refraction texture used by refraction channel of the standard material.
  57358. * It is like a mirror but to see through a material.
  57359. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57360. */
  57361. export class RefractionTexture extends RenderTargetTexture {
  57362. /**
  57363. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57364. * 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.
  57365. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57366. */
  57367. refractionPlane: Plane;
  57368. /**
  57369. * Define how deep under the surface we should see.
  57370. */
  57371. depth: number;
  57372. /**
  57373. * Creates a refraction texture used by refraction channel of the standard material.
  57374. * It is like a mirror but to see through a material.
  57375. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57376. * @param name Define the texture name
  57377. * @param size Define the size of the underlying texture
  57378. * @param scene Define the scene the refraction belongs to
  57379. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57380. */
  57381. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57382. /**
  57383. * Clone the refraction texture.
  57384. * @returns the cloned texture
  57385. */
  57386. clone(): RefractionTexture;
  57387. /**
  57388. * Serialize the texture to a JSON representation you could use in Parse later on
  57389. * @returns the serialized JSON representation
  57390. */
  57391. serialize(): any;
  57392. }
  57393. }
  57394. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  57395. import { Nullable } from "babylonjs/types";
  57396. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57397. import { Matrix } from "babylonjs/Maths/math.vector";
  57398. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57399. import "babylonjs/Engines/Extensions/engine.videoTexture";
  57400. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  57401. import { Scene } from "babylonjs/scene";
  57402. /**
  57403. * Defines the options related to the creation of an HtmlElementTexture
  57404. */
  57405. export interface IHtmlElementTextureOptions {
  57406. /**
  57407. * Defines wether mip maps should be created or not.
  57408. */
  57409. generateMipMaps?: boolean;
  57410. /**
  57411. * Defines the sampling mode of the texture.
  57412. */
  57413. samplingMode?: number;
  57414. /**
  57415. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57416. */
  57417. engine: Nullable<ThinEngine>;
  57418. /**
  57419. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57420. */
  57421. scene: Nullable<Scene>;
  57422. }
  57423. /**
  57424. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57425. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57426. * is automatically managed.
  57427. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57428. * in your application.
  57429. *
  57430. * As the update is not automatic, you need to call them manually.
  57431. */
  57432. export class HtmlElementTexture extends BaseTexture {
  57433. /**
  57434. * The texture URL.
  57435. */
  57436. element: HTMLVideoElement | HTMLCanvasElement;
  57437. private static readonly DefaultOptions;
  57438. private _textureMatrix;
  57439. private _engine;
  57440. private _isVideo;
  57441. private _generateMipMaps;
  57442. private _samplingMode;
  57443. /**
  57444. * Instantiates a HtmlElementTexture from the following parameters.
  57445. *
  57446. * @param name Defines the name of the texture
  57447. * @param element Defines the video or canvas the texture is filled with
  57448. * @param options Defines the other none mandatory texture creation options
  57449. */
  57450. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57451. private _createInternalTexture;
  57452. /**
  57453. * Returns the texture matrix used in most of the material.
  57454. */
  57455. getTextureMatrix(): Matrix;
  57456. /**
  57457. * Updates the content of the texture.
  57458. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57459. */
  57460. update(invertY?: Nullable<boolean>): void;
  57461. }
  57462. }
  57463. declare module "babylonjs/Materials/Textures/index" {
  57464. export * from "babylonjs/Materials/Textures/baseTexture";
  57465. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  57466. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  57467. export * from "babylonjs/Materials/Textures/cubeTexture";
  57468. export * from "babylonjs/Materials/Textures/dynamicTexture";
  57469. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57470. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  57471. export * from "babylonjs/Materials/Textures/internalTexture";
  57472. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  57473. export * from "babylonjs/Materials/Textures/Loaders/index";
  57474. export * from "babylonjs/Materials/Textures/mirrorTexture";
  57475. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  57476. export * from "babylonjs/Materials/Textures/Procedurals/index";
  57477. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  57478. export * from "babylonjs/Materials/Textures/rawTexture";
  57479. export * from "babylonjs/Materials/Textures/rawTexture3D";
  57480. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  57481. export * from "babylonjs/Materials/Textures/refractionTexture";
  57482. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  57483. export * from "babylonjs/Materials/Textures/texture";
  57484. export * from "babylonjs/Materials/Textures/videoTexture";
  57485. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  57486. }
  57487. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  57488. /**
  57489. * Enum used to define the target of a block
  57490. */
  57491. export enum NodeMaterialBlockTargets {
  57492. /** Vertex shader */
  57493. Vertex = 1,
  57494. /** Fragment shader */
  57495. Fragment = 2,
  57496. /** Neutral */
  57497. Neutral = 4,
  57498. /** Vertex and Fragment */
  57499. VertexAndFragment = 3
  57500. }
  57501. }
  57502. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  57503. /**
  57504. * Defines the kind of connection point for node based material
  57505. */
  57506. export enum NodeMaterialBlockConnectionPointTypes {
  57507. /** Float */
  57508. Float = 1,
  57509. /** Int */
  57510. Int = 2,
  57511. /** Vector2 */
  57512. Vector2 = 4,
  57513. /** Vector3 */
  57514. Vector3 = 8,
  57515. /** Vector4 */
  57516. Vector4 = 16,
  57517. /** Color3 */
  57518. Color3 = 32,
  57519. /** Color4 */
  57520. Color4 = 64,
  57521. /** Matrix */
  57522. Matrix = 128,
  57523. /** Detect type based on connection */
  57524. AutoDetect = 1024,
  57525. /** Output type that will be defined by input type */
  57526. BasedOnInput = 2048
  57527. }
  57528. }
  57529. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  57530. /**
  57531. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57532. */
  57533. export enum NodeMaterialBlockConnectionPointMode {
  57534. /** Value is an uniform */
  57535. Uniform = 0,
  57536. /** Value is a mesh attribute */
  57537. Attribute = 1,
  57538. /** Value is a varying between vertex and fragment shaders */
  57539. Varying = 2,
  57540. /** Mode is undefined */
  57541. Undefined = 3
  57542. }
  57543. }
  57544. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  57545. /**
  57546. * Enum used to define system values e.g. values automatically provided by the system
  57547. */
  57548. export enum NodeMaterialSystemValues {
  57549. /** World */
  57550. World = 1,
  57551. /** View */
  57552. View = 2,
  57553. /** Projection */
  57554. Projection = 3,
  57555. /** ViewProjection */
  57556. ViewProjection = 4,
  57557. /** WorldView */
  57558. WorldView = 5,
  57559. /** WorldViewProjection */
  57560. WorldViewProjection = 6,
  57561. /** CameraPosition */
  57562. CameraPosition = 7,
  57563. /** Fog Color */
  57564. FogColor = 8,
  57565. /** Delta time */
  57566. DeltaTime = 9
  57567. }
  57568. }
  57569. declare module "babylonjs/Materials/Node/Enums/index" {
  57570. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57571. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57572. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  57573. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57574. }
  57575. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  57576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57577. /**
  57578. * Root class for all node material optimizers
  57579. */
  57580. export class NodeMaterialOptimizer {
  57581. /**
  57582. * Function used to optimize a NodeMaterial graph
  57583. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57584. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57585. */
  57586. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57587. }
  57588. }
  57589. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  57590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57593. import { Scene } from "babylonjs/scene";
  57594. /**
  57595. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57596. */
  57597. export class TransformBlock extends NodeMaterialBlock {
  57598. /**
  57599. * Defines the value to use to complement W value to transform it to a Vector4
  57600. */
  57601. complementW: number;
  57602. /**
  57603. * Defines the value to use to complement z value to transform it to a Vector4
  57604. */
  57605. complementZ: number;
  57606. /**
  57607. * Creates a new TransformBlock
  57608. * @param name defines the block name
  57609. */
  57610. constructor(name: string);
  57611. /**
  57612. * Gets the current class name
  57613. * @returns the class name
  57614. */
  57615. getClassName(): string;
  57616. /**
  57617. * Gets the vector input
  57618. */
  57619. get vector(): NodeMaterialConnectionPoint;
  57620. /**
  57621. * Gets the output component
  57622. */
  57623. get output(): NodeMaterialConnectionPoint;
  57624. /**
  57625. * Gets the matrix transform input
  57626. */
  57627. get transform(): NodeMaterialConnectionPoint;
  57628. protected _buildBlock(state: NodeMaterialBuildState): this;
  57629. serialize(): any;
  57630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57631. protected _dumpPropertiesCode(): string;
  57632. }
  57633. }
  57634. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  57635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57636. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57637. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57638. /**
  57639. * Block used to output the vertex position
  57640. */
  57641. export class VertexOutputBlock extends NodeMaterialBlock {
  57642. /**
  57643. * Creates a new VertexOutputBlock
  57644. * @param name defines the block name
  57645. */
  57646. constructor(name: string);
  57647. /**
  57648. * Gets the current class name
  57649. * @returns the class name
  57650. */
  57651. getClassName(): string;
  57652. /**
  57653. * Gets the vector input component
  57654. */
  57655. get vector(): NodeMaterialConnectionPoint;
  57656. protected _buildBlock(state: NodeMaterialBuildState): this;
  57657. }
  57658. }
  57659. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  57660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57663. /**
  57664. * Block used to output the final color
  57665. */
  57666. export class FragmentOutputBlock extends NodeMaterialBlock {
  57667. /**
  57668. * Create a new FragmentOutputBlock
  57669. * @param name defines the block name
  57670. */
  57671. constructor(name: string);
  57672. /**
  57673. * Gets the current class name
  57674. * @returns the class name
  57675. */
  57676. getClassName(): string;
  57677. /**
  57678. * Gets the rgba input component
  57679. */
  57680. get rgba(): NodeMaterialConnectionPoint;
  57681. /**
  57682. * Gets the rgb input component
  57683. */
  57684. get rgb(): NodeMaterialConnectionPoint;
  57685. /**
  57686. * Gets the a input component
  57687. */
  57688. get a(): NodeMaterialConnectionPoint;
  57689. protected _buildBlock(state: NodeMaterialBuildState): this;
  57690. }
  57691. }
  57692. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  57693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57696. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57698. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57699. import { Effect } from "babylonjs/Materials/effect";
  57700. import { Mesh } from "babylonjs/Meshes/mesh";
  57701. import { Nullable } from "babylonjs/types";
  57702. import { Scene } from "babylonjs/scene";
  57703. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57704. /**
  57705. * Block used to read a reflection texture from a sampler
  57706. */
  57707. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57708. private _define3DName;
  57709. private _defineCubicName;
  57710. private _defineExplicitName;
  57711. private _defineProjectionName;
  57712. private _defineLocalCubicName;
  57713. private _defineSphericalName;
  57714. private _definePlanarName;
  57715. private _defineEquirectangularName;
  57716. private _defineMirroredEquirectangularFixedName;
  57717. private _defineEquirectangularFixedName;
  57718. private _defineSkyboxName;
  57719. private _cubeSamplerName;
  57720. private _2DSamplerName;
  57721. private _positionUVWName;
  57722. private _directionWName;
  57723. private _reflectionCoordsName;
  57724. private _reflection2DCoordsName;
  57725. private _reflectionColorName;
  57726. private _reflectionMatrixName;
  57727. /**
  57728. * Gets or sets the texture associated with the node
  57729. */
  57730. texture: Nullable<BaseTexture>;
  57731. /**
  57732. * Create a new TextureBlock
  57733. * @param name defines the block name
  57734. */
  57735. constructor(name: string);
  57736. /**
  57737. * Gets the current class name
  57738. * @returns the class name
  57739. */
  57740. getClassName(): string;
  57741. /**
  57742. * Gets the world position input component
  57743. */
  57744. get position(): NodeMaterialConnectionPoint;
  57745. /**
  57746. * Gets the world position input component
  57747. */
  57748. get worldPosition(): NodeMaterialConnectionPoint;
  57749. /**
  57750. * Gets the world normal input component
  57751. */
  57752. get worldNormal(): NodeMaterialConnectionPoint;
  57753. /**
  57754. * Gets the world input component
  57755. */
  57756. get world(): NodeMaterialConnectionPoint;
  57757. /**
  57758. * Gets the camera (or eye) position component
  57759. */
  57760. get cameraPosition(): NodeMaterialConnectionPoint;
  57761. /**
  57762. * Gets the view input component
  57763. */
  57764. get view(): NodeMaterialConnectionPoint;
  57765. /**
  57766. * Gets the rgb output component
  57767. */
  57768. get rgb(): NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the r output component
  57771. */
  57772. get r(): NodeMaterialConnectionPoint;
  57773. /**
  57774. * Gets the g output component
  57775. */
  57776. get g(): NodeMaterialConnectionPoint;
  57777. /**
  57778. * Gets the b output component
  57779. */
  57780. get b(): NodeMaterialConnectionPoint;
  57781. autoConfigure(material: NodeMaterial): void;
  57782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57783. isReady(): boolean;
  57784. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57785. private _injectVertexCode;
  57786. private _writeOutput;
  57787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57788. protected _dumpPropertiesCode(): string;
  57789. serialize(): any;
  57790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57791. }
  57792. }
  57793. declare module "babylonjs/Materials/Node/nodeMaterial" {
  57794. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57795. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57796. import { Scene } from "babylonjs/scene";
  57797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57798. import { Matrix } from "babylonjs/Maths/math.vector";
  57799. import { Mesh } from "babylonjs/Meshes/mesh";
  57800. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57801. import { Observable } from "babylonjs/Misc/observable";
  57802. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57803. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57804. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57805. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57806. import { Nullable } from "babylonjs/types";
  57807. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57808. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57809. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57810. /**
  57811. * Interface used to configure the node material editor
  57812. */
  57813. export interface INodeMaterialEditorOptions {
  57814. /** Define the URl to load node editor script */
  57815. editorURL?: string;
  57816. }
  57817. /** @hidden */
  57818. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57819. /** BONES */
  57820. NUM_BONE_INFLUENCERS: number;
  57821. BonesPerMesh: number;
  57822. BONETEXTURE: boolean;
  57823. /** MORPH TARGETS */
  57824. MORPHTARGETS: boolean;
  57825. MORPHTARGETS_NORMAL: boolean;
  57826. MORPHTARGETS_TANGENT: boolean;
  57827. MORPHTARGETS_UV: boolean;
  57828. NUM_MORPH_INFLUENCERS: number;
  57829. /** IMAGE PROCESSING */
  57830. IMAGEPROCESSING: boolean;
  57831. VIGNETTE: boolean;
  57832. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57833. VIGNETTEBLENDMODEOPAQUE: boolean;
  57834. TONEMAPPING: boolean;
  57835. TONEMAPPING_ACES: boolean;
  57836. CONTRAST: boolean;
  57837. EXPOSURE: boolean;
  57838. COLORCURVES: boolean;
  57839. COLORGRADING: boolean;
  57840. COLORGRADING3D: boolean;
  57841. SAMPLER3DGREENDEPTH: boolean;
  57842. SAMPLER3DBGRMAP: boolean;
  57843. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57844. /** MISC. */
  57845. BUMPDIRECTUV: number;
  57846. constructor();
  57847. setValue(name: string, value: boolean): void;
  57848. }
  57849. /**
  57850. * Class used to configure NodeMaterial
  57851. */
  57852. export interface INodeMaterialOptions {
  57853. /**
  57854. * Defines if blocks should emit comments
  57855. */
  57856. emitComments: boolean;
  57857. }
  57858. /**
  57859. * Class used to create a node based material built by assembling shader blocks
  57860. */
  57861. export class NodeMaterial extends PushMaterial {
  57862. private static _BuildIdGenerator;
  57863. private _options;
  57864. private _vertexCompilationState;
  57865. private _fragmentCompilationState;
  57866. private _sharedData;
  57867. private _buildId;
  57868. private _buildWasSuccessful;
  57869. private _cachedWorldViewMatrix;
  57870. private _cachedWorldViewProjectionMatrix;
  57871. private _optimizers;
  57872. private _animationFrame;
  57873. /** Define the URl to load node editor script */
  57874. static EditorURL: string;
  57875. private BJSNODEMATERIALEDITOR;
  57876. /** Get the inspector from bundle or global */
  57877. private _getGlobalNodeMaterialEditor;
  57878. /**
  57879. * Gets or sets data used by visual editor
  57880. * @see https://nme.babylonjs.com
  57881. */
  57882. editorData: any;
  57883. /**
  57884. * 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)
  57885. */
  57886. ignoreAlpha: boolean;
  57887. /**
  57888. * Defines the maximum number of lights that can be used in the material
  57889. */
  57890. maxSimultaneousLights: number;
  57891. /**
  57892. * Observable raised when the material is built
  57893. */
  57894. onBuildObservable: Observable<NodeMaterial>;
  57895. /**
  57896. * Gets or sets the root nodes of the material vertex shader
  57897. */
  57898. _vertexOutputNodes: NodeMaterialBlock[];
  57899. /**
  57900. * Gets or sets the root nodes of the material fragment (pixel) shader
  57901. */
  57902. _fragmentOutputNodes: NodeMaterialBlock[];
  57903. /** Gets or sets options to control the node material overall behavior */
  57904. get options(): INodeMaterialOptions;
  57905. set options(options: INodeMaterialOptions);
  57906. /**
  57907. * Default configuration related to image processing available in the standard Material.
  57908. */
  57909. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57910. /**
  57911. * Gets the image processing configuration used either in this material.
  57912. */
  57913. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57914. /**
  57915. * Sets the Default image processing configuration used either in the this material.
  57916. *
  57917. * If sets to null, the scene one is in use.
  57918. */
  57919. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57920. /**
  57921. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57922. */
  57923. attachedBlocks: NodeMaterialBlock[];
  57924. /**
  57925. * Create a new node based material
  57926. * @param name defines the material name
  57927. * @param scene defines the hosting scene
  57928. * @param options defines creation option
  57929. */
  57930. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57931. /**
  57932. * Gets the current class name of the material e.g. "NodeMaterial"
  57933. * @returns the class name
  57934. */
  57935. getClassName(): string;
  57936. /**
  57937. * Keep track of the image processing observer to allow dispose and replace.
  57938. */
  57939. private _imageProcessingObserver;
  57940. /**
  57941. * Attaches a new image processing configuration to the Standard Material.
  57942. * @param configuration
  57943. */
  57944. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57945. /**
  57946. * Get a block by its name
  57947. * @param name defines the name of the block to retrieve
  57948. * @returns the required block or null if not found
  57949. */
  57950. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57951. /**
  57952. * Get a block by its name
  57953. * @param predicate defines the predicate used to find the good candidate
  57954. * @returns the required block or null if not found
  57955. */
  57956. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57957. /**
  57958. * Get an input block by its name
  57959. * @param predicate defines the predicate used to find the good candidate
  57960. * @returns the required input block or null if not found
  57961. */
  57962. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57963. /**
  57964. * Gets the list of input blocks attached to this material
  57965. * @returns an array of InputBlocks
  57966. */
  57967. getInputBlocks(): InputBlock[];
  57968. /**
  57969. * Adds a new optimizer to the list of optimizers
  57970. * @param optimizer defines the optimizers to add
  57971. * @returns the current material
  57972. */
  57973. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57974. /**
  57975. * Remove an optimizer from the list of optimizers
  57976. * @param optimizer defines the optimizers to remove
  57977. * @returns the current material
  57978. */
  57979. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57980. /**
  57981. * Add a new block to the list of output nodes
  57982. * @param node defines the node to add
  57983. * @returns the current material
  57984. */
  57985. addOutputNode(node: NodeMaterialBlock): this;
  57986. /**
  57987. * Remove a block from the list of root nodes
  57988. * @param node defines the node to remove
  57989. * @returns the current material
  57990. */
  57991. removeOutputNode(node: NodeMaterialBlock): this;
  57992. private _addVertexOutputNode;
  57993. private _removeVertexOutputNode;
  57994. private _addFragmentOutputNode;
  57995. private _removeFragmentOutputNode;
  57996. /**
  57997. * Specifies if the material will require alpha blending
  57998. * @returns a boolean specifying if alpha blending is needed
  57999. */
  58000. needAlphaBlending(): boolean;
  58001. /**
  58002. * Specifies if this material should be rendered in alpha test mode
  58003. * @returns a boolean specifying if an alpha test is needed.
  58004. */
  58005. needAlphaTesting(): boolean;
  58006. private _initializeBlock;
  58007. private _resetDualBlocks;
  58008. /**
  58009. * Remove a block from the current node material
  58010. * @param block defines the block to remove
  58011. */
  58012. removeBlock(block: NodeMaterialBlock): void;
  58013. /**
  58014. * Build the material and generates the inner effect
  58015. * @param verbose defines if the build should log activity
  58016. */
  58017. build(verbose?: boolean): void;
  58018. /**
  58019. * Runs an otpimization phase to try to improve the shader code
  58020. */
  58021. optimize(): void;
  58022. private _prepareDefinesForAttributes;
  58023. /**
  58024. * Get if the submesh is ready to be used and all its information available.
  58025. * Child classes can use it to update shaders
  58026. * @param mesh defines the mesh to check
  58027. * @param subMesh defines which submesh to check
  58028. * @param useInstances specifies that instances should be used
  58029. * @returns a boolean indicating that the submesh is ready or not
  58030. */
  58031. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58032. /**
  58033. * Get a string representing the shaders built by the current node graph
  58034. */
  58035. get compiledShaders(): string;
  58036. /**
  58037. * Binds the world matrix to the material
  58038. * @param world defines the world transformation matrix
  58039. */
  58040. bindOnlyWorldMatrix(world: Matrix): void;
  58041. /**
  58042. * Binds the submesh to this material by preparing the effect and shader to draw
  58043. * @param world defines the world transformation matrix
  58044. * @param mesh defines the mesh containing the submesh
  58045. * @param subMesh defines the submesh to bind the material to
  58046. */
  58047. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58048. /**
  58049. * Gets the active textures from the material
  58050. * @returns an array of textures
  58051. */
  58052. getActiveTextures(): BaseTexture[];
  58053. /**
  58054. * Gets the list of texture blocks
  58055. * @returns an array of texture blocks
  58056. */
  58057. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58058. /**
  58059. * Specifies if the material uses a texture
  58060. * @param texture defines the texture to check against the material
  58061. * @returns a boolean specifying if the material uses the texture
  58062. */
  58063. hasTexture(texture: BaseTexture): boolean;
  58064. /**
  58065. * Disposes the material
  58066. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58067. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58068. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58069. */
  58070. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58071. /** Creates the node editor window. */
  58072. private _createNodeEditor;
  58073. /**
  58074. * Launch the node material editor
  58075. * @param config Define the configuration of the editor
  58076. * @return a promise fulfilled when the node editor is visible
  58077. */
  58078. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58079. /**
  58080. * Clear the current material
  58081. */
  58082. clear(): void;
  58083. /**
  58084. * Clear the current material and set it to a default state
  58085. */
  58086. setToDefault(): void;
  58087. /**
  58088. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58089. * @param url defines the url to load from
  58090. * @returns a promise that will fullfil when the material is fully loaded
  58091. */
  58092. loadAsync(url: string): Promise<void>;
  58093. private _gatherBlocks;
  58094. /**
  58095. * Generate a string containing the code declaration required to create an equivalent of this material
  58096. * @returns a string
  58097. */
  58098. generateCode(): string;
  58099. /**
  58100. * Serializes this material in a JSON representation
  58101. * @returns the serialized material object
  58102. */
  58103. serialize(): any;
  58104. private _restoreConnections;
  58105. /**
  58106. * Clear the current graph and load a new one from a serialization object
  58107. * @param source defines the JSON representation of the material
  58108. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58109. */
  58110. loadFromSerialization(source: any, rootUrl?: string): void;
  58111. /**
  58112. * Creates a node material from parsed material data
  58113. * @param source defines the JSON representation of the material
  58114. * @param scene defines the hosting scene
  58115. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58116. * @returns a new node material
  58117. */
  58118. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58119. /**
  58120. * Creates a new node material set to default basic configuration
  58121. * @param name defines the name of the material
  58122. * @param scene defines the hosting scene
  58123. * @returns a new NodeMaterial
  58124. */
  58125. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58126. }
  58127. }
  58128. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58131. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58134. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58135. import { Effect } from "babylonjs/Materials/effect";
  58136. import { Mesh } from "babylonjs/Meshes/mesh";
  58137. import { Nullable } from "babylonjs/types";
  58138. import { Texture } from "babylonjs/Materials/Textures/texture";
  58139. import { Scene } from "babylonjs/scene";
  58140. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58141. /**
  58142. * Block used to read a texture from a sampler
  58143. */
  58144. export class TextureBlock extends NodeMaterialBlock {
  58145. private _defineName;
  58146. private _linearDefineName;
  58147. private _tempTextureRead;
  58148. private _samplerName;
  58149. private _transformedUVName;
  58150. private _textureTransformName;
  58151. private _textureInfoName;
  58152. private _mainUVName;
  58153. private _mainUVDefineName;
  58154. /**
  58155. * Gets or sets the texture associated with the node
  58156. */
  58157. texture: Nullable<Texture>;
  58158. /**
  58159. * Create a new TextureBlock
  58160. * @param name defines the block name
  58161. */
  58162. constructor(name: string);
  58163. /**
  58164. * Gets the current class name
  58165. * @returns the class name
  58166. */
  58167. getClassName(): string;
  58168. /**
  58169. * Gets the uv input component
  58170. */
  58171. get uv(): NodeMaterialConnectionPoint;
  58172. /**
  58173. * Gets the rgba output component
  58174. */
  58175. get rgba(): NodeMaterialConnectionPoint;
  58176. /**
  58177. * Gets the rgb output component
  58178. */
  58179. get rgb(): NodeMaterialConnectionPoint;
  58180. /**
  58181. * Gets the r output component
  58182. */
  58183. get r(): NodeMaterialConnectionPoint;
  58184. /**
  58185. * Gets the g output component
  58186. */
  58187. get g(): NodeMaterialConnectionPoint;
  58188. /**
  58189. * Gets the b output component
  58190. */
  58191. get b(): NodeMaterialConnectionPoint;
  58192. /**
  58193. * Gets the a output component
  58194. */
  58195. get a(): NodeMaterialConnectionPoint;
  58196. get target(): NodeMaterialBlockTargets;
  58197. autoConfigure(material: NodeMaterial): void;
  58198. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58199. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58200. private _getTextureBase;
  58201. isReady(): boolean;
  58202. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58203. private get _isMixed();
  58204. private _injectVertexCode;
  58205. private _writeTextureRead;
  58206. private _writeOutput;
  58207. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58208. protected _dumpPropertiesCode(): string;
  58209. serialize(): any;
  58210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58211. }
  58212. }
  58213. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  58214. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58216. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58217. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58218. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58219. import { Scene } from "babylonjs/scene";
  58220. /**
  58221. * Class used to store shared data between 2 NodeMaterialBuildState
  58222. */
  58223. export class NodeMaterialBuildStateSharedData {
  58224. /**
  58225. * Gets the list of emitted varyings
  58226. */
  58227. temps: string[];
  58228. /**
  58229. * Gets the list of emitted varyings
  58230. */
  58231. varyings: string[];
  58232. /**
  58233. * Gets the varying declaration string
  58234. */
  58235. varyingDeclaration: string;
  58236. /**
  58237. * Input blocks
  58238. */
  58239. inputBlocks: InputBlock[];
  58240. /**
  58241. * Input blocks
  58242. */
  58243. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58244. /**
  58245. * Bindable blocks (Blocks that need to set data to the effect)
  58246. */
  58247. bindableBlocks: NodeMaterialBlock[];
  58248. /**
  58249. * List of blocks that can provide a compilation fallback
  58250. */
  58251. blocksWithFallbacks: NodeMaterialBlock[];
  58252. /**
  58253. * List of blocks that can provide a define update
  58254. */
  58255. blocksWithDefines: NodeMaterialBlock[];
  58256. /**
  58257. * List of blocks that can provide a repeatable content
  58258. */
  58259. repeatableContentBlocks: NodeMaterialBlock[];
  58260. /**
  58261. * List of blocks that can provide a dynamic list of uniforms
  58262. */
  58263. dynamicUniformBlocks: NodeMaterialBlock[];
  58264. /**
  58265. * List of blocks that can block the isReady function for the material
  58266. */
  58267. blockingBlocks: NodeMaterialBlock[];
  58268. /**
  58269. * Gets the list of animated inputs
  58270. */
  58271. animatedInputs: InputBlock[];
  58272. /**
  58273. * Build Id used to avoid multiple recompilations
  58274. */
  58275. buildId: number;
  58276. /** List of emitted variables */
  58277. variableNames: {
  58278. [key: string]: number;
  58279. };
  58280. /** List of emitted defines */
  58281. defineNames: {
  58282. [key: string]: number;
  58283. };
  58284. /** Should emit comments? */
  58285. emitComments: boolean;
  58286. /** Emit build activity */
  58287. verbose: boolean;
  58288. /** Gets or sets the hosting scene */
  58289. scene: Scene;
  58290. /**
  58291. * Gets the compilation hints emitted at compilation time
  58292. */
  58293. hints: {
  58294. needWorldViewMatrix: boolean;
  58295. needWorldViewProjectionMatrix: boolean;
  58296. needAlphaBlending: boolean;
  58297. needAlphaTesting: boolean;
  58298. };
  58299. /**
  58300. * List of compilation checks
  58301. */
  58302. checks: {
  58303. emitVertex: boolean;
  58304. emitFragment: boolean;
  58305. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58306. };
  58307. /** Creates a new shared data */
  58308. constructor();
  58309. /**
  58310. * Emits console errors and exceptions if there is a failing check
  58311. */
  58312. emitErrors(): void;
  58313. }
  58314. }
  58315. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  58316. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58317. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58318. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  58319. /**
  58320. * Class used to store node based material build state
  58321. */
  58322. export class NodeMaterialBuildState {
  58323. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58324. supportUniformBuffers: boolean;
  58325. /**
  58326. * Gets the list of emitted attributes
  58327. */
  58328. attributes: string[];
  58329. /**
  58330. * Gets the list of emitted uniforms
  58331. */
  58332. uniforms: string[];
  58333. /**
  58334. * Gets the list of emitted constants
  58335. */
  58336. constants: string[];
  58337. /**
  58338. * Gets the list of emitted samplers
  58339. */
  58340. samplers: string[];
  58341. /**
  58342. * Gets the list of emitted functions
  58343. */
  58344. functions: {
  58345. [key: string]: string;
  58346. };
  58347. /**
  58348. * Gets the list of emitted extensions
  58349. */
  58350. extensions: {
  58351. [key: string]: string;
  58352. };
  58353. /**
  58354. * Gets the target of the compilation state
  58355. */
  58356. target: NodeMaterialBlockTargets;
  58357. /**
  58358. * Gets the list of emitted counters
  58359. */
  58360. counters: {
  58361. [key: string]: number;
  58362. };
  58363. /**
  58364. * Shared data between multiple NodeMaterialBuildState instances
  58365. */
  58366. sharedData: NodeMaterialBuildStateSharedData;
  58367. /** @hidden */
  58368. _vertexState: NodeMaterialBuildState;
  58369. /** @hidden */
  58370. _attributeDeclaration: string;
  58371. /** @hidden */
  58372. _uniformDeclaration: string;
  58373. /** @hidden */
  58374. _constantDeclaration: string;
  58375. /** @hidden */
  58376. _samplerDeclaration: string;
  58377. /** @hidden */
  58378. _varyingTransfer: string;
  58379. private _repeatableContentAnchorIndex;
  58380. /** @hidden */
  58381. _builtCompilationString: string;
  58382. /**
  58383. * Gets the emitted compilation strings
  58384. */
  58385. compilationString: string;
  58386. /**
  58387. * Finalize the compilation strings
  58388. * @param state defines the current compilation state
  58389. */
  58390. finalize(state: NodeMaterialBuildState): void;
  58391. /** @hidden */
  58392. get _repeatableContentAnchor(): string;
  58393. /** @hidden */
  58394. _getFreeVariableName(prefix: string): string;
  58395. /** @hidden */
  58396. _getFreeDefineName(prefix: string): string;
  58397. /** @hidden */
  58398. _excludeVariableName(name: string): void;
  58399. /** @hidden */
  58400. _emit2DSampler(name: string): void;
  58401. /** @hidden */
  58402. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58403. /** @hidden */
  58404. _emitExtension(name: string, extension: string): void;
  58405. /** @hidden */
  58406. _emitFunction(name: string, code: string, comments: string): void;
  58407. /** @hidden */
  58408. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58409. replaceStrings?: {
  58410. search: RegExp;
  58411. replace: string;
  58412. }[];
  58413. repeatKey?: string;
  58414. }): string;
  58415. /** @hidden */
  58416. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58417. repeatKey?: string;
  58418. removeAttributes?: boolean;
  58419. removeUniforms?: boolean;
  58420. removeVaryings?: boolean;
  58421. removeIfDef?: boolean;
  58422. replaceStrings?: {
  58423. search: RegExp;
  58424. replace: string;
  58425. }[];
  58426. }, storeKey?: string): void;
  58427. /** @hidden */
  58428. _registerTempVariable(name: string): boolean;
  58429. /** @hidden */
  58430. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58431. /** @hidden */
  58432. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58433. /** @hidden */
  58434. _emitFloat(value: number): string;
  58435. }
  58436. }
  58437. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  58438. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58440. import { Nullable } from "babylonjs/types";
  58441. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58442. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58443. import { Effect } from "babylonjs/Materials/effect";
  58444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58445. import { Mesh } from "babylonjs/Meshes/mesh";
  58446. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58447. import { Scene } from "babylonjs/scene";
  58448. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58449. /**
  58450. * Defines a block that can be used inside a node based material
  58451. */
  58452. export class NodeMaterialBlock {
  58453. private _buildId;
  58454. private _buildTarget;
  58455. private _target;
  58456. private _isFinalMerger;
  58457. private _isInput;
  58458. protected _isUnique: boolean;
  58459. /** @hidden */
  58460. _codeVariableName: string;
  58461. /** @hidden */
  58462. _inputs: NodeMaterialConnectionPoint[];
  58463. /** @hidden */
  58464. _outputs: NodeMaterialConnectionPoint[];
  58465. /** @hidden */
  58466. _preparationId: number;
  58467. /**
  58468. * Gets or sets the name of the block
  58469. */
  58470. name: string;
  58471. /**
  58472. * Gets or sets the unique id of the node
  58473. */
  58474. uniqueId: number;
  58475. /**
  58476. * Gets or sets the comments associated with this block
  58477. */
  58478. comments: string;
  58479. /**
  58480. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58481. */
  58482. get isUnique(): boolean;
  58483. /**
  58484. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58485. */
  58486. get isFinalMerger(): boolean;
  58487. /**
  58488. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58489. */
  58490. get isInput(): boolean;
  58491. /**
  58492. * Gets or sets the build Id
  58493. */
  58494. get buildId(): number;
  58495. set buildId(value: number);
  58496. /**
  58497. * Gets or sets the target of the block
  58498. */
  58499. get target(): NodeMaterialBlockTargets;
  58500. set target(value: NodeMaterialBlockTargets);
  58501. /**
  58502. * Gets the list of input points
  58503. */
  58504. get inputs(): NodeMaterialConnectionPoint[];
  58505. /** Gets the list of output points */
  58506. get outputs(): NodeMaterialConnectionPoint[];
  58507. /**
  58508. * Find an input by its name
  58509. * @param name defines the name of the input to look for
  58510. * @returns the input or null if not found
  58511. */
  58512. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58513. /**
  58514. * Find an output by its name
  58515. * @param name defines the name of the outputto look for
  58516. * @returns the output or null if not found
  58517. */
  58518. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58519. /**
  58520. * Creates a new NodeMaterialBlock
  58521. * @param name defines the block name
  58522. * @param target defines the target of that block (Vertex by default)
  58523. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58524. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58525. */
  58526. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58527. /**
  58528. * Initialize the block and prepare the context for build
  58529. * @param state defines the state that will be used for the build
  58530. */
  58531. initialize(state: NodeMaterialBuildState): void;
  58532. /**
  58533. * Bind data to effect. Will only be called for blocks with isBindable === true
  58534. * @param effect defines the effect to bind data to
  58535. * @param nodeMaterial defines the hosting NodeMaterial
  58536. * @param mesh defines the mesh that will be rendered
  58537. */
  58538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58539. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58540. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58541. protected _writeFloat(value: number): string;
  58542. /**
  58543. * Gets the current class name e.g. "NodeMaterialBlock"
  58544. * @returns the class name
  58545. */
  58546. getClassName(): string;
  58547. /**
  58548. * Register a new input. Must be called inside a block constructor
  58549. * @param name defines the connection point name
  58550. * @param type defines the connection point type
  58551. * @param isOptional defines a boolean indicating that this input can be omitted
  58552. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58553. * @returns the current block
  58554. */
  58555. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58556. /**
  58557. * Register a new output. Must be called inside a block constructor
  58558. * @param name defines the connection point name
  58559. * @param type defines the connection point type
  58560. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58561. * @returns the current block
  58562. */
  58563. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58564. /**
  58565. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58566. * @param forOutput defines an optional connection point to check compatibility with
  58567. * @returns the first available input or null
  58568. */
  58569. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58570. /**
  58571. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58572. * @param forBlock defines an optional block to check compatibility with
  58573. * @returns the first available input or null
  58574. */
  58575. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58576. /**
  58577. * Gets the sibling of the given output
  58578. * @param current defines the current output
  58579. * @returns the next output in the list or null
  58580. */
  58581. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58582. /**
  58583. * Connect current block with another block
  58584. * @param other defines the block to connect with
  58585. * @param options define the various options to help pick the right connections
  58586. * @returns the current block
  58587. */
  58588. connectTo(other: NodeMaterialBlock, options?: {
  58589. input?: string;
  58590. output?: string;
  58591. outputSwizzle?: string;
  58592. }): this | undefined;
  58593. protected _buildBlock(state: NodeMaterialBuildState): void;
  58594. /**
  58595. * Add uniforms, samplers and uniform buffers at compilation time
  58596. * @param state defines the state to update
  58597. * @param nodeMaterial defines the node material requesting the update
  58598. * @param defines defines the material defines to update
  58599. * @param uniformBuffers defines the list of uniform buffer names
  58600. */
  58601. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58602. /**
  58603. * Add potential fallbacks if shader compilation fails
  58604. * @param mesh defines the mesh to be rendered
  58605. * @param fallbacks defines the current prioritized list of fallbacks
  58606. */
  58607. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58608. /**
  58609. * Initialize defines for shader compilation
  58610. * @param mesh defines the mesh to be rendered
  58611. * @param nodeMaterial defines the node material requesting the update
  58612. * @param defines defines the material defines to update
  58613. * @param useInstances specifies that instances should be used
  58614. */
  58615. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58616. /**
  58617. * Update defines for shader compilation
  58618. * @param mesh defines the mesh to be rendered
  58619. * @param nodeMaterial defines the node material requesting the update
  58620. * @param defines defines the material defines to update
  58621. * @param useInstances specifies that instances should be used
  58622. */
  58623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58624. /**
  58625. * Lets the block try to connect some inputs automatically
  58626. * @param material defines the hosting NodeMaterial
  58627. */
  58628. autoConfigure(material: NodeMaterial): void;
  58629. /**
  58630. * Function called when a block is declared as repeatable content generator
  58631. * @param vertexShaderState defines the current compilation state for the vertex shader
  58632. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58633. * @param mesh defines the mesh to be rendered
  58634. * @param defines defines the material defines to update
  58635. */
  58636. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58637. /**
  58638. * Checks if the block is ready
  58639. * @param mesh defines the mesh to be rendered
  58640. * @param nodeMaterial defines the node material requesting the update
  58641. * @param defines defines the material defines to update
  58642. * @param useInstances specifies that instances should be used
  58643. * @returns true if the block is ready
  58644. */
  58645. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58646. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58647. private _processBuild;
  58648. /**
  58649. * Compile the current node and generate the shader code
  58650. * @param state defines the current compilation state (uniforms, samplers, current string)
  58651. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58652. * @returns true if already built
  58653. */
  58654. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58655. protected _inputRename(name: string): string;
  58656. protected _outputRename(name: string): string;
  58657. protected _dumpPropertiesCode(): string;
  58658. /** @hidden */
  58659. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58660. /** @hidden */
  58661. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58662. /**
  58663. * Clone the current block to a new identical block
  58664. * @param scene defines the hosting scene
  58665. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58666. * @returns a copy of the current block
  58667. */
  58668. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58669. /**
  58670. * Serializes this block in a JSON representation
  58671. * @returns the serialized block object
  58672. */
  58673. serialize(): any;
  58674. /** @hidden */
  58675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58676. /**
  58677. * Release resources
  58678. */
  58679. dispose(): void;
  58680. }
  58681. }
  58682. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  58683. /**
  58684. * Enum defining the type of animations supported by InputBlock
  58685. */
  58686. export enum AnimatedInputBlockTypes {
  58687. /** No animation */
  58688. None = 0,
  58689. /** Time based animation. Will only work for floats */
  58690. Time = 1
  58691. }
  58692. }
  58693. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  58694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58695. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58696. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58697. import { Nullable } from "babylonjs/types";
  58698. import { Effect } from "babylonjs/Materials/effect";
  58699. import { Matrix } from "babylonjs/Maths/math.vector";
  58700. import { Scene } from "babylonjs/scene";
  58701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58703. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58704. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58705. /**
  58706. * Block used to expose an input value
  58707. */
  58708. export class InputBlock extends NodeMaterialBlock {
  58709. private _mode;
  58710. private _associatedVariableName;
  58711. private _storedValue;
  58712. private _valueCallback;
  58713. private _type;
  58714. private _animationType;
  58715. /** Gets or set a value used to limit the range of float values */
  58716. min: number;
  58717. /** Gets or set a value used to limit the range of float values */
  58718. max: number;
  58719. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58720. matrixMode: number;
  58721. /** @hidden */
  58722. _systemValue: Nullable<NodeMaterialSystemValues>;
  58723. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58724. visibleInInspector: boolean;
  58725. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58726. isConstant: boolean;
  58727. /** Gets or sets the group to use to display this block in the Inspector */
  58728. groupInInspector: string;
  58729. /**
  58730. * Gets or sets the connection point type (default is float)
  58731. */
  58732. get type(): NodeMaterialBlockConnectionPointTypes;
  58733. /**
  58734. * Creates a new InputBlock
  58735. * @param name defines the block name
  58736. * @param target defines the target of that block (Vertex by default)
  58737. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58738. */
  58739. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58740. /**
  58741. * Gets the output component
  58742. */
  58743. get output(): NodeMaterialConnectionPoint;
  58744. /**
  58745. * Set the source of this connection point to a vertex attribute
  58746. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58747. * @returns the current connection point
  58748. */
  58749. setAsAttribute(attributeName?: string): InputBlock;
  58750. /**
  58751. * Set the source of this connection point to a system value
  58752. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58753. * @returns the current connection point
  58754. */
  58755. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58756. /**
  58757. * Gets or sets the value of that point.
  58758. * Please note that this value will be ignored if valueCallback is defined
  58759. */
  58760. get value(): any;
  58761. set value(value: any);
  58762. /**
  58763. * Gets or sets a callback used to get the value of that point.
  58764. * Please note that setting this value will force the connection point to ignore the value property
  58765. */
  58766. get valueCallback(): () => any;
  58767. set valueCallback(value: () => any);
  58768. /**
  58769. * Gets or sets the associated variable name in the shader
  58770. */
  58771. get associatedVariableName(): string;
  58772. set associatedVariableName(value: string);
  58773. /** Gets or sets the type of animation applied to the input */
  58774. get animationType(): AnimatedInputBlockTypes;
  58775. set animationType(value: AnimatedInputBlockTypes);
  58776. /**
  58777. * Gets a boolean indicating that this connection point not defined yet
  58778. */
  58779. get isUndefined(): boolean;
  58780. /**
  58781. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58782. * In this case the connection point name must be the name of the uniform to use.
  58783. * Can only be set on inputs
  58784. */
  58785. get isUniform(): boolean;
  58786. set isUniform(value: boolean);
  58787. /**
  58788. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58789. * In this case the connection point name must be the name of the attribute to use
  58790. * Can only be set on inputs
  58791. */
  58792. get isAttribute(): boolean;
  58793. set isAttribute(value: boolean);
  58794. /**
  58795. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58796. * Can only be set on exit points
  58797. */
  58798. get isVarying(): boolean;
  58799. set isVarying(value: boolean);
  58800. /**
  58801. * Gets a boolean indicating that the current connection point is a system value
  58802. */
  58803. get isSystemValue(): boolean;
  58804. /**
  58805. * Gets or sets the current well known value or null if not defined as a system value
  58806. */
  58807. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58808. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58809. /**
  58810. * Gets the current class name
  58811. * @returns the class name
  58812. */
  58813. getClassName(): string;
  58814. /**
  58815. * Animate the input if animationType !== None
  58816. * @param scene defines the rendering scene
  58817. */
  58818. animate(scene: Scene): void;
  58819. private _emitDefine;
  58820. initialize(state: NodeMaterialBuildState): void;
  58821. /**
  58822. * Set the input block to its default value (based on its type)
  58823. */
  58824. setDefaultValue(): void;
  58825. private _emitConstant;
  58826. private _emit;
  58827. /** @hidden */
  58828. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58829. /** @hidden */
  58830. _transmit(effect: Effect, scene: Scene): void;
  58831. protected _buildBlock(state: NodeMaterialBuildState): void;
  58832. protected _dumpPropertiesCode(): string;
  58833. serialize(): any;
  58834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58835. }
  58836. }
  58837. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  58838. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58839. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58840. import { Nullable } from "babylonjs/types";
  58841. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58842. import { Observable } from "babylonjs/Misc/observable";
  58843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58844. /**
  58845. * Enum used to define the compatibility state between two connection points
  58846. */
  58847. export enum NodeMaterialConnectionPointCompatibilityStates {
  58848. /** Points are compatibles */
  58849. Compatible = 0,
  58850. /** Points are incompatible because of their types */
  58851. TypeIncompatible = 1,
  58852. /** Points are incompatible because of their targets (vertex vs fragment) */
  58853. TargetIncompatible = 2
  58854. }
  58855. /**
  58856. * Defines the direction of a connection point
  58857. */
  58858. export enum NodeMaterialConnectionPointDirection {
  58859. /** Input */
  58860. Input = 0,
  58861. /** Output */
  58862. Output = 1
  58863. }
  58864. /**
  58865. * Defines a connection point for a block
  58866. */
  58867. export class NodeMaterialConnectionPoint {
  58868. /** @hidden */
  58869. _ownerBlock: NodeMaterialBlock;
  58870. /** @hidden */
  58871. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58872. private _endpoints;
  58873. private _associatedVariableName;
  58874. private _direction;
  58875. /** @hidden */
  58876. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58877. /** @hidden */
  58878. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58879. private _type;
  58880. /** @hidden */
  58881. _enforceAssociatedVariableName: boolean;
  58882. /** Gets the direction of the point */
  58883. get direction(): NodeMaterialConnectionPointDirection;
  58884. /**
  58885. * Gets or sets the additional types supported by this connection point
  58886. */
  58887. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58888. /**
  58889. * Gets or sets the additional types excluded by this connection point
  58890. */
  58891. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58892. /**
  58893. * Observable triggered when this point is connected
  58894. */
  58895. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58896. /**
  58897. * Gets or sets the associated variable name in the shader
  58898. */
  58899. get associatedVariableName(): string;
  58900. set associatedVariableName(value: string);
  58901. /**
  58902. * Gets or sets the connection point type (default is float)
  58903. */
  58904. get type(): NodeMaterialBlockConnectionPointTypes;
  58905. set type(value: NodeMaterialBlockConnectionPointTypes);
  58906. /**
  58907. * Gets or sets the connection point name
  58908. */
  58909. name: string;
  58910. /**
  58911. * Gets or sets a boolean indicating that this connection point can be omitted
  58912. */
  58913. isOptional: boolean;
  58914. /**
  58915. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58916. */
  58917. define: string;
  58918. /** @hidden */
  58919. _prioritizeVertex: boolean;
  58920. private _target;
  58921. /** Gets or sets the target of that connection point */
  58922. get target(): NodeMaterialBlockTargets;
  58923. set target(value: NodeMaterialBlockTargets);
  58924. /**
  58925. * Gets a boolean indicating that the current point is connected
  58926. */
  58927. get isConnected(): boolean;
  58928. /**
  58929. * Gets a boolean indicating that the current point is connected to an input block
  58930. */
  58931. get isConnectedToInputBlock(): boolean;
  58932. /**
  58933. * Gets a the connected input block (if any)
  58934. */
  58935. get connectInputBlock(): Nullable<InputBlock>;
  58936. /** Get the other side of the connection (if any) */
  58937. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58938. /** Get the block that owns this connection point */
  58939. get ownerBlock(): NodeMaterialBlock;
  58940. /** Get the block connected on the other side of this connection (if any) */
  58941. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58942. /** Get the block connected on the endpoints of this connection (if any) */
  58943. get connectedBlocks(): Array<NodeMaterialBlock>;
  58944. /** Gets the list of connected endpoints */
  58945. get endpoints(): NodeMaterialConnectionPoint[];
  58946. /** Gets a boolean indicating if that output point is connected to at least one input */
  58947. get hasEndpoints(): boolean;
  58948. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58949. get isConnectedInVertexShader(): boolean;
  58950. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58951. get isConnectedInFragmentShader(): boolean;
  58952. /**
  58953. * Creates a new connection point
  58954. * @param name defines the connection point name
  58955. * @param ownerBlock defines the block hosting this connection point
  58956. * @param direction defines the direction of the connection point
  58957. */
  58958. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58959. /**
  58960. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58961. * @returns the class name
  58962. */
  58963. getClassName(): string;
  58964. /**
  58965. * Gets a boolean indicating if the current point can be connected to another point
  58966. * @param connectionPoint defines the other connection point
  58967. * @returns a boolean
  58968. */
  58969. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58970. /**
  58971. * Gets a number indicating if the current point can be connected to another point
  58972. * @param connectionPoint defines the other connection point
  58973. * @returns a number defining the compatibility state
  58974. */
  58975. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58976. /**
  58977. * Connect this point to another connection point
  58978. * @param connectionPoint defines the other connection point
  58979. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58980. * @returns the current connection point
  58981. */
  58982. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Disconnect this point from one of his endpoint
  58985. * @param endpoint defines the other connection point
  58986. * @returns the current connection point
  58987. */
  58988. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58989. /**
  58990. * Serializes this point in a JSON representation
  58991. * @returns the serialized point object
  58992. */
  58993. serialize(): any;
  58994. /**
  58995. * Release resources
  58996. */
  58997. dispose(): void;
  58998. }
  58999. }
  59000. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  59001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59004. import { Mesh } from "babylonjs/Meshes/mesh";
  59005. import { Effect } from "babylonjs/Materials/effect";
  59006. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59007. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59008. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59009. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59010. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59011. /**
  59012. * Block used to add support for vertex skinning (bones)
  59013. */
  59014. export class BonesBlock extends NodeMaterialBlock {
  59015. /**
  59016. * Creates a new BonesBlock
  59017. * @param name defines the block name
  59018. */
  59019. constructor(name: string);
  59020. /**
  59021. * Initialize the block and prepare the context for build
  59022. * @param state defines the state that will be used for the build
  59023. */
  59024. initialize(state: NodeMaterialBuildState): void;
  59025. /**
  59026. * Gets the current class name
  59027. * @returns the class name
  59028. */
  59029. getClassName(): string;
  59030. /**
  59031. * Gets the matrix indices input component
  59032. */
  59033. get matricesIndices(): NodeMaterialConnectionPoint;
  59034. /**
  59035. * Gets the matrix weights input component
  59036. */
  59037. get matricesWeights(): NodeMaterialConnectionPoint;
  59038. /**
  59039. * Gets the extra matrix indices input component
  59040. */
  59041. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59042. /**
  59043. * Gets the extra matrix weights input component
  59044. */
  59045. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59046. /**
  59047. * Gets the world input component
  59048. */
  59049. get world(): NodeMaterialConnectionPoint;
  59050. /**
  59051. * Gets the output component
  59052. */
  59053. get output(): NodeMaterialConnectionPoint;
  59054. autoConfigure(material: NodeMaterial): void;
  59055. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59056. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59057. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59058. protected _buildBlock(state: NodeMaterialBuildState): this;
  59059. }
  59060. }
  59061. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59062. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59066. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59067. /**
  59068. * Block used to add support for instances
  59069. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59070. */
  59071. export class InstancesBlock extends NodeMaterialBlock {
  59072. /**
  59073. * Creates a new InstancesBlock
  59074. * @param name defines the block name
  59075. */
  59076. constructor(name: string);
  59077. /**
  59078. * Gets the current class name
  59079. * @returns the class name
  59080. */
  59081. getClassName(): string;
  59082. /**
  59083. * Gets the first world row input component
  59084. */
  59085. get world0(): NodeMaterialConnectionPoint;
  59086. /**
  59087. * Gets the second world row input component
  59088. */
  59089. get world1(): NodeMaterialConnectionPoint;
  59090. /**
  59091. * Gets the third world row input component
  59092. */
  59093. get world2(): NodeMaterialConnectionPoint;
  59094. /**
  59095. * Gets the forth world row input component
  59096. */
  59097. get world3(): NodeMaterialConnectionPoint;
  59098. /**
  59099. * Gets the world input component
  59100. */
  59101. get world(): NodeMaterialConnectionPoint;
  59102. /**
  59103. * Gets the output component
  59104. */
  59105. get output(): NodeMaterialConnectionPoint;
  59106. autoConfigure(material: NodeMaterial): void;
  59107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59108. protected _buildBlock(state: NodeMaterialBuildState): this;
  59109. }
  59110. }
  59111. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59116. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59117. import { Effect } from "babylonjs/Materials/effect";
  59118. import { Mesh } from "babylonjs/Meshes/mesh";
  59119. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59121. /**
  59122. * Block used to add morph targets support to vertex shader
  59123. */
  59124. export class MorphTargetsBlock extends NodeMaterialBlock {
  59125. private _repeatableContentAnchor;
  59126. private _repeatebleContentGenerated;
  59127. /**
  59128. * Create a new MorphTargetsBlock
  59129. * @param name defines the block name
  59130. */
  59131. constructor(name: string);
  59132. /**
  59133. * Gets the current class name
  59134. * @returns the class name
  59135. */
  59136. getClassName(): string;
  59137. /**
  59138. * Gets the position input component
  59139. */
  59140. get position(): NodeMaterialConnectionPoint;
  59141. /**
  59142. * Gets the normal input component
  59143. */
  59144. get normal(): NodeMaterialConnectionPoint;
  59145. /**
  59146. * Gets the tangent input component
  59147. */
  59148. get tangent(): NodeMaterialConnectionPoint;
  59149. /**
  59150. * Gets the tangent input component
  59151. */
  59152. get uv(): NodeMaterialConnectionPoint;
  59153. /**
  59154. * Gets the position output component
  59155. */
  59156. get positionOutput(): NodeMaterialConnectionPoint;
  59157. /**
  59158. * Gets the normal output component
  59159. */
  59160. get normalOutput(): NodeMaterialConnectionPoint;
  59161. /**
  59162. * Gets the tangent output component
  59163. */
  59164. get tangentOutput(): NodeMaterialConnectionPoint;
  59165. /**
  59166. * Gets the tangent output component
  59167. */
  59168. get uvOutput(): NodeMaterialConnectionPoint;
  59169. initialize(state: NodeMaterialBuildState): void;
  59170. autoConfigure(material: NodeMaterial): void;
  59171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59172. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59173. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59174. protected _buildBlock(state: NodeMaterialBuildState): this;
  59175. }
  59176. }
  59177. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59181. import { Nullable } from "babylonjs/types";
  59182. import { Scene } from "babylonjs/scene";
  59183. import { Effect } from "babylonjs/Materials/effect";
  59184. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59185. import { Mesh } from "babylonjs/Meshes/mesh";
  59186. import { Light } from "babylonjs/Lights/light";
  59187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59188. /**
  59189. * Block used to get data information from a light
  59190. */
  59191. export class LightInformationBlock extends NodeMaterialBlock {
  59192. private _lightDataUniformName;
  59193. private _lightColorUniformName;
  59194. private _lightTypeDefineName;
  59195. /**
  59196. * Gets or sets the light associated with this block
  59197. */
  59198. light: Nullable<Light>;
  59199. /**
  59200. * Creates a new LightInformationBlock
  59201. * @param name defines the block name
  59202. */
  59203. constructor(name: string);
  59204. /**
  59205. * Gets the current class name
  59206. * @returns the class name
  59207. */
  59208. getClassName(): string;
  59209. /**
  59210. * Gets the world position input component
  59211. */
  59212. get worldPosition(): NodeMaterialConnectionPoint;
  59213. /**
  59214. * Gets the direction output component
  59215. */
  59216. get direction(): NodeMaterialConnectionPoint;
  59217. /**
  59218. * Gets the direction output component
  59219. */
  59220. get color(): NodeMaterialConnectionPoint;
  59221. /**
  59222. * Gets the direction output component
  59223. */
  59224. get intensity(): NodeMaterialConnectionPoint;
  59225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59227. protected _buildBlock(state: NodeMaterialBuildState): this;
  59228. serialize(): any;
  59229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59230. }
  59231. }
  59232. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  59233. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  59234. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  59235. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  59236. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  59237. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  59238. }
  59239. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  59240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59244. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59245. import { Effect } from "babylonjs/Materials/effect";
  59246. import { Mesh } from "babylonjs/Meshes/mesh";
  59247. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59248. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59249. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59250. /**
  59251. * Block used to add image processing support to fragment shader
  59252. */
  59253. export class ImageProcessingBlock extends NodeMaterialBlock {
  59254. /**
  59255. * Create a new ImageProcessingBlock
  59256. * @param name defines the block name
  59257. */
  59258. constructor(name: string);
  59259. /**
  59260. * Gets the current class name
  59261. * @returns the class name
  59262. */
  59263. getClassName(): string;
  59264. /**
  59265. * Gets the color input component
  59266. */
  59267. get color(): NodeMaterialConnectionPoint;
  59268. /**
  59269. * Gets the output component
  59270. */
  59271. get output(): NodeMaterialConnectionPoint;
  59272. /**
  59273. * Initialize the block and prepare the context for build
  59274. * @param state defines the state that will be used for the build
  59275. */
  59276. initialize(state: NodeMaterialBuildState): void;
  59277. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59279. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59280. protected _buildBlock(state: NodeMaterialBuildState): this;
  59281. }
  59282. }
  59283. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  59284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59287. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59289. import { Effect } from "babylonjs/Materials/effect";
  59290. import { Mesh } from "babylonjs/Meshes/mesh";
  59291. import { Scene } from "babylonjs/scene";
  59292. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59293. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59294. /**
  59295. * Block used to pertub normals based on a normal map
  59296. */
  59297. export class PerturbNormalBlock extends NodeMaterialBlock {
  59298. private _tangentSpaceParameterName;
  59299. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59300. invertX: boolean;
  59301. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59302. invertY: boolean;
  59303. /**
  59304. * Create a new PerturbNormalBlock
  59305. * @param name defines the block name
  59306. */
  59307. constructor(name: string);
  59308. /**
  59309. * Gets the current class name
  59310. * @returns the class name
  59311. */
  59312. getClassName(): string;
  59313. /**
  59314. * Gets the world position input component
  59315. */
  59316. get worldPosition(): NodeMaterialConnectionPoint;
  59317. /**
  59318. * Gets the world normal input component
  59319. */
  59320. get worldNormal(): NodeMaterialConnectionPoint;
  59321. /**
  59322. * Gets the uv input component
  59323. */
  59324. get uv(): NodeMaterialConnectionPoint;
  59325. /**
  59326. * Gets the normal map color input component
  59327. */
  59328. get normalMapColor(): NodeMaterialConnectionPoint;
  59329. /**
  59330. * Gets the strength input component
  59331. */
  59332. get strength(): NodeMaterialConnectionPoint;
  59333. /**
  59334. * Gets the output component
  59335. */
  59336. get output(): NodeMaterialConnectionPoint;
  59337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59339. autoConfigure(material: NodeMaterial): void;
  59340. protected _buildBlock(state: NodeMaterialBuildState): this;
  59341. protected _dumpPropertiesCode(): string;
  59342. serialize(): any;
  59343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59344. }
  59345. }
  59346. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  59347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59350. /**
  59351. * Block used to discard a pixel if a value is smaller than a cutoff
  59352. */
  59353. export class DiscardBlock extends NodeMaterialBlock {
  59354. /**
  59355. * Create a new DiscardBlock
  59356. * @param name defines the block name
  59357. */
  59358. constructor(name: string);
  59359. /**
  59360. * Gets the current class name
  59361. * @returns the class name
  59362. */
  59363. getClassName(): string;
  59364. /**
  59365. * Gets the color input component
  59366. */
  59367. get value(): NodeMaterialConnectionPoint;
  59368. /**
  59369. * Gets the cutoff input component
  59370. */
  59371. get cutoff(): NodeMaterialConnectionPoint;
  59372. protected _buildBlock(state: NodeMaterialBuildState): this;
  59373. }
  59374. }
  59375. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  59376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59379. /**
  59380. * Block used to test if the fragment shader is front facing
  59381. */
  59382. export class FrontFacingBlock extends NodeMaterialBlock {
  59383. /**
  59384. * Creates a new FrontFacingBlock
  59385. * @param name defines the block name
  59386. */
  59387. constructor(name: string);
  59388. /**
  59389. * Gets the current class name
  59390. * @returns the class name
  59391. */
  59392. getClassName(): string;
  59393. /**
  59394. * Gets the output component
  59395. */
  59396. get output(): NodeMaterialConnectionPoint;
  59397. protected _buildBlock(state: NodeMaterialBuildState): this;
  59398. }
  59399. }
  59400. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  59401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59404. /**
  59405. * Block used to get the derivative value on x and y of a given input
  59406. */
  59407. export class DerivativeBlock extends NodeMaterialBlock {
  59408. /**
  59409. * Create a new DerivativeBlock
  59410. * @param name defines the block name
  59411. */
  59412. constructor(name: string);
  59413. /**
  59414. * Gets the current class name
  59415. * @returns the class name
  59416. */
  59417. getClassName(): string;
  59418. /**
  59419. * Gets the input component
  59420. */
  59421. get input(): NodeMaterialConnectionPoint;
  59422. /**
  59423. * Gets the derivative output on x
  59424. */
  59425. get dx(): NodeMaterialConnectionPoint;
  59426. /**
  59427. * Gets the derivative output on y
  59428. */
  59429. get dy(): NodeMaterialConnectionPoint;
  59430. protected _buildBlock(state: NodeMaterialBuildState): this;
  59431. }
  59432. }
  59433. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  59434. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  59435. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  59436. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  59437. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  59438. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  59439. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  59440. }
  59441. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  59442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59444. import { Mesh } from "babylonjs/Meshes/mesh";
  59445. import { Effect } from "babylonjs/Materials/effect";
  59446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59448. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59449. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59450. /**
  59451. * Block used to add support for scene fog
  59452. */
  59453. export class FogBlock extends NodeMaterialBlock {
  59454. private _fogDistanceName;
  59455. private _fogParameters;
  59456. /**
  59457. * Create a new FogBlock
  59458. * @param name defines the block name
  59459. */
  59460. constructor(name: string);
  59461. /**
  59462. * Gets the current class name
  59463. * @returns the class name
  59464. */
  59465. getClassName(): string;
  59466. /**
  59467. * Gets the world position input component
  59468. */
  59469. get worldPosition(): NodeMaterialConnectionPoint;
  59470. /**
  59471. * Gets the view input component
  59472. */
  59473. get view(): NodeMaterialConnectionPoint;
  59474. /**
  59475. * Gets the color input component
  59476. */
  59477. get input(): NodeMaterialConnectionPoint;
  59478. /**
  59479. * Gets the fog color input component
  59480. */
  59481. get fogColor(): NodeMaterialConnectionPoint;
  59482. /**
  59483. * Gets the output component
  59484. */
  59485. get output(): NodeMaterialConnectionPoint;
  59486. autoConfigure(material: NodeMaterial): void;
  59487. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59489. protected _buildBlock(state: NodeMaterialBuildState): this;
  59490. }
  59491. }
  59492. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  59493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59494. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59495. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59497. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59498. import { Effect } from "babylonjs/Materials/effect";
  59499. import { Mesh } from "babylonjs/Meshes/mesh";
  59500. import { Light } from "babylonjs/Lights/light";
  59501. import { Nullable } from "babylonjs/types";
  59502. import { Scene } from "babylonjs/scene";
  59503. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59504. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59505. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59506. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59507. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59508. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59509. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59510. /**
  59511. * Block used to add light in the fragment shader
  59512. */
  59513. export class LightBlock extends NodeMaterialBlock {
  59514. private _lightId;
  59515. /**
  59516. * Gets or sets the light associated with this block
  59517. */
  59518. light: Nullable<Light>;
  59519. /**
  59520. * Create a new LightBlock
  59521. * @param name defines the block name
  59522. */
  59523. constructor(name: string);
  59524. /**
  59525. * Gets the current class name
  59526. * @returns the class name
  59527. */
  59528. getClassName(): string;
  59529. /**
  59530. * Gets the world position input component
  59531. */
  59532. get worldPosition(): NodeMaterialConnectionPoint;
  59533. /**
  59534. * Gets the world normal input component
  59535. */
  59536. get worldNormal(): NodeMaterialConnectionPoint;
  59537. /**
  59538. * Gets the camera (or eye) position component
  59539. */
  59540. get cameraPosition(): NodeMaterialConnectionPoint;
  59541. /**
  59542. * Gets the glossiness component
  59543. */
  59544. get glossiness(): NodeMaterialConnectionPoint;
  59545. /**
  59546. * Gets the glossinness power component
  59547. */
  59548. get glossPower(): NodeMaterialConnectionPoint;
  59549. /**
  59550. * Gets the diffuse color component
  59551. */
  59552. get diffuseColor(): NodeMaterialConnectionPoint;
  59553. /**
  59554. * Gets the specular color component
  59555. */
  59556. get specularColor(): NodeMaterialConnectionPoint;
  59557. /**
  59558. * Gets the diffuse output component
  59559. */
  59560. get diffuseOutput(): NodeMaterialConnectionPoint;
  59561. /**
  59562. * Gets the specular output component
  59563. */
  59564. get specularOutput(): NodeMaterialConnectionPoint;
  59565. /**
  59566. * Gets the shadow output component
  59567. */
  59568. get shadow(): NodeMaterialConnectionPoint;
  59569. autoConfigure(material: NodeMaterial): void;
  59570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59571. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59573. private _injectVertexCode;
  59574. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59575. serialize(): any;
  59576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59577. }
  59578. }
  59579. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  59580. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  59581. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  59582. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59583. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59584. }
  59585. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  59586. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59587. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59588. }
  59589. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  59590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59593. /**
  59594. * Block used to multiply 2 values
  59595. */
  59596. export class MultiplyBlock extends NodeMaterialBlock {
  59597. /**
  59598. * Creates a new MultiplyBlock
  59599. * @param name defines the block name
  59600. */
  59601. constructor(name: string);
  59602. /**
  59603. * Gets the current class name
  59604. * @returns the class name
  59605. */
  59606. getClassName(): string;
  59607. /**
  59608. * Gets the left operand input component
  59609. */
  59610. get left(): NodeMaterialConnectionPoint;
  59611. /**
  59612. * Gets the right operand input component
  59613. */
  59614. get right(): NodeMaterialConnectionPoint;
  59615. /**
  59616. * Gets the output component
  59617. */
  59618. get output(): NodeMaterialConnectionPoint;
  59619. protected _buildBlock(state: NodeMaterialBuildState): this;
  59620. }
  59621. }
  59622. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  59623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59626. /**
  59627. * Block used to add 2 vectors
  59628. */
  59629. export class AddBlock extends NodeMaterialBlock {
  59630. /**
  59631. * Creates a new AddBlock
  59632. * @param name defines the block name
  59633. */
  59634. constructor(name: string);
  59635. /**
  59636. * Gets the current class name
  59637. * @returns the class name
  59638. */
  59639. getClassName(): string;
  59640. /**
  59641. * Gets the left operand input component
  59642. */
  59643. get left(): NodeMaterialConnectionPoint;
  59644. /**
  59645. * Gets the right operand input component
  59646. */
  59647. get right(): NodeMaterialConnectionPoint;
  59648. /**
  59649. * Gets the output component
  59650. */
  59651. get output(): NodeMaterialConnectionPoint;
  59652. protected _buildBlock(state: NodeMaterialBuildState): this;
  59653. }
  59654. }
  59655. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  59656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59659. /**
  59660. * Block used to scale a vector by a float
  59661. */
  59662. export class ScaleBlock extends NodeMaterialBlock {
  59663. /**
  59664. * Creates a new ScaleBlock
  59665. * @param name defines the block name
  59666. */
  59667. constructor(name: string);
  59668. /**
  59669. * Gets the current class name
  59670. * @returns the class name
  59671. */
  59672. getClassName(): string;
  59673. /**
  59674. * Gets the input component
  59675. */
  59676. get input(): NodeMaterialConnectionPoint;
  59677. /**
  59678. * Gets the factor input component
  59679. */
  59680. get factor(): NodeMaterialConnectionPoint;
  59681. /**
  59682. * Gets the output component
  59683. */
  59684. get output(): NodeMaterialConnectionPoint;
  59685. protected _buildBlock(state: NodeMaterialBuildState): this;
  59686. }
  59687. }
  59688. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  59689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59692. import { Scene } from "babylonjs/scene";
  59693. /**
  59694. * Block used to clamp a float
  59695. */
  59696. export class ClampBlock extends NodeMaterialBlock {
  59697. /** Gets or sets the minimum range */
  59698. minimum: number;
  59699. /** Gets or sets the maximum range */
  59700. maximum: number;
  59701. /**
  59702. * Creates a new ClampBlock
  59703. * @param name defines the block name
  59704. */
  59705. constructor(name: string);
  59706. /**
  59707. * Gets the current class name
  59708. * @returns the class name
  59709. */
  59710. getClassName(): string;
  59711. /**
  59712. * Gets the value input component
  59713. */
  59714. get value(): NodeMaterialConnectionPoint;
  59715. /**
  59716. * Gets the output component
  59717. */
  59718. get output(): NodeMaterialConnectionPoint;
  59719. protected _buildBlock(state: NodeMaterialBuildState): this;
  59720. protected _dumpPropertiesCode(): string;
  59721. serialize(): any;
  59722. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59723. }
  59724. }
  59725. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  59726. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59728. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59729. /**
  59730. * Block used to apply a cross product between 2 vectors
  59731. */
  59732. export class CrossBlock extends NodeMaterialBlock {
  59733. /**
  59734. * Creates a new CrossBlock
  59735. * @param name defines the block name
  59736. */
  59737. constructor(name: string);
  59738. /**
  59739. * Gets the current class name
  59740. * @returns the class name
  59741. */
  59742. getClassName(): string;
  59743. /**
  59744. * Gets the left operand input component
  59745. */
  59746. get left(): NodeMaterialConnectionPoint;
  59747. /**
  59748. * Gets the right operand input component
  59749. */
  59750. get right(): NodeMaterialConnectionPoint;
  59751. /**
  59752. * Gets the output component
  59753. */
  59754. get output(): NodeMaterialConnectionPoint;
  59755. protected _buildBlock(state: NodeMaterialBuildState): this;
  59756. }
  59757. }
  59758. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  59759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59762. /**
  59763. * Block used to apply a dot product between 2 vectors
  59764. */
  59765. export class DotBlock extends NodeMaterialBlock {
  59766. /**
  59767. * Creates a new DotBlock
  59768. * @param name defines the block name
  59769. */
  59770. constructor(name: string);
  59771. /**
  59772. * Gets the current class name
  59773. * @returns the class name
  59774. */
  59775. getClassName(): string;
  59776. /**
  59777. * Gets the left operand input component
  59778. */
  59779. get left(): NodeMaterialConnectionPoint;
  59780. /**
  59781. * Gets the right operand input component
  59782. */
  59783. get right(): NodeMaterialConnectionPoint;
  59784. /**
  59785. * Gets the output component
  59786. */
  59787. get output(): NodeMaterialConnectionPoint;
  59788. protected _buildBlock(state: NodeMaterialBuildState): this;
  59789. }
  59790. }
  59791. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  59792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59793. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59795. import { Vector2 } from "babylonjs/Maths/math.vector";
  59796. import { Scene } from "babylonjs/scene";
  59797. /**
  59798. * Block used to remap a float from a range to a new one
  59799. */
  59800. export class RemapBlock extends NodeMaterialBlock {
  59801. /**
  59802. * Gets or sets the source range
  59803. */
  59804. sourceRange: Vector2;
  59805. /**
  59806. * Gets or sets the target range
  59807. */
  59808. targetRange: Vector2;
  59809. /**
  59810. * Creates a new RemapBlock
  59811. * @param name defines the block name
  59812. */
  59813. constructor(name: string);
  59814. /**
  59815. * Gets the current class name
  59816. * @returns the class name
  59817. */
  59818. getClassName(): string;
  59819. /**
  59820. * Gets the input component
  59821. */
  59822. get input(): NodeMaterialConnectionPoint;
  59823. /**
  59824. * Gets the source min input component
  59825. */
  59826. get sourceMin(): NodeMaterialConnectionPoint;
  59827. /**
  59828. * Gets the source max input component
  59829. */
  59830. get sourceMax(): NodeMaterialConnectionPoint;
  59831. /**
  59832. * Gets the target min input component
  59833. */
  59834. get targetMin(): NodeMaterialConnectionPoint;
  59835. /**
  59836. * Gets the target max input component
  59837. */
  59838. get targetMax(): NodeMaterialConnectionPoint;
  59839. /**
  59840. * Gets the output component
  59841. */
  59842. get output(): NodeMaterialConnectionPoint;
  59843. protected _buildBlock(state: NodeMaterialBuildState): this;
  59844. protected _dumpPropertiesCode(): string;
  59845. serialize(): any;
  59846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59847. }
  59848. }
  59849. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  59850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59853. /**
  59854. * Block used to normalize a vector
  59855. */
  59856. export class NormalizeBlock extends NodeMaterialBlock {
  59857. /**
  59858. * Creates a new NormalizeBlock
  59859. * @param name defines the block name
  59860. */
  59861. constructor(name: string);
  59862. /**
  59863. * Gets the current class name
  59864. * @returns the class name
  59865. */
  59866. getClassName(): string;
  59867. /**
  59868. * Gets the input component
  59869. */
  59870. get input(): NodeMaterialConnectionPoint;
  59871. /**
  59872. * Gets the output component
  59873. */
  59874. get output(): NodeMaterialConnectionPoint;
  59875. protected _buildBlock(state: NodeMaterialBuildState): this;
  59876. }
  59877. }
  59878. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  59879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59882. import { Scene } from "babylonjs/scene";
  59883. /**
  59884. * Operations supported by the Trigonometry block
  59885. */
  59886. export enum TrigonometryBlockOperations {
  59887. /** Cos */
  59888. Cos = 0,
  59889. /** Sin */
  59890. Sin = 1,
  59891. /** Abs */
  59892. Abs = 2,
  59893. /** Exp */
  59894. Exp = 3,
  59895. /** Exp2 */
  59896. Exp2 = 4,
  59897. /** Round */
  59898. Round = 5,
  59899. /** Floor */
  59900. Floor = 6,
  59901. /** Ceiling */
  59902. Ceiling = 7,
  59903. /** Square root */
  59904. Sqrt = 8,
  59905. /** Log */
  59906. Log = 9,
  59907. /** Tangent */
  59908. Tan = 10,
  59909. /** Arc tangent */
  59910. ArcTan = 11,
  59911. /** Arc cosinus */
  59912. ArcCos = 12,
  59913. /** Arc sinus */
  59914. ArcSin = 13,
  59915. /** Fraction */
  59916. Fract = 14,
  59917. /** Sign */
  59918. Sign = 15,
  59919. /** To radians (from degrees) */
  59920. Radians = 16,
  59921. /** To degrees (from radians) */
  59922. Degrees = 17
  59923. }
  59924. /**
  59925. * Block used to apply trigonometry operation to floats
  59926. */
  59927. export class TrigonometryBlock extends NodeMaterialBlock {
  59928. /**
  59929. * Gets or sets the operation applied by the block
  59930. */
  59931. operation: TrigonometryBlockOperations;
  59932. /**
  59933. * Creates a new TrigonometryBlock
  59934. * @param name defines the block name
  59935. */
  59936. constructor(name: string);
  59937. /**
  59938. * Gets the current class name
  59939. * @returns the class name
  59940. */
  59941. getClassName(): string;
  59942. /**
  59943. * Gets the input component
  59944. */
  59945. get input(): NodeMaterialConnectionPoint;
  59946. /**
  59947. * Gets the output component
  59948. */
  59949. get output(): NodeMaterialConnectionPoint;
  59950. protected _buildBlock(state: NodeMaterialBuildState): this;
  59951. serialize(): any;
  59952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59953. protected _dumpPropertiesCode(): string;
  59954. }
  59955. }
  59956. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  59957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59960. /**
  59961. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59962. */
  59963. export class ColorMergerBlock extends NodeMaterialBlock {
  59964. /**
  59965. * Create a new ColorMergerBlock
  59966. * @param name defines the block name
  59967. */
  59968. constructor(name: string);
  59969. /**
  59970. * Gets the current class name
  59971. * @returns the class name
  59972. */
  59973. getClassName(): string;
  59974. /**
  59975. * Gets the rgb component (input)
  59976. */
  59977. get rgbIn(): NodeMaterialConnectionPoint;
  59978. /**
  59979. * Gets the r component (input)
  59980. */
  59981. get r(): NodeMaterialConnectionPoint;
  59982. /**
  59983. * Gets the g component (input)
  59984. */
  59985. get g(): NodeMaterialConnectionPoint;
  59986. /**
  59987. * Gets the b component (input)
  59988. */
  59989. get b(): NodeMaterialConnectionPoint;
  59990. /**
  59991. * Gets the a component (input)
  59992. */
  59993. get a(): NodeMaterialConnectionPoint;
  59994. /**
  59995. * Gets the rgba component (output)
  59996. */
  59997. get rgba(): NodeMaterialConnectionPoint;
  59998. /**
  59999. * Gets the rgb component (output)
  60000. */
  60001. get rgbOut(): NodeMaterialConnectionPoint;
  60002. /**
  60003. * Gets the rgb component (output)
  60004. * @deprecated Please use rgbOut instead.
  60005. */
  60006. get rgb(): NodeMaterialConnectionPoint;
  60007. protected _buildBlock(state: NodeMaterialBuildState): this;
  60008. }
  60009. }
  60010. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60014. /**
  60015. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60016. */
  60017. export class VectorMergerBlock extends NodeMaterialBlock {
  60018. /**
  60019. * Create a new VectorMergerBlock
  60020. * @param name defines the block name
  60021. */
  60022. constructor(name: string);
  60023. /**
  60024. * Gets the current class name
  60025. * @returns the class name
  60026. */
  60027. getClassName(): string;
  60028. /**
  60029. * Gets the xyz component (input)
  60030. */
  60031. get xyzIn(): NodeMaterialConnectionPoint;
  60032. /**
  60033. * Gets the xy component (input)
  60034. */
  60035. get xyIn(): NodeMaterialConnectionPoint;
  60036. /**
  60037. * Gets the x component (input)
  60038. */
  60039. get x(): NodeMaterialConnectionPoint;
  60040. /**
  60041. * Gets the y component (input)
  60042. */
  60043. get y(): NodeMaterialConnectionPoint;
  60044. /**
  60045. * Gets the z component (input)
  60046. */
  60047. get z(): NodeMaterialConnectionPoint;
  60048. /**
  60049. * Gets the w component (input)
  60050. */
  60051. get w(): NodeMaterialConnectionPoint;
  60052. /**
  60053. * Gets the xyzw component (output)
  60054. */
  60055. get xyzw(): NodeMaterialConnectionPoint;
  60056. /**
  60057. * Gets the xyz component (output)
  60058. */
  60059. get xyzOut(): NodeMaterialConnectionPoint;
  60060. /**
  60061. * Gets the xy component (output)
  60062. */
  60063. get xyOut(): NodeMaterialConnectionPoint;
  60064. /**
  60065. * Gets the xy component (output)
  60066. * @deprecated Please use xyOut instead.
  60067. */
  60068. get xy(): NodeMaterialConnectionPoint;
  60069. /**
  60070. * Gets the xyz component (output)
  60071. * @deprecated Please use xyzOut instead.
  60072. */
  60073. get xyz(): NodeMaterialConnectionPoint;
  60074. protected _buildBlock(state: NodeMaterialBuildState): this;
  60075. }
  60076. }
  60077. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60079. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60081. /**
  60082. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60083. */
  60084. export class ColorSplitterBlock extends NodeMaterialBlock {
  60085. /**
  60086. * Create a new ColorSplitterBlock
  60087. * @param name defines the block name
  60088. */
  60089. constructor(name: string);
  60090. /**
  60091. * Gets the current class name
  60092. * @returns the class name
  60093. */
  60094. getClassName(): string;
  60095. /**
  60096. * Gets the rgba component (input)
  60097. */
  60098. get rgba(): NodeMaterialConnectionPoint;
  60099. /**
  60100. * Gets the rgb component (input)
  60101. */
  60102. get rgbIn(): NodeMaterialConnectionPoint;
  60103. /**
  60104. * Gets the rgb component (output)
  60105. */
  60106. get rgbOut(): NodeMaterialConnectionPoint;
  60107. /**
  60108. * Gets the r component (output)
  60109. */
  60110. get r(): NodeMaterialConnectionPoint;
  60111. /**
  60112. * Gets the g component (output)
  60113. */
  60114. get g(): NodeMaterialConnectionPoint;
  60115. /**
  60116. * Gets the b component (output)
  60117. */
  60118. get b(): NodeMaterialConnectionPoint;
  60119. /**
  60120. * Gets the a component (output)
  60121. */
  60122. get a(): NodeMaterialConnectionPoint;
  60123. protected _inputRename(name: string): string;
  60124. protected _outputRename(name: string): string;
  60125. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60126. }
  60127. }
  60128. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60132. /**
  60133. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60134. */
  60135. export class VectorSplitterBlock extends NodeMaterialBlock {
  60136. /**
  60137. * Create a new VectorSplitterBlock
  60138. * @param name defines the block name
  60139. */
  60140. constructor(name: string);
  60141. /**
  60142. * Gets the current class name
  60143. * @returns the class name
  60144. */
  60145. getClassName(): string;
  60146. /**
  60147. * Gets the xyzw component (input)
  60148. */
  60149. get xyzw(): NodeMaterialConnectionPoint;
  60150. /**
  60151. * Gets the xyz component (input)
  60152. */
  60153. get xyzIn(): NodeMaterialConnectionPoint;
  60154. /**
  60155. * Gets the xy component (input)
  60156. */
  60157. get xyIn(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the xyz component (output)
  60160. */
  60161. get xyzOut(): NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the xy component (output)
  60164. */
  60165. get xyOut(): NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the x component (output)
  60168. */
  60169. get x(): NodeMaterialConnectionPoint;
  60170. /**
  60171. * Gets the y component (output)
  60172. */
  60173. get y(): NodeMaterialConnectionPoint;
  60174. /**
  60175. * Gets the z component (output)
  60176. */
  60177. get z(): NodeMaterialConnectionPoint;
  60178. /**
  60179. * Gets the w component (output)
  60180. */
  60181. get w(): NodeMaterialConnectionPoint;
  60182. protected _inputRename(name: string): string;
  60183. protected _outputRename(name: string): string;
  60184. protected _buildBlock(state: NodeMaterialBuildState): this;
  60185. }
  60186. }
  60187. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60191. /**
  60192. * Block used to lerp between 2 values
  60193. */
  60194. export class LerpBlock extends NodeMaterialBlock {
  60195. /**
  60196. * Creates a new LerpBlock
  60197. * @param name defines the block name
  60198. */
  60199. constructor(name: string);
  60200. /**
  60201. * Gets the current class name
  60202. * @returns the class name
  60203. */
  60204. getClassName(): string;
  60205. /**
  60206. * Gets the left operand input component
  60207. */
  60208. get left(): NodeMaterialConnectionPoint;
  60209. /**
  60210. * Gets the right operand input component
  60211. */
  60212. get right(): NodeMaterialConnectionPoint;
  60213. /**
  60214. * Gets the gradient operand input component
  60215. */
  60216. get gradient(): NodeMaterialConnectionPoint;
  60217. /**
  60218. * Gets the output component
  60219. */
  60220. get output(): NodeMaterialConnectionPoint;
  60221. protected _buildBlock(state: NodeMaterialBuildState): this;
  60222. }
  60223. }
  60224. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  60225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60228. /**
  60229. * Block used to divide 2 vectors
  60230. */
  60231. export class DivideBlock extends NodeMaterialBlock {
  60232. /**
  60233. * Creates a new DivideBlock
  60234. * @param name defines the block name
  60235. */
  60236. constructor(name: string);
  60237. /**
  60238. * Gets the current class name
  60239. * @returns the class name
  60240. */
  60241. getClassName(): string;
  60242. /**
  60243. * Gets the left operand input component
  60244. */
  60245. get left(): NodeMaterialConnectionPoint;
  60246. /**
  60247. * Gets the right operand input component
  60248. */
  60249. get right(): NodeMaterialConnectionPoint;
  60250. /**
  60251. * Gets the output component
  60252. */
  60253. get output(): NodeMaterialConnectionPoint;
  60254. protected _buildBlock(state: NodeMaterialBuildState): this;
  60255. }
  60256. }
  60257. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  60258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60261. /**
  60262. * Block used to subtract 2 vectors
  60263. */
  60264. export class SubtractBlock extends NodeMaterialBlock {
  60265. /**
  60266. * Creates a new SubtractBlock
  60267. * @param name defines the block name
  60268. */
  60269. constructor(name: string);
  60270. /**
  60271. * Gets the current class name
  60272. * @returns the class name
  60273. */
  60274. getClassName(): string;
  60275. /**
  60276. * Gets the left operand input component
  60277. */
  60278. get left(): NodeMaterialConnectionPoint;
  60279. /**
  60280. * Gets the right operand input component
  60281. */
  60282. get right(): NodeMaterialConnectionPoint;
  60283. /**
  60284. * Gets the output component
  60285. */
  60286. get output(): NodeMaterialConnectionPoint;
  60287. protected _buildBlock(state: NodeMaterialBuildState): this;
  60288. }
  60289. }
  60290. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  60291. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60293. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60294. /**
  60295. * Block used to step a value
  60296. */
  60297. export class StepBlock extends NodeMaterialBlock {
  60298. /**
  60299. * Creates a new StepBlock
  60300. * @param name defines the block name
  60301. */
  60302. constructor(name: string);
  60303. /**
  60304. * Gets the current class name
  60305. * @returns the class name
  60306. */
  60307. getClassName(): string;
  60308. /**
  60309. * Gets the value operand input component
  60310. */
  60311. get value(): NodeMaterialConnectionPoint;
  60312. /**
  60313. * Gets the edge operand input component
  60314. */
  60315. get edge(): NodeMaterialConnectionPoint;
  60316. /**
  60317. * Gets the output component
  60318. */
  60319. get output(): NodeMaterialConnectionPoint;
  60320. protected _buildBlock(state: NodeMaterialBuildState): this;
  60321. }
  60322. }
  60323. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  60324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60327. /**
  60328. * Block used to get the opposite (1 - x) of a value
  60329. */
  60330. export class OneMinusBlock extends NodeMaterialBlock {
  60331. /**
  60332. * Creates a new OneMinusBlock
  60333. * @param name defines the block name
  60334. */
  60335. constructor(name: string);
  60336. /**
  60337. * Gets the current class name
  60338. * @returns the class name
  60339. */
  60340. getClassName(): string;
  60341. /**
  60342. * Gets the input component
  60343. */
  60344. get input(): NodeMaterialConnectionPoint;
  60345. /**
  60346. * Gets the output component
  60347. */
  60348. get output(): NodeMaterialConnectionPoint;
  60349. protected _buildBlock(state: NodeMaterialBuildState): this;
  60350. }
  60351. }
  60352. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  60353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60356. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60357. /**
  60358. * Block used to get the view direction
  60359. */
  60360. export class ViewDirectionBlock extends NodeMaterialBlock {
  60361. /**
  60362. * Creates a new ViewDirectionBlock
  60363. * @param name defines the block name
  60364. */
  60365. constructor(name: string);
  60366. /**
  60367. * Gets the current class name
  60368. * @returns the class name
  60369. */
  60370. getClassName(): string;
  60371. /**
  60372. * Gets the world position component
  60373. */
  60374. get worldPosition(): NodeMaterialConnectionPoint;
  60375. /**
  60376. * Gets the camera position component
  60377. */
  60378. get cameraPosition(): NodeMaterialConnectionPoint;
  60379. /**
  60380. * Gets the output component
  60381. */
  60382. get output(): NodeMaterialConnectionPoint;
  60383. autoConfigure(material: NodeMaterial): void;
  60384. protected _buildBlock(state: NodeMaterialBuildState): this;
  60385. }
  60386. }
  60387. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  60388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60391. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60392. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  60393. /**
  60394. * Block used to compute fresnel value
  60395. */
  60396. export class FresnelBlock extends NodeMaterialBlock {
  60397. /**
  60398. * Create a new FresnelBlock
  60399. * @param name defines the block name
  60400. */
  60401. constructor(name: string);
  60402. /**
  60403. * Gets the current class name
  60404. * @returns the class name
  60405. */
  60406. getClassName(): string;
  60407. /**
  60408. * Gets the world normal input component
  60409. */
  60410. get worldNormal(): NodeMaterialConnectionPoint;
  60411. /**
  60412. * Gets the view direction input component
  60413. */
  60414. get viewDirection(): NodeMaterialConnectionPoint;
  60415. /**
  60416. * Gets the bias input component
  60417. */
  60418. get bias(): NodeMaterialConnectionPoint;
  60419. /**
  60420. * Gets the camera (or eye) position component
  60421. */
  60422. get power(): NodeMaterialConnectionPoint;
  60423. /**
  60424. * Gets the fresnel output component
  60425. */
  60426. get fresnel(): NodeMaterialConnectionPoint;
  60427. autoConfigure(material: NodeMaterial): void;
  60428. protected _buildBlock(state: NodeMaterialBuildState): this;
  60429. }
  60430. }
  60431. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  60432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60435. /**
  60436. * Block used to get the max of 2 values
  60437. */
  60438. export class MaxBlock extends NodeMaterialBlock {
  60439. /**
  60440. * Creates a new MaxBlock
  60441. * @param name defines the block name
  60442. */
  60443. constructor(name: string);
  60444. /**
  60445. * Gets the current class name
  60446. * @returns the class name
  60447. */
  60448. getClassName(): string;
  60449. /**
  60450. * Gets the left operand input component
  60451. */
  60452. get left(): NodeMaterialConnectionPoint;
  60453. /**
  60454. * Gets the right operand input component
  60455. */
  60456. get right(): NodeMaterialConnectionPoint;
  60457. /**
  60458. * Gets the output component
  60459. */
  60460. get output(): NodeMaterialConnectionPoint;
  60461. protected _buildBlock(state: NodeMaterialBuildState): this;
  60462. }
  60463. }
  60464. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  60465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60468. /**
  60469. * Block used to get the min of 2 values
  60470. */
  60471. export class MinBlock extends NodeMaterialBlock {
  60472. /**
  60473. * Creates a new MinBlock
  60474. * @param name defines the block name
  60475. */
  60476. constructor(name: string);
  60477. /**
  60478. * Gets the current class name
  60479. * @returns the class name
  60480. */
  60481. getClassName(): string;
  60482. /**
  60483. * Gets the left operand input component
  60484. */
  60485. get left(): NodeMaterialConnectionPoint;
  60486. /**
  60487. * Gets the right operand input component
  60488. */
  60489. get right(): NodeMaterialConnectionPoint;
  60490. /**
  60491. * Gets the output component
  60492. */
  60493. get output(): NodeMaterialConnectionPoint;
  60494. protected _buildBlock(state: NodeMaterialBuildState): this;
  60495. }
  60496. }
  60497. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  60498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60501. /**
  60502. * Block used to get the distance between 2 values
  60503. */
  60504. export class DistanceBlock extends NodeMaterialBlock {
  60505. /**
  60506. * Creates a new DistanceBlock
  60507. * @param name defines the block name
  60508. */
  60509. constructor(name: string);
  60510. /**
  60511. * Gets the current class name
  60512. * @returns the class name
  60513. */
  60514. getClassName(): string;
  60515. /**
  60516. * Gets the left operand input component
  60517. */
  60518. get left(): NodeMaterialConnectionPoint;
  60519. /**
  60520. * Gets the right operand input component
  60521. */
  60522. get right(): NodeMaterialConnectionPoint;
  60523. /**
  60524. * Gets the output component
  60525. */
  60526. get output(): NodeMaterialConnectionPoint;
  60527. protected _buildBlock(state: NodeMaterialBuildState): this;
  60528. }
  60529. }
  60530. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  60531. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60532. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60533. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60534. /**
  60535. * Block used to get the length of a vector
  60536. */
  60537. export class LengthBlock extends NodeMaterialBlock {
  60538. /**
  60539. * Creates a new LengthBlock
  60540. * @param name defines the block name
  60541. */
  60542. constructor(name: string);
  60543. /**
  60544. * Gets the current class name
  60545. * @returns the class name
  60546. */
  60547. getClassName(): string;
  60548. /**
  60549. * Gets the value input component
  60550. */
  60551. get value(): NodeMaterialConnectionPoint;
  60552. /**
  60553. * Gets the output component
  60554. */
  60555. get output(): NodeMaterialConnectionPoint;
  60556. protected _buildBlock(state: NodeMaterialBuildState): this;
  60557. }
  60558. }
  60559. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  60560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60563. /**
  60564. * Block used to get negative version of a value (i.e. x * -1)
  60565. */
  60566. export class NegateBlock extends NodeMaterialBlock {
  60567. /**
  60568. * Creates a new NegateBlock
  60569. * @param name defines the block name
  60570. */
  60571. constructor(name: string);
  60572. /**
  60573. * Gets the current class name
  60574. * @returns the class name
  60575. */
  60576. getClassName(): string;
  60577. /**
  60578. * Gets the value input component
  60579. */
  60580. get value(): NodeMaterialConnectionPoint;
  60581. /**
  60582. * Gets the output component
  60583. */
  60584. get output(): NodeMaterialConnectionPoint;
  60585. protected _buildBlock(state: NodeMaterialBuildState): this;
  60586. }
  60587. }
  60588. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  60589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60592. /**
  60593. * Block used to get the value of the first parameter raised to the power of the second
  60594. */
  60595. export class PowBlock extends NodeMaterialBlock {
  60596. /**
  60597. * Creates a new PowBlock
  60598. * @param name defines the block name
  60599. */
  60600. constructor(name: string);
  60601. /**
  60602. * Gets the current class name
  60603. * @returns the class name
  60604. */
  60605. getClassName(): string;
  60606. /**
  60607. * Gets the value operand input component
  60608. */
  60609. get value(): NodeMaterialConnectionPoint;
  60610. /**
  60611. * Gets the power operand input component
  60612. */
  60613. get power(): NodeMaterialConnectionPoint;
  60614. /**
  60615. * Gets the output component
  60616. */
  60617. get output(): NodeMaterialConnectionPoint;
  60618. protected _buildBlock(state: NodeMaterialBuildState): this;
  60619. }
  60620. }
  60621. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  60622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60625. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60626. /**
  60627. * Block used to get a random number
  60628. */
  60629. export class RandomNumberBlock extends NodeMaterialBlock {
  60630. /**
  60631. * Creates a new RandomNumberBlock
  60632. * @param name defines the block name
  60633. */
  60634. constructor(name: string);
  60635. /**
  60636. * Gets the current class name
  60637. * @returns the class name
  60638. */
  60639. getClassName(): string;
  60640. /**
  60641. * Gets the seed input component
  60642. */
  60643. get seed(): NodeMaterialConnectionPoint;
  60644. /**
  60645. * Gets the output component
  60646. */
  60647. get output(): NodeMaterialConnectionPoint;
  60648. protected _buildBlock(state: NodeMaterialBuildState): this;
  60649. }
  60650. }
  60651. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  60652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60655. /**
  60656. * Block used to compute arc tangent of 2 values
  60657. */
  60658. export class ArcTan2Block extends NodeMaterialBlock {
  60659. /**
  60660. * Creates a new ArcTan2Block
  60661. * @param name defines the block name
  60662. */
  60663. constructor(name: string);
  60664. /**
  60665. * Gets the current class name
  60666. * @returns the class name
  60667. */
  60668. getClassName(): string;
  60669. /**
  60670. * Gets the x operand input component
  60671. */
  60672. get x(): NodeMaterialConnectionPoint;
  60673. /**
  60674. * Gets the y operand input component
  60675. */
  60676. get y(): NodeMaterialConnectionPoint;
  60677. /**
  60678. * Gets the output component
  60679. */
  60680. get output(): NodeMaterialConnectionPoint;
  60681. protected _buildBlock(state: NodeMaterialBuildState): this;
  60682. }
  60683. }
  60684. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  60685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60688. /**
  60689. * Block used to smooth step a value
  60690. */
  60691. export class SmoothStepBlock extends NodeMaterialBlock {
  60692. /**
  60693. * Creates a new SmoothStepBlock
  60694. * @param name defines the block name
  60695. */
  60696. constructor(name: string);
  60697. /**
  60698. * Gets the current class name
  60699. * @returns the class name
  60700. */
  60701. getClassName(): string;
  60702. /**
  60703. * Gets the value operand input component
  60704. */
  60705. get value(): NodeMaterialConnectionPoint;
  60706. /**
  60707. * Gets the first edge operand input component
  60708. */
  60709. get edge0(): NodeMaterialConnectionPoint;
  60710. /**
  60711. * Gets the second edge operand input component
  60712. */
  60713. get edge1(): NodeMaterialConnectionPoint;
  60714. /**
  60715. * Gets the output component
  60716. */
  60717. get output(): NodeMaterialConnectionPoint;
  60718. protected _buildBlock(state: NodeMaterialBuildState): this;
  60719. }
  60720. }
  60721. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  60722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60725. /**
  60726. * Block used to get the reciprocal (1 / x) of a value
  60727. */
  60728. export class ReciprocalBlock extends NodeMaterialBlock {
  60729. /**
  60730. * Creates a new ReciprocalBlock
  60731. * @param name defines the block name
  60732. */
  60733. constructor(name: string);
  60734. /**
  60735. * Gets the current class name
  60736. * @returns the class name
  60737. */
  60738. getClassName(): string;
  60739. /**
  60740. * Gets the input component
  60741. */
  60742. get input(): NodeMaterialConnectionPoint;
  60743. /**
  60744. * Gets the output component
  60745. */
  60746. get output(): NodeMaterialConnectionPoint;
  60747. protected _buildBlock(state: NodeMaterialBuildState): this;
  60748. }
  60749. }
  60750. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  60751. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60752. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60753. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60754. /**
  60755. * Block used to replace a color by another one
  60756. */
  60757. export class ReplaceColorBlock extends NodeMaterialBlock {
  60758. /**
  60759. * Creates a new ReplaceColorBlock
  60760. * @param name defines the block name
  60761. */
  60762. constructor(name: string);
  60763. /**
  60764. * Gets the current class name
  60765. * @returns the class name
  60766. */
  60767. getClassName(): string;
  60768. /**
  60769. * Gets the value input component
  60770. */
  60771. get value(): NodeMaterialConnectionPoint;
  60772. /**
  60773. * Gets the reference input component
  60774. */
  60775. get reference(): NodeMaterialConnectionPoint;
  60776. /**
  60777. * Gets the distance input component
  60778. */
  60779. get distance(): NodeMaterialConnectionPoint;
  60780. /**
  60781. * Gets the replacement input component
  60782. */
  60783. get replacement(): NodeMaterialConnectionPoint;
  60784. /**
  60785. * Gets the output component
  60786. */
  60787. get output(): NodeMaterialConnectionPoint;
  60788. protected _buildBlock(state: NodeMaterialBuildState): this;
  60789. }
  60790. }
  60791. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  60792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60793. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60795. /**
  60796. * Block used to posterize a value
  60797. * @see https://en.wikipedia.org/wiki/Posterization
  60798. */
  60799. export class PosterizeBlock extends NodeMaterialBlock {
  60800. /**
  60801. * Creates a new PosterizeBlock
  60802. * @param name defines the block name
  60803. */
  60804. constructor(name: string);
  60805. /**
  60806. * Gets the current class name
  60807. * @returns the class name
  60808. */
  60809. getClassName(): string;
  60810. /**
  60811. * Gets the value input component
  60812. */
  60813. get value(): NodeMaterialConnectionPoint;
  60814. /**
  60815. * Gets the steps input component
  60816. */
  60817. get steps(): NodeMaterialConnectionPoint;
  60818. /**
  60819. * Gets the output component
  60820. */
  60821. get output(): NodeMaterialConnectionPoint;
  60822. protected _buildBlock(state: NodeMaterialBuildState): this;
  60823. }
  60824. }
  60825. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  60826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60829. import { Scene } from "babylonjs/scene";
  60830. /**
  60831. * Operations supported by the Wave block
  60832. */
  60833. export enum WaveBlockKind {
  60834. /** SawTooth */
  60835. SawTooth = 0,
  60836. /** Square */
  60837. Square = 1,
  60838. /** Triangle */
  60839. Triangle = 2
  60840. }
  60841. /**
  60842. * Block used to apply wave operation to floats
  60843. */
  60844. export class WaveBlock extends NodeMaterialBlock {
  60845. /**
  60846. * Gets or sets the kibnd of wave to be applied by the block
  60847. */
  60848. kind: WaveBlockKind;
  60849. /**
  60850. * Creates a new WaveBlock
  60851. * @param name defines the block name
  60852. */
  60853. constructor(name: string);
  60854. /**
  60855. * Gets the current class name
  60856. * @returns the class name
  60857. */
  60858. getClassName(): string;
  60859. /**
  60860. * Gets the input component
  60861. */
  60862. get input(): NodeMaterialConnectionPoint;
  60863. /**
  60864. * Gets the output component
  60865. */
  60866. get output(): NodeMaterialConnectionPoint;
  60867. protected _buildBlock(state: NodeMaterialBuildState): this;
  60868. serialize(): any;
  60869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60870. }
  60871. }
  60872. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  60873. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60874. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60875. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60876. import { Color3 } from "babylonjs/Maths/math.color";
  60877. import { Scene } from "babylonjs/scene";
  60878. /**
  60879. * Class used to store a color step for the GradientBlock
  60880. */
  60881. export class GradientBlockColorStep {
  60882. /**
  60883. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60884. */
  60885. step: number;
  60886. /**
  60887. * Gets or sets the color associated with this step
  60888. */
  60889. color: Color3;
  60890. /**
  60891. * Creates a new GradientBlockColorStep
  60892. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60893. * @param color defines the color associated with this step
  60894. */
  60895. constructor(
  60896. /**
  60897. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60898. */
  60899. step: number,
  60900. /**
  60901. * Gets or sets the color associated with this step
  60902. */
  60903. color: Color3);
  60904. }
  60905. /**
  60906. * Block used to return a color from a gradient based on an input value between 0 and 1
  60907. */
  60908. export class GradientBlock extends NodeMaterialBlock {
  60909. /**
  60910. * Gets or sets the list of color steps
  60911. */
  60912. colorSteps: GradientBlockColorStep[];
  60913. /**
  60914. * Creates a new GradientBlock
  60915. * @param name defines the block name
  60916. */
  60917. constructor(name: string);
  60918. /**
  60919. * Gets the current class name
  60920. * @returns the class name
  60921. */
  60922. getClassName(): string;
  60923. /**
  60924. * Gets the gradient input component
  60925. */
  60926. get gradient(): NodeMaterialConnectionPoint;
  60927. /**
  60928. * Gets the output component
  60929. */
  60930. get output(): NodeMaterialConnectionPoint;
  60931. private _writeColorConstant;
  60932. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60933. serialize(): any;
  60934. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60935. protected _dumpPropertiesCode(): string;
  60936. }
  60937. }
  60938. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  60939. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60940. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60941. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60942. /**
  60943. * Block used to normalize lerp between 2 values
  60944. */
  60945. export class NLerpBlock extends NodeMaterialBlock {
  60946. /**
  60947. * Creates a new NLerpBlock
  60948. * @param name defines the block name
  60949. */
  60950. constructor(name: string);
  60951. /**
  60952. * Gets the current class name
  60953. * @returns the class name
  60954. */
  60955. getClassName(): string;
  60956. /**
  60957. * Gets the left operand input component
  60958. */
  60959. get left(): NodeMaterialConnectionPoint;
  60960. /**
  60961. * Gets the right operand input component
  60962. */
  60963. get right(): NodeMaterialConnectionPoint;
  60964. /**
  60965. * Gets the gradient operand input component
  60966. */
  60967. get gradient(): NodeMaterialConnectionPoint;
  60968. /**
  60969. * Gets the output component
  60970. */
  60971. get output(): NodeMaterialConnectionPoint;
  60972. protected _buildBlock(state: NodeMaterialBuildState): this;
  60973. }
  60974. }
  60975. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  60976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60979. import { Scene } from "babylonjs/scene";
  60980. /**
  60981. * block used to Generate a Worley Noise 3D Noise Pattern
  60982. */
  60983. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60984. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60985. manhattanDistance: boolean;
  60986. /**
  60987. * Creates a new WorleyNoise3DBlock
  60988. * @param name defines the block name
  60989. */
  60990. constructor(name: string);
  60991. /**
  60992. * Gets the current class name
  60993. * @returns the class name
  60994. */
  60995. getClassName(): string;
  60996. /**
  60997. * Gets the seed input component
  60998. */
  60999. get seed(): NodeMaterialConnectionPoint;
  61000. /**
  61001. * Gets the jitter input component
  61002. */
  61003. get jitter(): NodeMaterialConnectionPoint;
  61004. /**
  61005. * Gets the output component
  61006. */
  61007. get output(): NodeMaterialConnectionPoint;
  61008. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61009. /**
  61010. * Exposes the properties to the UI?
  61011. */
  61012. protected _dumpPropertiesCode(): string;
  61013. /**
  61014. * Exposes the properties to the Seralize?
  61015. */
  61016. serialize(): any;
  61017. /**
  61018. * Exposes the properties to the deseralize?
  61019. */
  61020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61021. }
  61022. }
  61023. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61027. /**
  61028. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61029. */
  61030. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61031. /**
  61032. * Creates a new SimplexPerlin3DBlock
  61033. * @param name defines the block name
  61034. */
  61035. constructor(name: string);
  61036. /**
  61037. * Gets the current class name
  61038. * @returns the class name
  61039. */
  61040. getClassName(): string;
  61041. /**
  61042. * Gets the seed operand input component
  61043. */
  61044. get seed(): NodeMaterialConnectionPoint;
  61045. /**
  61046. * Gets the output component
  61047. */
  61048. get output(): NodeMaterialConnectionPoint;
  61049. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61050. }
  61051. }
  61052. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61056. /**
  61057. * Block used to blend normals
  61058. */
  61059. export class NormalBlendBlock extends NodeMaterialBlock {
  61060. /**
  61061. * Creates a new NormalBlendBlock
  61062. * @param name defines the block name
  61063. */
  61064. constructor(name: string);
  61065. /**
  61066. * Gets the current class name
  61067. * @returns the class name
  61068. */
  61069. getClassName(): string;
  61070. /**
  61071. * Gets the first input component
  61072. */
  61073. get normalMap0(): NodeMaterialConnectionPoint;
  61074. /**
  61075. * Gets the second input component
  61076. */
  61077. get normalMap1(): NodeMaterialConnectionPoint;
  61078. /**
  61079. * Gets the output component
  61080. */
  61081. get output(): NodeMaterialConnectionPoint;
  61082. protected _buildBlock(state: NodeMaterialBuildState): this;
  61083. }
  61084. }
  61085. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61089. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61090. /**
  61091. * Block used to rotate a 2d vector by a given angle
  61092. */
  61093. export class Rotate2dBlock extends NodeMaterialBlock {
  61094. /**
  61095. * Creates a new Rotate2dBlock
  61096. * @param name defines the block name
  61097. */
  61098. constructor(name: string);
  61099. /**
  61100. * Gets the current class name
  61101. * @returns the class name
  61102. */
  61103. getClassName(): string;
  61104. /**
  61105. * Gets the input vector
  61106. */
  61107. get input(): NodeMaterialConnectionPoint;
  61108. /**
  61109. * Gets the input angle
  61110. */
  61111. get angle(): NodeMaterialConnectionPoint;
  61112. /**
  61113. * Gets the output component
  61114. */
  61115. get output(): NodeMaterialConnectionPoint;
  61116. autoConfigure(material: NodeMaterial): void;
  61117. protected _buildBlock(state: NodeMaterialBuildState): this;
  61118. }
  61119. }
  61120. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61124. /**
  61125. * Block used to get the reflected vector from a direction and a normal
  61126. */
  61127. export class ReflectBlock extends NodeMaterialBlock {
  61128. /**
  61129. * Creates a new ReflectBlock
  61130. * @param name defines the block name
  61131. */
  61132. constructor(name: string);
  61133. /**
  61134. * Gets the current class name
  61135. * @returns the class name
  61136. */
  61137. getClassName(): string;
  61138. /**
  61139. * Gets the incident component
  61140. */
  61141. get incident(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the normal component
  61144. */
  61145. get normal(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the output component
  61148. */
  61149. get output(): NodeMaterialConnectionPoint;
  61150. protected _buildBlock(state: NodeMaterialBuildState): this;
  61151. }
  61152. }
  61153. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61157. /**
  61158. * Block used to get the refracted vector from a direction and a normal
  61159. */
  61160. export class RefractBlock extends NodeMaterialBlock {
  61161. /**
  61162. * Creates a new RefractBlock
  61163. * @param name defines the block name
  61164. */
  61165. constructor(name: string);
  61166. /**
  61167. * Gets the current class name
  61168. * @returns the class name
  61169. */
  61170. getClassName(): string;
  61171. /**
  61172. * Gets the incident component
  61173. */
  61174. get incident(): NodeMaterialConnectionPoint;
  61175. /**
  61176. * Gets the normal component
  61177. */
  61178. get normal(): NodeMaterialConnectionPoint;
  61179. /**
  61180. * Gets the index of refraction component
  61181. */
  61182. get ior(): NodeMaterialConnectionPoint;
  61183. /**
  61184. * Gets the output component
  61185. */
  61186. get output(): NodeMaterialConnectionPoint;
  61187. protected _buildBlock(state: NodeMaterialBuildState): this;
  61188. }
  61189. }
  61190. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61193. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61194. /**
  61195. * Block used to desaturate a color
  61196. */
  61197. export class DesaturateBlock extends NodeMaterialBlock {
  61198. /**
  61199. * Creates a new DesaturateBlock
  61200. * @param name defines the block name
  61201. */
  61202. constructor(name: string);
  61203. /**
  61204. * Gets the current class name
  61205. * @returns the class name
  61206. */
  61207. getClassName(): string;
  61208. /**
  61209. * Gets the color operand input component
  61210. */
  61211. get color(): NodeMaterialConnectionPoint;
  61212. /**
  61213. * Gets the level operand input component
  61214. */
  61215. get level(): NodeMaterialConnectionPoint;
  61216. /**
  61217. * Gets the output component
  61218. */
  61219. get output(): NodeMaterialConnectionPoint;
  61220. protected _buildBlock(state: NodeMaterialBuildState): this;
  61221. }
  61222. }
  61223. declare module "babylonjs/Materials/Node/Blocks/index" {
  61224. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  61225. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  61226. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  61227. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  61228. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  61229. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  61230. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  61231. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  61232. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  61233. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  61234. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  61235. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  61236. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  61237. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  61238. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  61239. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  61240. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  61241. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  61242. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  61243. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  61244. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  61245. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  61246. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  61247. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  61248. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  61249. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  61250. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  61251. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  61252. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  61253. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  61254. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  61255. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  61256. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  61257. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  61258. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  61259. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  61260. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  61261. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  61262. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  61263. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  61264. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  61265. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  61266. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  61267. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  61268. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  61269. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  61270. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  61271. }
  61272. declare module "babylonjs/Materials/Node/Optimizers/index" {
  61273. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61274. }
  61275. declare module "babylonjs/Materials/Node/index" {
  61276. export * from "babylonjs/Materials/Node/Enums/index";
  61277. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61278. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  61279. export * from "babylonjs/Materials/Node/nodeMaterial";
  61280. export * from "babylonjs/Materials/Node/Blocks/index";
  61281. export * from "babylonjs/Materials/Node/Optimizers/index";
  61282. }
  61283. declare module "babylonjs/Materials/effectRenderer" {
  61284. import { Nullable } from "babylonjs/types";
  61285. import { Texture } from "babylonjs/Materials/Textures/texture";
  61286. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61287. import { Viewport } from "babylonjs/Maths/math.viewport";
  61288. import { Observable } from "babylonjs/Misc/observable";
  61289. import { Effect } from "babylonjs/Materials/effect";
  61290. import "babylonjs/Engines/Extensions/engine.renderTarget";
  61291. import "babylonjs/Shaders/postprocess.vertex";
  61292. /**
  61293. * Effect Render Options
  61294. */
  61295. export interface IEffectRendererOptions {
  61296. /**
  61297. * Defines the vertices positions.
  61298. */
  61299. positions?: number[];
  61300. /**
  61301. * Defines the indices.
  61302. */
  61303. indices?: number[];
  61304. }
  61305. /**
  61306. * Helper class to render one or more effects
  61307. */
  61308. export class EffectRenderer {
  61309. private engine;
  61310. private static _DefaultOptions;
  61311. private _vertexBuffers;
  61312. private _indexBuffer;
  61313. private _ringBufferIndex;
  61314. private _ringScreenBuffer;
  61315. private _fullscreenViewport;
  61316. private _getNextFrameBuffer;
  61317. /**
  61318. * Creates an effect renderer
  61319. * @param engine the engine to use for rendering
  61320. * @param options defines the options of the effect renderer
  61321. */
  61322. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61323. /**
  61324. * Sets the current viewport in normalized coordinates 0-1
  61325. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61326. */
  61327. setViewport(viewport?: Viewport): void;
  61328. /**
  61329. * Binds the embedded attributes buffer to the effect.
  61330. * @param effect Defines the effect to bind the attributes for
  61331. */
  61332. bindBuffers(effect: Effect): void;
  61333. /**
  61334. * Sets the current effect wrapper to use during draw.
  61335. * The effect needs to be ready before calling this api.
  61336. * This also sets the default full screen position attribute.
  61337. * @param effectWrapper Defines the effect to draw with
  61338. */
  61339. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61340. /**
  61341. * Draws a full screen quad.
  61342. */
  61343. draw(): void;
  61344. /**
  61345. * renders one or more effects to a specified texture
  61346. * @param effectWrappers list of effects to renderer
  61347. * @param outputTexture texture to draw to, if null it will render to the screen
  61348. */
  61349. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  61350. /**
  61351. * Disposes of the effect renderer
  61352. */
  61353. dispose(): void;
  61354. }
  61355. /**
  61356. * Options to create an EffectWrapper
  61357. */
  61358. interface EffectWrapperCreationOptions {
  61359. /**
  61360. * Engine to use to create the effect
  61361. */
  61362. engine: ThinEngine;
  61363. /**
  61364. * Fragment shader for the effect
  61365. */
  61366. fragmentShader: string;
  61367. /**
  61368. * Vertex shader for the effect
  61369. */
  61370. vertexShader?: string;
  61371. /**
  61372. * Attributes to use in the shader
  61373. */
  61374. attributeNames?: Array<string>;
  61375. /**
  61376. * Uniforms to use in the shader
  61377. */
  61378. uniformNames?: Array<string>;
  61379. /**
  61380. * Texture sampler names to use in the shader
  61381. */
  61382. samplerNames?: Array<string>;
  61383. /**
  61384. * The friendly name of the effect displayed in Spector.
  61385. */
  61386. name?: string;
  61387. }
  61388. /**
  61389. * Wraps an effect to be used for rendering
  61390. */
  61391. export class EffectWrapper {
  61392. /**
  61393. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61394. */
  61395. onApplyObservable: Observable<{}>;
  61396. /**
  61397. * The underlying effect
  61398. */
  61399. effect: Effect;
  61400. /**
  61401. * Creates an effect to be renderer
  61402. * @param creationOptions options to create the effect
  61403. */
  61404. constructor(creationOptions: EffectWrapperCreationOptions);
  61405. /**
  61406. * Disposes of the effect wrapper
  61407. */
  61408. dispose(): void;
  61409. }
  61410. }
  61411. declare module "babylonjs/Materials/index" {
  61412. export * from "babylonjs/Materials/Background/index";
  61413. export * from "babylonjs/Materials/colorCurves";
  61414. export * from "babylonjs/Materials/iEffectFallbacks";
  61415. export * from "babylonjs/Materials/effectFallbacks";
  61416. export * from "babylonjs/Materials/effect";
  61417. export * from "babylonjs/Materials/fresnelParameters";
  61418. export * from "babylonjs/Materials/imageProcessingConfiguration";
  61419. export * from "babylonjs/Materials/material";
  61420. export * from "babylonjs/Materials/materialDefines";
  61421. export * from "babylonjs/Materials/materialHelper";
  61422. export * from "babylonjs/Materials/multiMaterial";
  61423. export * from "babylonjs/Materials/PBR/index";
  61424. export * from "babylonjs/Materials/pushMaterial";
  61425. export * from "babylonjs/Materials/shaderMaterial";
  61426. export * from "babylonjs/Materials/standardMaterial";
  61427. export * from "babylonjs/Materials/Textures/index";
  61428. export * from "babylonjs/Materials/uniformBuffer";
  61429. export * from "babylonjs/Materials/materialFlags";
  61430. export * from "babylonjs/Materials/Node/index";
  61431. export * from "babylonjs/Materials/effectRenderer";
  61432. }
  61433. declare module "babylonjs/Maths/index" {
  61434. export * from "babylonjs/Maths/math.scalar";
  61435. export * from "babylonjs/Maths/math";
  61436. export * from "babylonjs/Maths/sphericalPolynomial";
  61437. }
  61438. declare module "babylonjs/Misc/workerPool" {
  61439. import { IDisposable } from "babylonjs/scene";
  61440. /**
  61441. * Helper class to push actions to a pool of workers.
  61442. */
  61443. export class WorkerPool implements IDisposable {
  61444. private _workerInfos;
  61445. private _pendingActions;
  61446. /**
  61447. * Constructor
  61448. * @param workers Array of workers to use for actions
  61449. */
  61450. constructor(workers: Array<Worker>);
  61451. /**
  61452. * Terminates all workers and clears any pending actions.
  61453. */
  61454. dispose(): void;
  61455. /**
  61456. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61457. * pended until a worker has completed its action.
  61458. * @param action The action to perform. Call onComplete when the action is complete.
  61459. */
  61460. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61461. private _execute;
  61462. }
  61463. }
  61464. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  61465. import { IDisposable } from "babylonjs/scene";
  61466. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61467. /**
  61468. * Configuration for Draco compression
  61469. */
  61470. export interface IDracoCompressionConfiguration {
  61471. /**
  61472. * Configuration for the decoder.
  61473. */
  61474. decoder: {
  61475. /**
  61476. * The url to the WebAssembly module.
  61477. */
  61478. wasmUrl?: string;
  61479. /**
  61480. * The url to the WebAssembly binary.
  61481. */
  61482. wasmBinaryUrl?: string;
  61483. /**
  61484. * The url to the fallback JavaScript module.
  61485. */
  61486. fallbackUrl?: string;
  61487. };
  61488. }
  61489. /**
  61490. * Draco compression (https://google.github.io/draco/)
  61491. *
  61492. * This class wraps the Draco module.
  61493. *
  61494. * **Encoder**
  61495. *
  61496. * The encoder is not currently implemented.
  61497. *
  61498. * **Decoder**
  61499. *
  61500. * 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.
  61501. *
  61502. * To update the configuration, use the following code:
  61503. * ```javascript
  61504. * DracoCompression.Configuration = {
  61505. * decoder: {
  61506. * wasmUrl: "<url to the WebAssembly library>",
  61507. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61508. * fallbackUrl: "<url to the fallback JavaScript library>",
  61509. * }
  61510. * };
  61511. * ```
  61512. *
  61513. * 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.
  61514. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61515. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61516. *
  61517. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61518. * ```javascript
  61519. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61520. * ```
  61521. *
  61522. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61523. */
  61524. export class DracoCompression implements IDisposable {
  61525. private _workerPoolPromise?;
  61526. private _decoderModulePromise?;
  61527. /**
  61528. * The configuration. Defaults to the following urls:
  61529. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61530. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61531. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61532. */
  61533. static Configuration: IDracoCompressionConfiguration;
  61534. /**
  61535. * Returns true if the decoder configuration is available.
  61536. */
  61537. static get DecoderAvailable(): boolean;
  61538. /**
  61539. * Default number of workers to create when creating the draco compression object.
  61540. */
  61541. static DefaultNumWorkers: number;
  61542. private static GetDefaultNumWorkers;
  61543. private static _Default;
  61544. /**
  61545. * Default instance for the draco compression object.
  61546. */
  61547. static get Default(): DracoCompression;
  61548. /**
  61549. * Constructor
  61550. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61551. */
  61552. constructor(numWorkers?: number);
  61553. /**
  61554. * Stop all async operations and release resources.
  61555. */
  61556. dispose(): void;
  61557. /**
  61558. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61559. * @returns a promise that resolves when ready
  61560. */
  61561. whenReadyAsync(): Promise<void>;
  61562. /**
  61563. * Decode Draco compressed mesh data to vertex data.
  61564. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61565. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61566. * @returns A promise that resolves with the decoded vertex data
  61567. */
  61568. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61569. [kind: string]: number;
  61570. }): Promise<VertexData>;
  61571. }
  61572. }
  61573. declare module "babylonjs/Meshes/Compression/index" {
  61574. export * from "babylonjs/Meshes/Compression/dracoCompression";
  61575. }
  61576. declare module "babylonjs/Meshes/csg" {
  61577. import { Nullable } from "babylonjs/types";
  61578. import { Scene } from "babylonjs/scene";
  61579. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61580. import { Mesh } from "babylonjs/Meshes/mesh";
  61581. import { Material } from "babylonjs/Materials/material";
  61582. /**
  61583. * Class for building Constructive Solid Geometry
  61584. */
  61585. export class CSG {
  61586. private polygons;
  61587. /**
  61588. * The world matrix
  61589. */
  61590. matrix: Matrix;
  61591. /**
  61592. * Stores the position
  61593. */
  61594. position: Vector3;
  61595. /**
  61596. * Stores the rotation
  61597. */
  61598. rotation: Vector3;
  61599. /**
  61600. * Stores the rotation quaternion
  61601. */
  61602. rotationQuaternion: Nullable<Quaternion>;
  61603. /**
  61604. * Stores the scaling vector
  61605. */
  61606. scaling: Vector3;
  61607. /**
  61608. * Convert the Mesh to CSG
  61609. * @param mesh The Mesh to convert to CSG
  61610. * @returns A new CSG from the Mesh
  61611. */
  61612. static FromMesh(mesh: Mesh): CSG;
  61613. /**
  61614. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61615. * @param polygons Polygons used to construct a CSG solid
  61616. */
  61617. private static FromPolygons;
  61618. /**
  61619. * Clones, or makes a deep copy, of the CSG
  61620. * @returns A new CSG
  61621. */
  61622. clone(): CSG;
  61623. /**
  61624. * Unions this CSG with another CSG
  61625. * @param csg The CSG to union against this CSG
  61626. * @returns The unioned CSG
  61627. */
  61628. union(csg: CSG): CSG;
  61629. /**
  61630. * Unions this CSG with another CSG in place
  61631. * @param csg The CSG to union against this CSG
  61632. */
  61633. unionInPlace(csg: CSG): void;
  61634. /**
  61635. * Subtracts this CSG with another CSG
  61636. * @param csg The CSG to subtract against this CSG
  61637. * @returns A new CSG
  61638. */
  61639. subtract(csg: CSG): CSG;
  61640. /**
  61641. * Subtracts this CSG with another CSG in place
  61642. * @param csg The CSG to subtact against this CSG
  61643. */
  61644. subtractInPlace(csg: CSG): void;
  61645. /**
  61646. * Intersect this CSG with another CSG
  61647. * @param csg The CSG to intersect against this CSG
  61648. * @returns A new CSG
  61649. */
  61650. intersect(csg: CSG): CSG;
  61651. /**
  61652. * Intersects this CSG with another CSG in place
  61653. * @param csg The CSG to intersect against this CSG
  61654. */
  61655. intersectInPlace(csg: CSG): void;
  61656. /**
  61657. * Return a new CSG solid with solid and empty space switched. This solid is
  61658. * not modified.
  61659. * @returns A new CSG solid with solid and empty space switched
  61660. */
  61661. inverse(): CSG;
  61662. /**
  61663. * Inverses the CSG in place
  61664. */
  61665. inverseInPlace(): void;
  61666. /**
  61667. * This is used to keep meshes transformations so they can be restored
  61668. * when we build back a Babylon Mesh
  61669. * NB : All CSG operations are performed in world coordinates
  61670. * @param csg The CSG to copy the transform attributes from
  61671. * @returns This CSG
  61672. */
  61673. copyTransformAttributes(csg: CSG): CSG;
  61674. /**
  61675. * Build Raw mesh from CSG
  61676. * Coordinates here are in world space
  61677. * @param name The name of the mesh geometry
  61678. * @param scene The Scene
  61679. * @param keepSubMeshes Specifies if the submeshes should be kept
  61680. * @returns A new Mesh
  61681. */
  61682. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61683. /**
  61684. * Build Mesh from CSG taking material and transforms into account
  61685. * @param name The name of the Mesh
  61686. * @param material The material of the Mesh
  61687. * @param scene The Scene
  61688. * @param keepSubMeshes Specifies if submeshes should be kept
  61689. * @returns The new Mesh
  61690. */
  61691. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61692. }
  61693. }
  61694. declare module "babylonjs/Meshes/trailMesh" {
  61695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61696. import { Mesh } from "babylonjs/Meshes/mesh";
  61697. import { Scene } from "babylonjs/scene";
  61698. /**
  61699. * Class used to create a trail following a mesh
  61700. */
  61701. export class TrailMesh extends Mesh {
  61702. private _generator;
  61703. private _autoStart;
  61704. private _running;
  61705. private _diameter;
  61706. private _length;
  61707. private _sectionPolygonPointsCount;
  61708. private _sectionVectors;
  61709. private _sectionNormalVectors;
  61710. private _beforeRenderObserver;
  61711. /**
  61712. * @constructor
  61713. * @param name The value used by scene.getMeshByName() to do a lookup.
  61714. * @param generator The mesh to generate a trail.
  61715. * @param scene The scene to add this mesh to.
  61716. * @param diameter Diameter of trailing mesh. Default is 1.
  61717. * @param length Length of trailing mesh. Default is 60.
  61718. * @param autoStart Automatically start trailing mesh. Default true.
  61719. */
  61720. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61721. /**
  61722. * "TrailMesh"
  61723. * @returns "TrailMesh"
  61724. */
  61725. getClassName(): string;
  61726. private _createMesh;
  61727. /**
  61728. * Start trailing mesh.
  61729. */
  61730. start(): void;
  61731. /**
  61732. * Stop trailing mesh.
  61733. */
  61734. stop(): void;
  61735. /**
  61736. * Update trailing mesh geometry.
  61737. */
  61738. update(): void;
  61739. /**
  61740. * Returns a new TrailMesh object.
  61741. * @param name is a string, the name given to the new mesh
  61742. * @param newGenerator use new generator object for cloned trail mesh
  61743. * @returns a new mesh
  61744. */
  61745. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  61746. /**
  61747. * Serializes this trail mesh
  61748. * @param serializationObject object to write serialization to
  61749. */
  61750. serialize(serializationObject: any): void;
  61751. /**
  61752. * Parses a serialized trail mesh
  61753. * @param parsedMesh the serialized mesh
  61754. * @param scene the scene to create the trail mesh in
  61755. * @returns the created trail mesh
  61756. */
  61757. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61758. }
  61759. }
  61760. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  61761. import { Nullable } from "babylonjs/types";
  61762. import { Scene } from "babylonjs/scene";
  61763. import { Vector4 } from "babylonjs/Maths/math.vector";
  61764. import { Color4 } from "babylonjs/Maths/math.color";
  61765. import { Mesh } from "babylonjs/Meshes/mesh";
  61766. /**
  61767. * Class containing static functions to help procedurally build meshes
  61768. */
  61769. export class TiledBoxBuilder {
  61770. /**
  61771. * Creates a box mesh
  61772. * 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)
  61773. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61777. * @param name defines the name of the mesh
  61778. * @param options defines the options used to create the mesh
  61779. * @param scene defines the hosting scene
  61780. * @returns the box mesh
  61781. */
  61782. static CreateTiledBox(name: string, options: {
  61783. pattern?: number;
  61784. width?: number;
  61785. height?: number;
  61786. depth?: number;
  61787. tileSize?: number;
  61788. tileWidth?: number;
  61789. tileHeight?: number;
  61790. alignHorizontal?: number;
  61791. alignVertical?: number;
  61792. faceUV?: Vector4[];
  61793. faceColors?: Color4[];
  61794. sideOrientation?: number;
  61795. updatable?: boolean;
  61796. }, scene?: Nullable<Scene>): Mesh;
  61797. }
  61798. }
  61799. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  61800. import { Vector4 } from "babylonjs/Maths/math.vector";
  61801. import { Mesh } from "babylonjs/Meshes/mesh";
  61802. /**
  61803. * Class containing static functions to help procedurally build meshes
  61804. */
  61805. export class TorusKnotBuilder {
  61806. /**
  61807. * Creates a torus knot mesh
  61808. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61809. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61810. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61811. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61815. * @param name defines the name of the mesh
  61816. * @param options defines the options used to create the mesh
  61817. * @param scene defines the hosting scene
  61818. * @returns the torus knot mesh
  61819. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61820. */
  61821. static CreateTorusKnot(name: string, options: {
  61822. radius?: number;
  61823. tube?: number;
  61824. radialSegments?: number;
  61825. tubularSegments?: number;
  61826. p?: number;
  61827. q?: number;
  61828. updatable?: boolean;
  61829. sideOrientation?: number;
  61830. frontUVs?: Vector4;
  61831. backUVs?: Vector4;
  61832. }, scene: any): Mesh;
  61833. }
  61834. }
  61835. declare module "babylonjs/Meshes/polygonMesh" {
  61836. import { Scene } from "babylonjs/scene";
  61837. import { Vector2 } from "babylonjs/Maths/math.vector";
  61838. import { Mesh } from "babylonjs/Meshes/mesh";
  61839. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61840. import { Path2 } from "babylonjs/Maths/math.path";
  61841. /**
  61842. * Polygon
  61843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61844. */
  61845. export class Polygon {
  61846. /**
  61847. * Creates a rectangle
  61848. * @param xmin bottom X coord
  61849. * @param ymin bottom Y coord
  61850. * @param xmax top X coord
  61851. * @param ymax top Y coord
  61852. * @returns points that make the resulting rectation
  61853. */
  61854. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61855. /**
  61856. * Creates a circle
  61857. * @param radius radius of circle
  61858. * @param cx scale in x
  61859. * @param cy scale in y
  61860. * @param numberOfSides number of sides that make up the circle
  61861. * @returns points that make the resulting circle
  61862. */
  61863. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61864. /**
  61865. * Creates a polygon from input string
  61866. * @param input Input polygon data
  61867. * @returns the parsed points
  61868. */
  61869. static Parse(input: string): Vector2[];
  61870. /**
  61871. * Starts building a polygon from x and y coordinates
  61872. * @param x x coordinate
  61873. * @param y y coordinate
  61874. * @returns the started path2
  61875. */
  61876. static StartingAt(x: number, y: number): Path2;
  61877. }
  61878. /**
  61879. * Builds a polygon
  61880. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61881. */
  61882. export class PolygonMeshBuilder {
  61883. private _points;
  61884. private _outlinepoints;
  61885. private _holes;
  61886. private _name;
  61887. private _scene;
  61888. private _epoints;
  61889. private _eholes;
  61890. private _addToepoint;
  61891. /**
  61892. * Babylon reference to the earcut plugin.
  61893. */
  61894. bjsEarcut: any;
  61895. /**
  61896. * Creates a PolygonMeshBuilder
  61897. * @param name name of the builder
  61898. * @param contours Path of the polygon
  61899. * @param scene scene to add to when creating the mesh
  61900. * @param earcutInjection can be used to inject your own earcut reference
  61901. */
  61902. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61903. /**
  61904. * Adds a whole within the polygon
  61905. * @param hole Array of points defining the hole
  61906. * @returns this
  61907. */
  61908. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61909. /**
  61910. * Creates the polygon
  61911. * @param updatable If the mesh should be updatable
  61912. * @param depth The depth of the mesh created
  61913. * @returns the created mesh
  61914. */
  61915. build(updatable?: boolean, depth?: number): Mesh;
  61916. /**
  61917. * Creates the polygon
  61918. * @param depth The depth of the mesh created
  61919. * @returns the created VertexData
  61920. */
  61921. buildVertexData(depth?: number): VertexData;
  61922. /**
  61923. * Adds a side to the polygon
  61924. * @param positions points that make the polygon
  61925. * @param normals normals of the polygon
  61926. * @param uvs uvs of the polygon
  61927. * @param indices indices of the polygon
  61928. * @param bounds bounds of the polygon
  61929. * @param points points of the polygon
  61930. * @param depth depth of the polygon
  61931. * @param flip flip of the polygon
  61932. */
  61933. private addSide;
  61934. }
  61935. }
  61936. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  61937. import { Scene } from "babylonjs/scene";
  61938. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61939. import { Color4 } from "babylonjs/Maths/math.color";
  61940. import { Mesh } from "babylonjs/Meshes/mesh";
  61941. import { Nullable } from "babylonjs/types";
  61942. /**
  61943. * Class containing static functions to help procedurally build meshes
  61944. */
  61945. export class PolygonBuilder {
  61946. /**
  61947. * Creates a polygon mesh
  61948. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61949. * * 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
  61950. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61953. * * Remember you can only change the shape positions, not their number when updating a polygon
  61954. * @param name defines the name of the mesh
  61955. * @param options defines the options used to create the mesh
  61956. * @param scene defines the hosting scene
  61957. * @param earcutInjection can be used to inject your own earcut reference
  61958. * @returns the polygon mesh
  61959. */
  61960. static CreatePolygon(name: string, options: {
  61961. shape: Vector3[];
  61962. holes?: Vector3[][];
  61963. depth?: number;
  61964. faceUV?: Vector4[];
  61965. faceColors?: Color4[];
  61966. updatable?: boolean;
  61967. sideOrientation?: number;
  61968. frontUVs?: Vector4;
  61969. backUVs?: Vector4;
  61970. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61971. /**
  61972. * Creates an extruded polygon mesh, with depth in the Y direction.
  61973. * * 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)
  61974. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61975. * @param name defines the name of the mesh
  61976. * @param options defines the options used to create the mesh
  61977. * @param scene defines the hosting scene
  61978. * @param earcutInjection can be used to inject your own earcut reference
  61979. * @returns the polygon mesh
  61980. */
  61981. static ExtrudePolygon(name: string, options: {
  61982. shape: Vector3[];
  61983. holes?: Vector3[][];
  61984. depth?: number;
  61985. faceUV?: Vector4[];
  61986. faceColors?: Color4[];
  61987. updatable?: boolean;
  61988. sideOrientation?: number;
  61989. frontUVs?: Vector4;
  61990. backUVs?: Vector4;
  61991. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61992. }
  61993. }
  61994. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  61995. import { Scene } from "babylonjs/scene";
  61996. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61997. import { Mesh } from "babylonjs/Meshes/mesh";
  61998. import { Nullable } from "babylonjs/types";
  61999. /**
  62000. * Class containing static functions to help procedurally build meshes
  62001. */
  62002. export class LatheBuilder {
  62003. /**
  62004. * Creates lathe mesh.
  62005. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62006. * * 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
  62007. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62008. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62009. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62010. * * 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
  62011. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62012. * * 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
  62013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62017. * @param name defines the name of the mesh
  62018. * @param options defines the options used to create the mesh
  62019. * @param scene defines the hosting scene
  62020. * @returns the lathe mesh
  62021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62022. */
  62023. static CreateLathe(name: string, options: {
  62024. shape: Vector3[];
  62025. radius?: number;
  62026. tessellation?: number;
  62027. clip?: number;
  62028. arc?: number;
  62029. closed?: boolean;
  62030. updatable?: boolean;
  62031. sideOrientation?: number;
  62032. frontUVs?: Vector4;
  62033. backUVs?: Vector4;
  62034. cap?: number;
  62035. invertUV?: boolean;
  62036. }, scene?: Nullable<Scene>): Mesh;
  62037. }
  62038. }
  62039. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62040. import { Nullable } from "babylonjs/types";
  62041. import { Scene } from "babylonjs/scene";
  62042. import { Vector4 } from "babylonjs/Maths/math.vector";
  62043. import { Mesh } from "babylonjs/Meshes/mesh";
  62044. /**
  62045. * Class containing static functions to help procedurally build meshes
  62046. */
  62047. export class TiledPlaneBuilder {
  62048. /**
  62049. * Creates a tiled plane mesh
  62050. * * The parameter `pattern` will, depending on value, do nothing or
  62051. * * * flip (reflect about central vertical) alternate tiles across and up
  62052. * * * flip every tile on alternate rows
  62053. * * * rotate (180 degs) alternate tiles across and up
  62054. * * * rotate every tile on alternate rows
  62055. * * * flip and rotate alternate tiles across and up
  62056. * * * flip and rotate every tile on alternate rows
  62057. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62058. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62061. * * 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)
  62062. * * 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)
  62063. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62064. * @param name defines the name of the mesh
  62065. * @param options defines the options used to create the mesh
  62066. * @param scene defines the hosting scene
  62067. * @returns the box mesh
  62068. */
  62069. static CreateTiledPlane(name: string, options: {
  62070. pattern?: number;
  62071. tileSize?: number;
  62072. tileWidth?: number;
  62073. tileHeight?: number;
  62074. size?: number;
  62075. width?: number;
  62076. height?: number;
  62077. alignHorizontal?: number;
  62078. alignVertical?: number;
  62079. sideOrientation?: number;
  62080. frontUVs?: Vector4;
  62081. backUVs?: Vector4;
  62082. updatable?: boolean;
  62083. }, scene?: Nullable<Scene>): Mesh;
  62084. }
  62085. }
  62086. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62087. import { Nullable } from "babylonjs/types";
  62088. import { Scene } from "babylonjs/scene";
  62089. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62090. import { Mesh } from "babylonjs/Meshes/mesh";
  62091. /**
  62092. * Class containing static functions to help procedurally build meshes
  62093. */
  62094. export class TubeBuilder {
  62095. /**
  62096. * Creates a tube mesh.
  62097. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62098. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62099. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62100. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62101. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62102. * * 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)
  62103. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62104. * * 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
  62105. * * 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
  62106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62108. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62110. * @param name defines the name of the mesh
  62111. * @param options defines the options used to create the mesh
  62112. * @param scene defines the hosting scene
  62113. * @returns the tube mesh
  62114. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62115. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62116. */
  62117. static CreateTube(name: string, options: {
  62118. path: Vector3[];
  62119. radius?: number;
  62120. tessellation?: number;
  62121. radiusFunction?: {
  62122. (i: number, distance: number): number;
  62123. };
  62124. cap?: number;
  62125. arc?: number;
  62126. updatable?: boolean;
  62127. sideOrientation?: number;
  62128. frontUVs?: Vector4;
  62129. backUVs?: Vector4;
  62130. instance?: Mesh;
  62131. invertUV?: boolean;
  62132. }, scene?: Nullable<Scene>): Mesh;
  62133. }
  62134. }
  62135. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62136. import { Scene } from "babylonjs/scene";
  62137. import { Vector4 } from "babylonjs/Maths/math.vector";
  62138. import { Mesh } from "babylonjs/Meshes/mesh";
  62139. import { Nullable } from "babylonjs/types";
  62140. /**
  62141. * Class containing static functions to help procedurally build meshes
  62142. */
  62143. export class IcoSphereBuilder {
  62144. /**
  62145. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62146. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62147. * * 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`)
  62148. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62149. * * 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
  62150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62153. * @param name defines the name of the mesh
  62154. * @param options defines the options used to create the mesh
  62155. * @param scene defines the hosting scene
  62156. * @returns the icosahedron mesh
  62157. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62158. */
  62159. static CreateIcoSphere(name: string, options: {
  62160. radius?: number;
  62161. radiusX?: number;
  62162. radiusY?: number;
  62163. radiusZ?: number;
  62164. flat?: boolean;
  62165. subdivisions?: number;
  62166. sideOrientation?: number;
  62167. frontUVs?: Vector4;
  62168. backUVs?: Vector4;
  62169. updatable?: boolean;
  62170. }, scene?: Nullable<Scene>): Mesh;
  62171. }
  62172. }
  62173. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62174. import { Vector3 } from "babylonjs/Maths/math.vector";
  62175. import { Mesh } from "babylonjs/Meshes/mesh";
  62176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62177. /**
  62178. * Class containing static functions to help procedurally build meshes
  62179. */
  62180. export class DecalBuilder {
  62181. /**
  62182. * Creates a decal mesh.
  62183. * 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
  62184. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62185. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62186. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62187. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62188. * @param name defines the name of the mesh
  62189. * @param sourceMesh defines the mesh where the decal must be applied
  62190. * @param options defines the options used to create the mesh
  62191. * @param scene defines the hosting scene
  62192. * @returns the decal mesh
  62193. * @see https://doc.babylonjs.com/how_to/decals
  62194. */
  62195. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62196. position?: Vector3;
  62197. normal?: Vector3;
  62198. size?: Vector3;
  62199. angle?: number;
  62200. }): Mesh;
  62201. }
  62202. }
  62203. declare module "babylonjs/Meshes/meshBuilder" {
  62204. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  62205. import { Nullable } from "babylonjs/types";
  62206. import { Scene } from "babylonjs/scene";
  62207. import { Mesh } from "babylonjs/Meshes/mesh";
  62208. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  62209. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  62210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62211. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62212. import { Plane } from "babylonjs/Maths/math.plane";
  62213. /**
  62214. * Class containing static functions to help procedurally build meshes
  62215. */
  62216. export class MeshBuilder {
  62217. /**
  62218. * Creates a box mesh
  62219. * * The parameter `size` sets the size (float) of each box side (default 1)
  62220. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62221. * * 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)
  62222. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62226. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62227. * @param name defines the name of the mesh
  62228. * @param options defines the options used to create the mesh
  62229. * @param scene defines the hosting scene
  62230. * @returns the box mesh
  62231. */
  62232. static CreateBox(name: string, options: {
  62233. size?: number;
  62234. width?: number;
  62235. height?: number;
  62236. depth?: number;
  62237. faceUV?: Vector4[];
  62238. faceColors?: Color4[];
  62239. sideOrientation?: number;
  62240. frontUVs?: Vector4;
  62241. backUVs?: Vector4;
  62242. updatable?: boolean;
  62243. }, scene?: Nullable<Scene>): Mesh;
  62244. /**
  62245. * Creates a tiled box mesh
  62246. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62248. * @param name defines the name of the mesh
  62249. * @param options defines the options used to create the mesh
  62250. * @param scene defines the hosting scene
  62251. * @returns the tiled box mesh
  62252. */
  62253. static CreateTiledBox(name: string, options: {
  62254. pattern?: number;
  62255. size?: number;
  62256. width?: number;
  62257. height?: number;
  62258. depth: number;
  62259. tileSize?: number;
  62260. tileWidth?: number;
  62261. tileHeight?: number;
  62262. faceUV?: Vector4[];
  62263. faceColors?: Color4[];
  62264. alignHorizontal?: number;
  62265. alignVertical?: number;
  62266. sideOrientation?: number;
  62267. updatable?: boolean;
  62268. }, scene?: Nullable<Scene>): Mesh;
  62269. /**
  62270. * Creates a sphere mesh
  62271. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62272. * * 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`)
  62273. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62274. * * 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
  62275. * * 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)
  62276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62279. * @param name defines the name of the mesh
  62280. * @param options defines the options used to create the mesh
  62281. * @param scene defines the hosting scene
  62282. * @returns the sphere mesh
  62283. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62284. */
  62285. static CreateSphere(name: string, options: {
  62286. segments?: number;
  62287. diameter?: number;
  62288. diameterX?: number;
  62289. diameterY?: number;
  62290. diameterZ?: number;
  62291. arc?: number;
  62292. slice?: number;
  62293. sideOrientation?: number;
  62294. frontUVs?: Vector4;
  62295. backUVs?: Vector4;
  62296. updatable?: boolean;
  62297. }, scene?: Nullable<Scene>): Mesh;
  62298. /**
  62299. * Creates a plane polygonal mesh. By default, this is a disc
  62300. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  62301. * * 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
  62302. * * 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
  62303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62306. * @param name defines the name of the mesh
  62307. * @param options defines the options used to create the mesh
  62308. * @param scene defines the hosting scene
  62309. * @returns the plane polygonal mesh
  62310. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  62311. */
  62312. static CreateDisc(name: string, options: {
  62313. radius?: number;
  62314. tessellation?: number;
  62315. arc?: number;
  62316. updatable?: boolean;
  62317. sideOrientation?: number;
  62318. frontUVs?: Vector4;
  62319. backUVs?: Vector4;
  62320. }, scene?: Nullable<Scene>): Mesh;
  62321. /**
  62322. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62323. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62324. * * 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`)
  62325. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62326. * * 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
  62327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62330. * @param name defines the name of the mesh
  62331. * @param options defines the options used to create the mesh
  62332. * @param scene defines the hosting scene
  62333. * @returns the icosahedron mesh
  62334. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62335. */
  62336. static CreateIcoSphere(name: string, options: {
  62337. radius?: number;
  62338. radiusX?: number;
  62339. radiusY?: number;
  62340. radiusZ?: number;
  62341. flat?: boolean;
  62342. subdivisions?: number;
  62343. sideOrientation?: number;
  62344. frontUVs?: Vector4;
  62345. backUVs?: Vector4;
  62346. updatable?: boolean;
  62347. }, scene?: Nullable<Scene>): Mesh;
  62348. /**
  62349. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62350. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62351. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62352. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62353. * * 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
  62354. * * 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
  62355. * * 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
  62356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62358. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62359. * * 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
  62360. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62361. * * 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
  62362. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62364. * @param name defines the name of the mesh
  62365. * @param options defines the options used to create the mesh
  62366. * @param scene defines the hosting scene
  62367. * @returns the ribbon mesh
  62368. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62369. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62370. */
  62371. static CreateRibbon(name: string, options: {
  62372. pathArray: Vector3[][];
  62373. closeArray?: boolean;
  62374. closePath?: boolean;
  62375. offset?: number;
  62376. updatable?: boolean;
  62377. sideOrientation?: number;
  62378. frontUVs?: Vector4;
  62379. backUVs?: Vector4;
  62380. instance?: Mesh;
  62381. invertUV?: boolean;
  62382. uvs?: Vector2[];
  62383. colors?: Color4[];
  62384. }, scene?: Nullable<Scene>): Mesh;
  62385. /**
  62386. * Creates a cylinder or a cone mesh
  62387. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  62388. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  62389. * * 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.
  62390. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  62391. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  62392. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  62393. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  62394. * * 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).
  62395. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  62396. * * 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).
  62397. * * 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
  62398. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  62399. * * 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
  62400. * * 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.
  62401. * * If `enclose` is false, a ring surface is one element.
  62402. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  62403. * * 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
  62404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62407. * @param name defines the name of the mesh
  62408. * @param options defines the options used to create the mesh
  62409. * @param scene defines the hosting scene
  62410. * @returns the cylinder mesh
  62411. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  62412. */
  62413. static CreateCylinder(name: string, options: {
  62414. height?: number;
  62415. diameterTop?: number;
  62416. diameterBottom?: number;
  62417. diameter?: number;
  62418. tessellation?: number;
  62419. subdivisions?: number;
  62420. arc?: number;
  62421. faceColors?: Color4[];
  62422. faceUV?: Vector4[];
  62423. updatable?: boolean;
  62424. hasRings?: boolean;
  62425. enclose?: boolean;
  62426. cap?: number;
  62427. sideOrientation?: number;
  62428. frontUVs?: Vector4;
  62429. backUVs?: Vector4;
  62430. }, scene?: Nullable<Scene>): Mesh;
  62431. /**
  62432. * Creates a torus mesh
  62433. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  62434. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  62435. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  62436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62439. * @param name defines the name of the mesh
  62440. * @param options defines the options used to create the mesh
  62441. * @param scene defines the hosting scene
  62442. * @returns the torus mesh
  62443. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  62444. */
  62445. static CreateTorus(name: string, options: {
  62446. diameter?: number;
  62447. thickness?: number;
  62448. tessellation?: number;
  62449. updatable?: boolean;
  62450. sideOrientation?: number;
  62451. frontUVs?: Vector4;
  62452. backUVs?: Vector4;
  62453. }, scene?: Nullable<Scene>): Mesh;
  62454. /**
  62455. * Creates a torus knot mesh
  62456. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62457. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62458. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62459. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62463. * @param name defines the name of the mesh
  62464. * @param options defines the options used to create the mesh
  62465. * @param scene defines the hosting scene
  62466. * @returns the torus knot mesh
  62467. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62468. */
  62469. static CreateTorusKnot(name: string, options: {
  62470. radius?: number;
  62471. tube?: number;
  62472. radialSegments?: number;
  62473. tubularSegments?: number;
  62474. p?: number;
  62475. q?: number;
  62476. updatable?: boolean;
  62477. sideOrientation?: number;
  62478. frontUVs?: Vector4;
  62479. backUVs?: Vector4;
  62480. }, scene?: Nullable<Scene>): Mesh;
  62481. /**
  62482. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62483. * * 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
  62484. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62485. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62486. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62487. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62488. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62489. * * 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
  62490. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62493. * @param name defines the name of the new line system
  62494. * @param options defines the options used to create the line system
  62495. * @param scene defines the hosting scene
  62496. * @returns a new line system mesh
  62497. */
  62498. static CreateLineSystem(name: string, options: {
  62499. lines: Vector3[][];
  62500. updatable?: boolean;
  62501. instance?: Nullable<LinesMesh>;
  62502. colors?: Nullable<Color4[][]>;
  62503. useVertexAlpha?: boolean;
  62504. }, scene: Nullable<Scene>): LinesMesh;
  62505. /**
  62506. * Creates a line mesh
  62507. * 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
  62508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62509. * * The parameter `points` is an array successive Vector3
  62510. * * 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
  62511. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62512. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62513. * * When updating an instance, remember that only point positions can change, not the number of points
  62514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62516. * @param name defines the name of the new line system
  62517. * @param options defines the options used to create the line system
  62518. * @param scene defines the hosting scene
  62519. * @returns a new line mesh
  62520. */
  62521. static CreateLines(name: string, options: {
  62522. points: Vector3[];
  62523. updatable?: boolean;
  62524. instance?: Nullable<LinesMesh>;
  62525. colors?: Color4[];
  62526. useVertexAlpha?: boolean;
  62527. }, scene?: Nullable<Scene>): LinesMesh;
  62528. /**
  62529. * Creates a dashed line mesh
  62530. * * 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
  62531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62532. * * The parameter `points` is an array successive Vector3
  62533. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62534. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62535. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62536. * * 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
  62537. * * When updating an instance, remember that only point positions can change, not the number of points
  62538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62539. * @param name defines the name of the mesh
  62540. * @param options defines the options used to create the mesh
  62541. * @param scene defines the hosting scene
  62542. * @returns the dashed line mesh
  62543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62544. */
  62545. static CreateDashedLines(name: string, options: {
  62546. points: Vector3[];
  62547. dashSize?: number;
  62548. gapSize?: number;
  62549. dashNb?: number;
  62550. updatable?: boolean;
  62551. instance?: LinesMesh;
  62552. }, scene?: Nullable<Scene>): LinesMesh;
  62553. /**
  62554. * 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.
  62555. * * 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.
  62556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62557. * * 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.
  62558. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62559. * * 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
  62560. * * 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
  62561. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62566. * @param name defines the name of the mesh
  62567. * @param options defines the options used to create the mesh
  62568. * @param scene defines the hosting scene
  62569. * @returns the extruded shape mesh
  62570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62572. */
  62573. static ExtrudeShape(name: string, options: {
  62574. shape: Vector3[];
  62575. path: Vector3[];
  62576. scale?: number;
  62577. rotation?: number;
  62578. cap?: number;
  62579. updatable?: boolean;
  62580. sideOrientation?: number;
  62581. frontUVs?: Vector4;
  62582. backUVs?: Vector4;
  62583. instance?: Mesh;
  62584. invertUV?: boolean;
  62585. }, scene?: Nullable<Scene>): Mesh;
  62586. /**
  62587. * Creates an custom extruded shape mesh.
  62588. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62589. * * 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.
  62590. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62591. * * 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
  62592. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62593. * * 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
  62594. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62595. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62596. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62597. * * 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
  62598. * * 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
  62599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62604. * @param name defines the name of the mesh
  62605. * @param options defines the options used to create the mesh
  62606. * @param scene defines the hosting scene
  62607. * @returns the custom extruded shape mesh
  62608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62611. */
  62612. static ExtrudeShapeCustom(name: string, options: {
  62613. shape: Vector3[];
  62614. path: Vector3[];
  62615. scaleFunction?: any;
  62616. rotationFunction?: any;
  62617. ribbonCloseArray?: boolean;
  62618. ribbonClosePath?: boolean;
  62619. cap?: number;
  62620. updatable?: boolean;
  62621. sideOrientation?: number;
  62622. frontUVs?: Vector4;
  62623. backUVs?: Vector4;
  62624. instance?: Mesh;
  62625. invertUV?: boolean;
  62626. }, scene?: Nullable<Scene>): Mesh;
  62627. /**
  62628. * Creates lathe mesh.
  62629. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62630. * * 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
  62631. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62632. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62633. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62634. * * 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
  62635. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62636. * * 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
  62637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62641. * @param name defines the name of the mesh
  62642. * @param options defines the options used to create the mesh
  62643. * @param scene defines the hosting scene
  62644. * @returns the lathe mesh
  62645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62646. */
  62647. static CreateLathe(name: string, options: {
  62648. shape: Vector3[];
  62649. radius?: number;
  62650. tessellation?: number;
  62651. clip?: number;
  62652. arc?: number;
  62653. closed?: boolean;
  62654. updatable?: boolean;
  62655. sideOrientation?: number;
  62656. frontUVs?: Vector4;
  62657. backUVs?: Vector4;
  62658. cap?: number;
  62659. invertUV?: boolean;
  62660. }, scene?: Nullable<Scene>): Mesh;
  62661. /**
  62662. * Creates a tiled plane mesh
  62663. * * You can set a limited pattern arrangement with the tiles
  62664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62667. * @param name defines the name of the mesh
  62668. * @param options defines the options used to create the mesh
  62669. * @param scene defines the hosting scene
  62670. * @returns the plane mesh
  62671. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62672. */
  62673. static CreateTiledPlane(name: string, options: {
  62674. pattern?: number;
  62675. tileSize?: number;
  62676. tileWidth?: number;
  62677. tileHeight?: number;
  62678. size?: number;
  62679. width?: number;
  62680. height?: number;
  62681. alignHorizontal?: number;
  62682. alignVertical?: number;
  62683. sideOrientation?: number;
  62684. frontUVs?: Vector4;
  62685. backUVs?: Vector4;
  62686. updatable?: boolean;
  62687. }, scene?: Nullable<Scene>): Mesh;
  62688. /**
  62689. * Creates a plane mesh
  62690. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62691. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62692. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62696. * @param name defines the name of the mesh
  62697. * @param options defines the options used to create the mesh
  62698. * @param scene defines the hosting scene
  62699. * @returns the plane mesh
  62700. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62701. */
  62702. static CreatePlane(name: string, options: {
  62703. size?: number;
  62704. width?: number;
  62705. height?: number;
  62706. sideOrientation?: number;
  62707. frontUVs?: Vector4;
  62708. backUVs?: Vector4;
  62709. updatable?: boolean;
  62710. sourcePlane?: Plane;
  62711. }, scene?: Nullable<Scene>): Mesh;
  62712. /**
  62713. * Creates a ground mesh
  62714. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62715. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62717. * @param name defines the name of the mesh
  62718. * @param options defines the options used to create the mesh
  62719. * @param scene defines the hosting scene
  62720. * @returns the ground mesh
  62721. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62722. */
  62723. static CreateGround(name: string, options: {
  62724. width?: number;
  62725. height?: number;
  62726. subdivisions?: number;
  62727. subdivisionsX?: number;
  62728. subdivisionsY?: number;
  62729. updatable?: boolean;
  62730. }, scene?: Nullable<Scene>): Mesh;
  62731. /**
  62732. * Creates a tiled ground mesh
  62733. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62734. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62735. * * 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
  62736. * * 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
  62737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62738. * @param name defines the name of the mesh
  62739. * @param options defines the options used to create the mesh
  62740. * @param scene defines the hosting scene
  62741. * @returns the tiled ground mesh
  62742. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62743. */
  62744. static CreateTiledGround(name: string, options: {
  62745. xmin: number;
  62746. zmin: number;
  62747. xmax: number;
  62748. zmax: number;
  62749. subdivisions?: {
  62750. w: number;
  62751. h: number;
  62752. };
  62753. precision?: {
  62754. w: number;
  62755. h: number;
  62756. };
  62757. updatable?: boolean;
  62758. }, scene?: Nullable<Scene>): Mesh;
  62759. /**
  62760. * Creates a ground mesh from a height map
  62761. * * The parameter `url` sets the URL of the height map image resource.
  62762. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62763. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62764. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62765. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62766. * * 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.
  62767. * * 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).
  62768. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62770. * @param name defines the name of the mesh
  62771. * @param url defines the url to the height map
  62772. * @param options defines the options used to create the mesh
  62773. * @param scene defines the hosting scene
  62774. * @returns the ground mesh
  62775. * @see https://doc.babylonjs.com/babylon101/height_map
  62776. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62777. */
  62778. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62779. width?: number;
  62780. height?: number;
  62781. subdivisions?: number;
  62782. minHeight?: number;
  62783. maxHeight?: number;
  62784. colorFilter?: Color3;
  62785. alphaFilter?: number;
  62786. updatable?: boolean;
  62787. onReady?: (mesh: GroundMesh) => void;
  62788. }, scene?: Nullable<Scene>): GroundMesh;
  62789. /**
  62790. * Creates a polygon mesh
  62791. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62792. * * 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
  62793. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62796. * * Remember you can only change the shape positions, not their number when updating a polygon
  62797. * @param name defines the name of the mesh
  62798. * @param options defines the options used to create the mesh
  62799. * @param scene defines the hosting scene
  62800. * @param earcutInjection can be used to inject your own earcut reference
  62801. * @returns the polygon mesh
  62802. */
  62803. static CreatePolygon(name: string, options: {
  62804. shape: Vector3[];
  62805. holes?: Vector3[][];
  62806. depth?: number;
  62807. faceUV?: Vector4[];
  62808. faceColors?: Color4[];
  62809. updatable?: boolean;
  62810. sideOrientation?: number;
  62811. frontUVs?: Vector4;
  62812. backUVs?: Vector4;
  62813. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62814. /**
  62815. * Creates an extruded polygon mesh, with depth in the Y direction.
  62816. * * 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)
  62817. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62818. * @param name defines the name of the mesh
  62819. * @param options defines the options used to create the mesh
  62820. * @param scene defines the hosting scene
  62821. * @param earcutInjection can be used to inject your own earcut reference
  62822. * @returns the polygon mesh
  62823. */
  62824. static ExtrudePolygon(name: string, options: {
  62825. shape: Vector3[];
  62826. holes?: Vector3[][];
  62827. depth?: number;
  62828. faceUV?: Vector4[];
  62829. faceColors?: Color4[];
  62830. updatable?: boolean;
  62831. sideOrientation?: number;
  62832. frontUVs?: Vector4;
  62833. backUVs?: Vector4;
  62834. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62835. /**
  62836. * Creates a tube mesh.
  62837. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62838. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62839. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62840. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62841. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62842. * * 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)
  62843. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62844. * * 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
  62845. * * 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
  62846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62850. * @param name defines the name of the mesh
  62851. * @param options defines the options used to create the mesh
  62852. * @param scene defines the hosting scene
  62853. * @returns the tube mesh
  62854. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62855. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62856. */
  62857. static CreateTube(name: string, options: {
  62858. path: Vector3[];
  62859. radius?: number;
  62860. tessellation?: number;
  62861. radiusFunction?: {
  62862. (i: number, distance: number): number;
  62863. };
  62864. cap?: number;
  62865. arc?: number;
  62866. updatable?: boolean;
  62867. sideOrientation?: number;
  62868. frontUVs?: Vector4;
  62869. backUVs?: Vector4;
  62870. instance?: Mesh;
  62871. invertUV?: boolean;
  62872. }, scene?: Nullable<Scene>): Mesh;
  62873. /**
  62874. * Creates a polyhedron mesh
  62875. * * 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
  62876. * * The parameter `size` (positive float, default 1) sets the polygon size
  62877. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62878. * * 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`
  62879. * * 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
  62880. * * 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)`)
  62881. * * 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
  62882. * * 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
  62883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62886. * @param name defines the name of the mesh
  62887. * @param options defines the options used to create the mesh
  62888. * @param scene defines the hosting scene
  62889. * @returns the polyhedron mesh
  62890. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62891. */
  62892. static CreatePolyhedron(name: string, options: {
  62893. type?: number;
  62894. size?: number;
  62895. sizeX?: number;
  62896. sizeY?: number;
  62897. sizeZ?: number;
  62898. custom?: any;
  62899. faceUV?: Vector4[];
  62900. faceColors?: Color4[];
  62901. flat?: boolean;
  62902. updatable?: boolean;
  62903. sideOrientation?: number;
  62904. frontUVs?: Vector4;
  62905. backUVs?: Vector4;
  62906. }, scene?: Nullable<Scene>): Mesh;
  62907. /**
  62908. * Creates a decal mesh.
  62909. * 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
  62910. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62911. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62912. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62913. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62914. * @param name defines the name of the mesh
  62915. * @param sourceMesh defines the mesh where the decal must be applied
  62916. * @param options defines the options used to create the mesh
  62917. * @param scene defines the hosting scene
  62918. * @returns the decal mesh
  62919. * @see https://doc.babylonjs.com/how_to/decals
  62920. */
  62921. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62922. position?: Vector3;
  62923. normal?: Vector3;
  62924. size?: Vector3;
  62925. angle?: number;
  62926. }): Mesh;
  62927. }
  62928. }
  62929. declare module "babylonjs/Meshes/meshSimplification" {
  62930. import { Mesh } from "babylonjs/Meshes/mesh";
  62931. /**
  62932. * A simplifier interface for future simplification implementations
  62933. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62934. */
  62935. export interface ISimplifier {
  62936. /**
  62937. * Simplification of a given mesh according to the given settings.
  62938. * Since this requires computation, it is assumed that the function runs async.
  62939. * @param settings The settings of the simplification, including quality and distance
  62940. * @param successCallback A callback that will be called after the mesh was simplified.
  62941. * @param errorCallback in case of an error, this callback will be called. optional.
  62942. */
  62943. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62944. }
  62945. /**
  62946. * Expected simplification settings.
  62947. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62948. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62949. */
  62950. export interface ISimplificationSettings {
  62951. /**
  62952. * Gets or sets the expected quality
  62953. */
  62954. quality: number;
  62955. /**
  62956. * Gets or sets the distance when this optimized version should be used
  62957. */
  62958. distance: number;
  62959. /**
  62960. * Gets an already optimized mesh
  62961. */
  62962. optimizeMesh?: boolean;
  62963. }
  62964. /**
  62965. * Class used to specify simplification options
  62966. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62967. */
  62968. export class SimplificationSettings implements ISimplificationSettings {
  62969. /** expected quality */
  62970. quality: number;
  62971. /** distance when this optimized version should be used */
  62972. distance: number;
  62973. /** already optimized mesh */
  62974. optimizeMesh?: boolean | undefined;
  62975. /**
  62976. * Creates a SimplificationSettings
  62977. * @param quality expected quality
  62978. * @param distance distance when this optimized version should be used
  62979. * @param optimizeMesh already optimized mesh
  62980. */
  62981. constructor(
  62982. /** expected quality */
  62983. quality: number,
  62984. /** distance when this optimized version should be used */
  62985. distance: number,
  62986. /** already optimized mesh */
  62987. optimizeMesh?: boolean | undefined);
  62988. }
  62989. /**
  62990. * Interface used to define a simplification task
  62991. */
  62992. export interface ISimplificationTask {
  62993. /**
  62994. * Array of settings
  62995. */
  62996. settings: Array<ISimplificationSettings>;
  62997. /**
  62998. * Simplification type
  62999. */
  63000. simplificationType: SimplificationType;
  63001. /**
  63002. * Mesh to simplify
  63003. */
  63004. mesh: Mesh;
  63005. /**
  63006. * Callback called on success
  63007. */
  63008. successCallback?: () => void;
  63009. /**
  63010. * Defines if parallel processing can be used
  63011. */
  63012. parallelProcessing: boolean;
  63013. }
  63014. /**
  63015. * Queue used to order the simplification tasks
  63016. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63017. */
  63018. export class SimplificationQueue {
  63019. private _simplificationArray;
  63020. /**
  63021. * Gets a boolean indicating that the process is still running
  63022. */
  63023. running: boolean;
  63024. /**
  63025. * Creates a new queue
  63026. */
  63027. constructor();
  63028. /**
  63029. * Adds a new simplification task
  63030. * @param task defines a task to add
  63031. */
  63032. addTask(task: ISimplificationTask): void;
  63033. /**
  63034. * Execute next task
  63035. */
  63036. executeNext(): void;
  63037. /**
  63038. * Execute a simplification task
  63039. * @param task defines the task to run
  63040. */
  63041. runSimplification(task: ISimplificationTask): void;
  63042. private getSimplifier;
  63043. }
  63044. /**
  63045. * The implemented types of simplification
  63046. * At the moment only Quadratic Error Decimation is implemented
  63047. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63048. */
  63049. export enum SimplificationType {
  63050. /** Quadratic error decimation */
  63051. QUADRATIC = 0
  63052. }
  63053. }
  63054. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63055. import { Scene } from "babylonjs/scene";
  63056. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63057. import { ISceneComponent } from "babylonjs/sceneComponent";
  63058. module "babylonjs/scene" {
  63059. interface Scene {
  63060. /** @hidden (Backing field) */
  63061. _simplificationQueue: SimplificationQueue;
  63062. /**
  63063. * Gets or sets the simplification queue attached to the scene
  63064. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63065. */
  63066. simplificationQueue: SimplificationQueue;
  63067. }
  63068. }
  63069. module "babylonjs/Meshes/mesh" {
  63070. interface Mesh {
  63071. /**
  63072. * Simplify the mesh according to the given array of settings.
  63073. * Function will return immediately and will simplify async
  63074. * @param settings a collection of simplification settings
  63075. * @param parallelProcessing should all levels calculate parallel or one after the other
  63076. * @param simplificationType the type of simplification to run
  63077. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63078. * @returns the current mesh
  63079. */
  63080. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63081. }
  63082. }
  63083. /**
  63084. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63085. * created in a scene
  63086. */
  63087. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63088. /**
  63089. * The component name helpfull to identify the component in the list of scene components.
  63090. */
  63091. readonly name: string;
  63092. /**
  63093. * The scene the component belongs to.
  63094. */
  63095. scene: Scene;
  63096. /**
  63097. * Creates a new instance of the component for the given scene
  63098. * @param scene Defines the scene to register the component in
  63099. */
  63100. constructor(scene: Scene);
  63101. /**
  63102. * Registers the component in a given scene
  63103. */
  63104. register(): void;
  63105. /**
  63106. * Rebuilds the elements related to this component in case of
  63107. * context lost for instance.
  63108. */
  63109. rebuild(): void;
  63110. /**
  63111. * Disposes the component and the associated ressources
  63112. */
  63113. dispose(): void;
  63114. private _beforeCameraUpdate;
  63115. }
  63116. }
  63117. declare module "babylonjs/Meshes/Builders/index" {
  63118. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63119. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63120. export * from "babylonjs/Meshes/Builders/discBuilder";
  63121. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63122. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63123. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63124. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63125. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63126. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63127. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63128. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63129. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63130. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63131. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63132. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63133. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63134. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63135. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63136. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63137. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63138. }
  63139. declare module "babylonjs/Meshes/index" {
  63140. export * from "babylonjs/Meshes/abstractMesh";
  63141. export * from "babylonjs/Meshes/buffer";
  63142. export * from "babylonjs/Meshes/Compression/index";
  63143. export * from "babylonjs/Meshes/csg";
  63144. export * from "babylonjs/Meshes/geometry";
  63145. export * from "babylonjs/Meshes/groundMesh";
  63146. export * from "babylonjs/Meshes/trailMesh";
  63147. export * from "babylonjs/Meshes/instancedMesh";
  63148. export * from "babylonjs/Meshes/linesMesh";
  63149. export * from "babylonjs/Meshes/mesh";
  63150. export * from "babylonjs/Meshes/mesh.vertexData";
  63151. export * from "babylonjs/Meshes/meshBuilder";
  63152. export * from "babylonjs/Meshes/meshSimplification";
  63153. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63154. export * from "babylonjs/Meshes/polygonMesh";
  63155. export * from "babylonjs/Meshes/subMesh";
  63156. export * from "babylonjs/Meshes/meshLODLevel";
  63157. export * from "babylonjs/Meshes/transformNode";
  63158. export * from "babylonjs/Meshes/Builders/index";
  63159. export * from "babylonjs/Meshes/dataBuffer";
  63160. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63161. }
  63162. declare module "babylonjs/Morph/index" {
  63163. export * from "babylonjs/Morph/morphTarget";
  63164. export * from "babylonjs/Morph/morphTargetManager";
  63165. }
  63166. declare module "babylonjs/Navigation/INavigationEngine" {
  63167. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63168. import { Vector3 } from "babylonjs/Maths/math";
  63169. import { Mesh } from "babylonjs/Meshes/mesh";
  63170. import { Scene } from "babylonjs/scene";
  63171. /**
  63172. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63173. */
  63174. export interface INavigationEnginePlugin {
  63175. /**
  63176. * plugin name
  63177. */
  63178. name: string;
  63179. /**
  63180. * Creates a navigation mesh
  63181. * @param meshes array of all the geometry used to compute the navigatio mesh
  63182. * @param parameters bunch of parameters used to filter geometry
  63183. */
  63184. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63185. /**
  63186. * Create a navigation mesh debug mesh
  63187. * @param scene is where the mesh will be added
  63188. * @returns debug display mesh
  63189. */
  63190. createDebugNavMesh(scene: Scene): Mesh;
  63191. /**
  63192. * Get a navigation mesh constrained position, closest to the parameter position
  63193. * @param position world position
  63194. * @returns the closest point to position constrained by the navigation mesh
  63195. */
  63196. getClosestPoint(position: Vector3): Vector3;
  63197. /**
  63198. * Get a navigation mesh constrained position, within a particular radius
  63199. * @param position world position
  63200. * @param maxRadius the maximum distance to the constrained world position
  63201. * @returns the closest point to position constrained by the navigation mesh
  63202. */
  63203. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63204. /**
  63205. * Compute the final position from a segment made of destination-position
  63206. * @param position world position
  63207. * @param destination world position
  63208. * @returns the resulting point along the navmesh
  63209. */
  63210. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63211. /**
  63212. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63213. * @param start world position
  63214. * @param end world position
  63215. * @returns array containing world position composing the path
  63216. */
  63217. computePath(start: Vector3, end: Vector3): Vector3[];
  63218. /**
  63219. * If this plugin is supported
  63220. * @returns true if plugin is supported
  63221. */
  63222. isSupported(): boolean;
  63223. /**
  63224. * Create a new Crowd so you can add agents
  63225. * @param maxAgents the maximum agent count in the crowd
  63226. * @param maxAgentRadius the maximum radius an agent can have
  63227. * @param scene to attach the crowd to
  63228. * @returns the crowd you can add agents to
  63229. */
  63230. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63231. /**
  63232. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63233. * The queries will try to find a solution within those bounds
  63234. * default is (1,1,1)
  63235. * @param extent x,y,z value that define the extent around the queries point of reference
  63236. */
  63237. setDefaultQueryExtent(extent: Vector3): void;
  63238. /**
  63239. * Get the Bounding box extent specified by setDefaultQueryExtent
  63240. * @returns the box extent values
  63241. */
  63242. getDefaultQueryExtent(): Vector3;
  63243. /**
  63244. * Release all resources
  63245. */
  63246. dispose(): void;
  63247. }
  63248. /**
  63249. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63250. */
  63251. export interface ICrowd {
  63252. /**
  63253. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63254. * You can attach anything to that node. The node position is updated in the scene update tick.
  63255. * @param pos world position that will be constrained by the navigation mesh
  63256. * @param parameters agent parameters
  63257. * @param transform hooked to the agent that will be update by the scene
  63258. * @returns agent index
  63259. */
  63260. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63261. /**
  63262. * Returns the agent position in world space
  63263. * @param index agent index returned by addAgent
  63264. * @returns world space position
  63265. */
  63266. getAgentPosition(index: number): Vector3;
  63267. /**
  63268. * Gets the agent velocity in world space
  63269. * @param index agent index returned by addAgent
  63270. * @returns world space velocity
  63271. */
  63272. getAgentVelocity(index: number): Vector3;
  63273. /**
  63274. * remove a particular agent previously created
  63275. * @param index agent index returned by addAgent
  63276. */
  63277. removeAgent(index: number): void;
  63278. /**
  63279. * get the list of all agents attached to this crowd
  63280. * @returns list of agent indices
  63281. */
  63282. getAgents(): number[];
  63283. /**
  63284. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63285. * @param deltaTime in seconds
  63286. */
  63287. update(deltaTime: number): void;
  63288. /**
  63289. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63290. * @param index agent index returned by addAgent
  63291. * @param destination targeted world position
  63292. */
  63293. agentGoto(index: number, destination: Vector3): void;
  63294. /**
  63295. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63296. * The queries will try to find a solution within those bounds
  63297. * default is (1,1,1)
  63298. * @param extent x,y,z value that define the extent around the queries point of reference
  63299. */
  63300. setDefaultQueryExtent(extent: Vector3): void;
  63301. /**
  63302. * Get the Bounding box extent specified by setDefaultQueryExtent
  63303. * @returns the box extent values
  63304. */
  63305. getDefaultQueryExtent(): Vector3;
  63306. /**
  63307. * Release all resources
  63308. */
  63309. dispose(): void;
  63310. }
  63311. /**
  63312. * Configures an agent
  63313. */
  63314. export interface IAgentParameters {
  63315. /**
  63316. * Agent radius. [Limit: >= 0]
  63317. */
  63318. radius: number;
  63319. /**
  63320. * Agent height. [Limit: > 0]
  63321. */
  63322. height: number;
  63323. /**
  63324. * Maximum allowed acceleration. [Limit: >= 0]
  63325. */
  63326. maxAcceleration: number;
  63327. /**
  63328. * Maximum allowed speed. [Limit: >= 0]
  63329. */
  63330. maxSpeed: number;
  63331. /**
  63332. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  63333. */
  63334. collisionQueryRange: number;
  63335. /**
  63336. * The path visibility optimization range. [Limit: > 0]
  63337. */
  63338. pathOptimizationRange: number;
  63339. /**
  63340. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  63341. */
  63342. separationWeight: number;
  63343. }
  63344. /**
  63345. * Configures the navigation mesh creation
  63346. */
  63347. export interface INavMeshParameters {
  63348. /**
  63349. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  63350. */
  63351. cs: number;
  63352. /**
  63353. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  63354. */
  63355. ch: number;
  63356. /**
  63357. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  63358. */
  63359. walkableSlopeAngle: number;
  63360. /**
  63361. * Minimum floor to 'ceiling' height that will still allow the floor area to
  63362. * be considered walkable. [Limit: >= 3] [Units: vx]
  63363. */
  63364. walkableHeight: number;
  63365. /**
  63366. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  63367. */
  63368. walkableClimb: number;
  63369. /**
  63370. * The distance to erode/shrink the walkable area of the heightfield away from
  63371. * obstructions. [Limit: >=0] [Units: vx]
  63372. */
  63373. walkableRadius: number;
  63374. /**
  63375. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  63376. */
  63377. maxEdgeLen: number;
  63378. /**
  63379. * The maximum distance a simplfied contour's border edges should deviate
  63380. * the original raw contour. [Limit: >=0] [Units: vx]
  63381. */
  63382. maxSimplificationError: number;
  63383. /**
  63384. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  63385. */
  63386. minRegionArea: number;
  63387. /**
  63388. * Any regions with a span count smaller than this value will, if possible,
  63389. * be merged with larger regions. [Limit: >=0] [Units: vx]
  63390. */
  63391. mergeRegionArea: number;
  63392. /**
  63393. * The maximum number of vertices allowed for polygons generated during the
  63394. * contour to polygon conversion process. [Limit: >= 3]
  63395. */
  63396. maxVertsPerPoly: number;
  63397. /**
  63398. * Sets the sampling distance to use when generating the detail mesh.
  63399. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  63400. */
  63401. detailSampleDist: number;
  63402. /**
  63403. * The maximum distance the detail mesh surface should deviate from heightfield
  63404. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  63405. */
  63406. detailSampleMaxError: number;
  63407. }
  63408. }
  63409. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  63410. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  63411. import { Mesh } from "babylonjs/Meshes/mesh";
  63412. import { Scene } from "babylonjs/scene";
  63413. import { Vector3 } from "babylonjs/Maths/math";
  63414. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63415. /**
  63416. * RecastJS navigation plugin
  63417. */
  63418. export class RecastJSPlugin implements INavigationEnginePlugin {
  63419. /**
  63420. * Reference to the Recast library
  63421. */
  63422. bjsRECAST: any;
  63423. /**
  63424. * plugin name
  63425. */
  63426. name: string;
  63427. /**
  63428. * the first navmesh created. We might extend this to support multiple navmeshes
  63429. */
  63430. navMesh: any;
  63431. /**
  63432. * Initializes the recastJS plugin
  63433. * @param recastInjection can be used to inject your own recast reference
  63434. */
  63435. constructor(recastInjection?: any);
  63436. /**
  63437. * Creates a navigation mesh
  63438. * @param meshes array of all the geometry used to compute the navigatio mesh
  63439. * @param parameters bunch of parameters used to filter geometry
  63440. */
  63441. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63442. /**
  63443. * Create a navigation mesh debug mesh
  63444. * @param scene is where the mesh will be added
  63445. * @returns debug display mesh
  63446. */
  63447. createDebugNavMesh(scene: Scene): Mesh;
  63448. /**
  63449. * Get a navigation mesh constrained position, closest to the parameter position
  63450. * @param position world position
  63451. * @returns the closest point to position constrained by the navigation mesh
  63452. */
  63453. getClosestPoint(position: Vector3): Vector3;
  63454. /**
  63455. * Get a navigation mesh constrained position, within a particular radius
  63456. * @param position world position
  63457. * @param maxRadius the maximum distance to the constrained world position
  63458. * @returns the closest point to position constrained by the navigation mesh
  63459. */
  63460. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63461. /**
  63462. * Compute the final position from a segment made of destination-position
  63463. * @param position world position
  63464. * @param destination world position
  63465. * @returns the resulting point along the navmesh
  63466. */
  63467. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63468. /**
  63469. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63470. * @param start world position
  63471. * @param end world position
  63472. * @returns array containing world position composing the path
  63473. */
  63474. computePath(start: Vector3, end: Vector3): Vector3[];
  63475. /**
  63476. * Create a new Crowd so you can add agents
  63477. * @param maxAgents the maximum agent count in the crowd
  63478. * @param maxAgentRadius the maximum radius an agent can have
  63479. * @param scene to attach the crowd to
  63480. * @returns the crowd you can add agents to
  63481. */
  63482. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63483. /**
  63484. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63485. * The queries will try to find a solution within those bounds
  63486. * default is (1,1,1)
  63487. * @param extent x,y,z value that define the extent around the queries point of reference
  63488. */
  63489. setDefaultQueryExtent(extent: Vector3): void;
  63490. /**
  63491. * Get the Bounding box extent specified by setDefaultQueryExtent
  63492. * @returns the box extent values
  63493. */
  63494. getDefaultQueryExtent(): Vector3;
  63495. /**
  63496. * Disposes
  63497. */
  63498. dispose(): void;
  63499. /**
  63500. * If this plugin is supported
  63501. * @returns true if plugin is supported
  63502. */
  63503. isSupported(): boolean;
  63504. }
  63505. /**
  63506. * Recast detour crowd implementation
  63507. */
  63508. export class RecastJSCrowd implements ICrowd {
  63509. /**
  63510. * Recast/detour plugin
  63511. */
  63512. bjsRECASTPlugin: RecastJSPlugin;
  63513. /**
  63514. * Link to the detour crowd
  63515. */
  63516. recastCrowd: any;
  63517. /**
  63518. * One transform per agent
  63519. */
  63520. transforms: TransformNode[];
  63521. /**
  63522. * All agents created
  63523. */
  63524. agents: number[];
  63525. /**
  63526. * Link to the scene is kept to unregister the crowd from the scene
  63527. */
  63528. private _scene;
  63529. /**
  63530. * Observer for crowd updates
  63531. */
  63532. private _onBeforeAnimationsObserver;
  63533. /**
  63534. * Constructor
  63535. * @param plugin recastJS plugin
  63536. * @param maxAgents the maximum agent count in the crowd
  63537. * @param maxAgentRadius the maximum radius an agent can have
  63538. * @param scene to attach the crowd to
  63539. * @returns the crowd you can add agents to
  63540. */
  63541. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63542. /**
  63543. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63544. * You can attach anything to that node. The node position is updated in the scene update tick.
  63545. * @param pos world position that will be constrained by the navigation mesh
  63546. * @param parameters agent parameters
  63547. * @param transform hooked to the agent that will be update by the scene
  63548. * @returns agent index
  63549. */
  63550. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63551. /**
  63552. * Returns the agent position in world space
  63553. * @param index agent index returned by addAgent
  63554. * @returns world space position
  63555. */
  63556. getAgentPosition(index: number): Vector3;
  63557. /**
  63558. * Returns the agent velocity in world space
  63559. * @param index agent index returned by addAgent
  63560. * @returns world space velocity
  63561. */
  63562. getAgentVelocity(index: number): Vector3;
  63563. /**
  63564. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63565. * @param index agent index returned by addAgent
  63566. * @param destination targeted world position
  63567. */
  63568. agentGoto(index: number, destination: Vector3): void;
  63569. /**
  63570. * remove a particular agent previously created
  63571. * @param index agent index returned by addAgent
  63572. */
  63573. removeAgent(index: number): void;
  63574. /**
  63575. * get the list of all agents attached to this crowd
  63576. * @returns list of agent indices
  63577. */
  63578. getAgents(): number[];
  63579. /**
  63580. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63581. * @param deltaTime in seconds
  63582. */
  63583. update(deltaTime: number): void;
  63584. /**
  63585. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63586. * The queries will try to find a solution within those bounds
  63587. * default is (1,1,1)
  63588. * @param extent x,y,z value that define the extent around the queries point of reference
  63589. */
  63590. setDefaultQueryExtent(extent: Vector3): void;
  63591. /**
  63592. * Get the Bounding box extent specified by setDefaultQueryExtent
  63593. * @returns the box extent values
  63594. */
  63595. getDefaultQueryExtent(): Vector3;
  63596. /**
  63597. * Release all resources
  63598. */
  63599. dispose(): void;
  63600. }
  63601. }
  63602. declare module "babylonjs/Navigation/Plugins/index" {
  63603. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  63604. }
  63605. declare module "babylonjs/Navigation/index" {
  63606. export * from "babylonjs/Navigation/INavigationEngine";
  63607. export * from "babylonjs/Navigation/Plugins/index";
  63608. }
  63609. declare module "babylonjs/Offline/database" {
  63610. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  63611. /**
  63612. * Class used to enable access to IndexedDB
  63613. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63614. */
  63615. export class Database implements IOfflineProvider {
  63616. private _callbackManifestChecked;
  63617. private _currentSceneUrl;
  63618. private _db;
  63619. private _enableSceneOffline;
  63620. private _enableTexturesOffline;
  63621. private _manifestVersionFound;
  63622. private _mustUpdateRessources;
  63623. private _hasReachedQuota;
  63624. private _isSupported;
  63625. private _idbFactory;
  63626. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63627. private static IsUASupportingBlobStorage;
  63628. /**
  63629. * Gets a boolean indicating if Database storate is enabled (off by default)
  63630. */
  63631. static IDBStorageEnabled: boolean;
  63632. /**
  63633. * Gets a boolean indicating if scene must be saved in the database
  63634. */
  63635. get enableSceneOffline(): boolean;
  63636. /**
  63637. * Gets a boolean indicating if textures must be saved in the database
  63638. */
  63639. get enableTexturesOffline(): boolean;
  63640. /**
  63641. * Creates a new Database
  63642. * @param urlToScene defines the url to load the scene
  63643. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63644. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63645. */
  63646. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63647. private static _ParseURL;
  63648. private static _ReturnFullUrlLocation;
  63649. private _checkManifestFile;
  63650. /**
  63651. * Open the database and make it available
  63652. * @param successCallback defines the callback to call on success
  63653. * @param errorCallback defines the callback to call on error
  63654. */
  63655. open(successCallback: () => void, errorCallback: () => void): void;
  63656. /**
  63657. * Loads an image from the database
  63658. * @param url defines the url to load from
  63659. * @param image defines the target DOM image
  63660. */
  63661. loadImage(url: string, image: HTMLImageElement): void;
  63662. private _loadImageFromDBAsync;
  63663. private _saveImageIntoDBAsync;
  63664. private _checkVersionFromDB;
  63665. private _loadVersionFromDBAsync;
  63666. private _saveVersionIntoDBAsync;
  63667. /**
  63668. * Loads a file from database
  63669. * @param url defines the URL to load from
  63670. * @param sceneLoaded defines a callback to call on success
  63671. * @param progressCallBack defines a callback to call when progress changed
  63672. * @param errorCallback defines a callback to call on error
  63673. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63674. */
  63675. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63676. private _loadFileAsync;
  63677. private _saveFileAsync;
  63678. /**
  63679. * Validates if xhr data is correct
  63680. * @param xhr defines the request to validate
  63681. * @param dataType defines the expected data type
  63682. * @returns true if data is correct
  63683. */
  63684. private static _ValidateXHRData;
  63685. }
  63686. }
  63687. declare module "babylonjs/Offline/index" {
  63688. export * from "babylonjs/Offline/database";
  63689. export * from "babylonjs/Offline/IOfflineProvider";
  63690. }
  63691. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  63692. /** @hidden */
  63693. export var gpuUpdateParticlesPixelShader: {
  63694. name: string;
  63695. shader: string;
  63696. };
  63697. }
  63698. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  63699. /** @hidden */
  63700. export var gpuUpdateParticlesVertexShader: {
  63701. name: string;
  63702. shader: string;
  63703. };
  63704. }
  63705. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  63706. /** @hidden */
  63707. export var clipPlaneFragmentDeclaration2: {
  63708. name: string;
  63709. shader: string;
  63710. };
  63711. }
  63712. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  63713. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  63714. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63715. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63716. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63717. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63718. /** @hidden */
  63719. export var gpuRenderParticlesPixelShader: {
  63720. name: string;
  63721. shader: string;
  63722. };
  63723. }
  63724. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  63725. /** @hidden */
  63726. export var clipPlaneVertexDeclaration2: {
  63727. name: string;
  63728. shader: string;
  63729. };
  63730. }
  63731. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  63732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  63733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63734. /** @hidden */
  63735. export var gpuRenderParticlesVertexShader: {
  63736. name: string;
  63737. shader: string;
  63738. };
  63739. }
  63740. declare module "babylonjs/Particles/gpuParticleSystem" {
  63741. import { Nullable } from "babylonjs/types";
  63742. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  63743. import { Observable } from "babylonjs/Misc/observable";
  63744. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63745. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63746. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  63747. import { Scene, IDisposable } from "babylonjs/scene";
  63748. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  63749. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63750. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  63751. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  63752. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  63753. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  63754. /**
  63755. * This represents a GPU particle system in Babylon
  63756. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63757. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63758. */
  63759. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63760. /**
  63761. * The layer mask we are rendering the particles through.
  63762. */
  63763. layerMask: number;
  63764. private _capacity;
  63765. private _activeCount;
  63766. private _currentActiveCount;
  63767. private _accumulatedCount;
  63768. private _renderEffect;
  63769. private _updateEffect;
  63770. private _buffer0;
  63771. private _buffer1;
  63772. private _spriteBuffer;
  63773. private _updateVAO;
  63774. private _renderVAO;
  63775. private _targetIndex;
  63776. private _sourceBuffer;
  63777. private _targetBuffer;
  63778. private _engine;
  63779. private _currentRenderId;
  63780. private _started;
  63781. private _stopped;
  63782. private _timeDelta;
  63783. private _randomTexture;
  63784. private _randomTexture2;
  63785. private _attributesStrideSize;
  63786. private _updateEffectOptions;
  63787. private _randomTextureSize;
  63788. private _actualFrame;
  63789. private readonly _rawTextureWidth;
  63790. /**
  63791. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63792. */
  63793. static get IsSupported(): boolean;
  63794. /**
  63795. * An event triggered when the system is disposed.
  63796. */
  63797. onDisposeObservable: Observable<GPUParticleSystem>;
  63798. /**
  63799. * Gets the maximum number of particles active at the same time.
  63800. * @returns The max number of active particles.
  63801. */
  63802. getCapacity(): number;
  63803. /**
  63804. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63805. * to override the particles.
  63806. */
  63807. forceDepthWrite: boolean;
  63808. /**
  63809. * Gets or set the number of active particles
  63810. */
  63811. get activeParticleCount(): number;
  63812. set activeParticleCount(value: number);
  63813. private _preWarmDone;
  63814. /**
  63815. * Is this system ready to be used/rendered
  63816. * @return true if the system is ready
  63817. */
  63818. isReady(): boolean;
  63819. /**
  63820. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63821. * @returns True if it has been started, otherwise false.
  63822. */
  63823. isStarted(): boolean;
  63824. /**
  63825. * Starts the particle system and begins to emit
  63826. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63827. */
  63828. start(delay?: number): void;
  63829. /**
  63830. * Stops the particle system.
  63831. */
  63832. stop(): void;
  63833. /**
  63834. * Remove all active particles
  63835. */
  63836. reset(): void;
  63837. /**
  63838. * Returns the string "GPUParticleSystem"
  63839. * @returns a string containing the class name
  63840. */
  63841. getClassName(): string;
  63842. private _colorGradientsTexture;
  63843. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63844. /**
  63845. * Adds a new color gradient
  63846. * @param gradient defines the gradient to use (between 0 and 1)
  63847. * @param color1 defines the color to affect to the specified gradient
  63848. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63849. * @returns the current particle system
  63850. */
  63851. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63852. /**
  63853. * Remove a specific color gradient
  63854. * @param gradient defines the gradient to remove
  63855. * @returns the current particle system
  63856. */
  63857. removeColorGradient(gradient: number): GPUParticleSystem;
  63858. private _angularSpeedGradientsTexture;
  63859. private _sizeGradientsTexture;
  63860. private _velocityGradientsTexture;
  63861. private _limitVelocityGradientsTexture;
  63862. private _dragGradientsTexture;
  63863. private _addFactorGradient;
  63864. /**
  63865. * Adds a new size gradient
  63866. * @param gradient defines the gradient to use (between 0 and 1)
  63867. * @param factor defines the size factor to affect to the specified gradient
  63868. * @returns the current particle system
  63869. */
  63870. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63871. /**
  63872. * Remove a specific size gradient
  63873. * @param gradient defines the gradient to remove
  63874. * @returns the current particle system
  63875. */
  63876. removeSizeGradient(gradient: number): GPUParticleSystem;
  63877. /**
  63878. * Adds a new angular speed gradient
  63879. * @param gradient defines the gradient to use (between 0 and 1)
  63880. * @param factor defines the angular speed to affect to the specified gradient
  63881. * @returns the current particle system
  63882. */
  63883. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63884. /**
  63885. * Remove a specific angular speed gradient
  63886. * @param gradient defines the gradient to remove
  63887. * @returns the current particle system
  63888. */
  63889. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63890. /**
  63891. * Adds a new velocity gradient
  63892. * @param gradient defines the gradient to use (between 0 and 1)
  63893. * @param factor defines the velocity to affect to the specified gradient
  63894. * @returns the current particle system
  63895. */
  63896. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63897. /**
  63898. * Remove a specific velocity gradient
  63899. * @param gradient defines the gradient to remove
  63900. * @returns the current particle system
  63901. */
  63902. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63903. /**
  63904. * Adds a new limit velocity gradient
  63905. * @param gradient defines the gradient to use (between 0 and 1)
  63906. * @param factor defines the limit velocity value to affect to the specified gradient
  63907. * @returns the current particle system
  63908. */
  63909. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63910. /**
  63911. * Remove a specific limit velocity gradient
  63912. * @param gradient defines the gradient to remove
  63913. * @returns the current particle system
  63914. */
  63915. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63916. /**
  63917. * Adds a new drag gradient
  63918. * @param gradient defines the gradient to use (between 0 and 1)
  63919. * @param factor defines the drag value to affect to the specified gradient
  63920. * @returns the current particle system
  63921. */
  63922. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63923. /**
  63924. * Remove a specific drag gradient
  63925. * @param gradient defines the gradient to remove
  63926. * @returns the current particle system
  63927. */
  63928. removeDragGradient(gradient: number): GPUParticleSystem;
  63929. /**
  63930. * Not supported by GPUParticleSystem
  63931. * @param gradient defines the gradient to use (between 0 and 1)
  63932. * @param factor defines the emit rate value to affect to the specified gradient
  63933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63934. * @returns the current particle system
  63935. */
  63936. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63937. /**
  63938. * Not supported by GPUParticleSystem
  63939. * @param gradient defines the gradient to remove
  63940. * @returns the current particle system
  63941. */
  63942. removeEmitRateGradient(gradient: number): IParticleSystem;
  63943. /**
  63944. * Not supported by GPUParticleSystem
  63945. * @param gradient defines the gradient to use (between 0 and 1)
  63946. * @param factor defines the start size value to affect to the specified gradient
  63947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63948. * @returns the current particle system
  63949. */
  63950. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63951. /**
  63952. * Not supported by GPUParticleSystem
  63953. * @param gradient defines the gradient to remove
  63954. * @returns the current particle system
  63955. */
  63956. removeStartSizeGradient(gradient: number): IParticleSystem;
  63957. /**
  63958. * Not supported by GPUParticleSystem
  63959. * @param gradient defines the gradient to use (between 0 and 1)
  63960. * @param min defines the color remap minimal range
  63961. * @param max defines the color remap maximal range
  63962. * @returns the current particle system
  63963. */
  63964. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63965. /**
  63966. * Not supported by GPUParticleSystem
  63967. * @param gradient defines the gradient to remove
  63968. * @returns the current particle system
  63969. */
  63970. removeColorRemapGradient(): IParticleSystem;
  63971. /**
  63972. * Not supported by GPUParticleSystem
  63973. * @param gradient defines the gradient to use (between 0 and 1)
  63974. * @param min defines the alpha remap minimal range
  63975. * @param max defines the alpha remap maximal range
  63976. * @returns the current particle system
  63977. */
  63978. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63979. /**
  63980. * Not supported by GPUParticleSystem
  63981. * @param gradient defines the gradient to remove
  63982. * @returns the current particle system
  63983. */
  63984. removeAlphaRemapGradient(): IParticleSystem;
  63985. /**
  63986. * Not supported by GPUParticleSystem
  63987. * @param gradient defines the gradient to use (between 0 and 1)
  63988. * @param color defines the color to affect to the specified gradient
  63989. * @returns the current particle system
  63990. */
  63991. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63992. /**
  63993. * Not supported by GPUParticleSystem
  63994. * @param gradient defines the gradient to remove
  63995. * @returns the current particle system
  63996. */
  63997. removeRampGradient(): IParticleSystem;
  63998. /**
  63999. * Not supported by GPUParticleSystem
  64000. * @returns the list of ramp gradients
  64001. */
  64002. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64003. /**
  64004. * Not supported by GPUParticleSystem
  64005. * Gets or sets a boolean indicating that ramp gradients must be used
  64006. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64007. */
  64008. get useRampGradients(): boolean;
  64009. set useRampGradients(value: boolean);
  64010. /**
  64011. * Not supported by GPUParticleSystem
  64012. * @param gradient defines the gradient to use (between 0 and 1)
  64013. * @param factor defines the life time factor to affect to the specified gradient
  64014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64015. * @returns the current particle system
  64016. */
  64017. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64018. /**
  64019. * Not supported by GPUParticleSystem
  64020. * @param gradient defines the gradient to remove
  64021. * @returns the current particle system
  64022. */
  64023. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64024. /**
  64025. * Instantiates a GPU particle system.
  64026. * 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.
  64027. * @param name The name of the particle system
  64028. * @param options The options used to create the system
  64029. * @param scene The scene the particle system belongs to
  64030. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64031. */
  64032. constructor(name: string, options: Partial<{
  64033. capacity: number;
  64034. randomTextureSize: number;
  64035. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64036. protected _reset(): void;
  64037. private _createUpdateVAO;
  64038. private _createRenderVAO;
  64039. private _initialize;
  64040. /** @hidden */
  64041. _recreateUpdateEffect(): void;
  64042. /** @hidden */
  64043. _recreateRenderEffect(): void;
  64044. /**
  64045. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64046. * @param preWarm defines if we are in the pre-warmimg phase
  64047. */
  64048. animate(preWarm?: boolean): void;
  64049. private _createFactorGradientTexture;
  64050. private _createSizeGradientTexture;
  64051. private _createAngularSpeedGradientTexture;
  64052. private _createVelocityGradientTexture;
  64053. private _createLimitVelocityGradientTexture;
  64054. private _createDragGradientTexture;
  64055. private _createColorGradientTexture;
  64056. /**
  64057. * Renders the particle system in its current state
  64058. * @param preWarm defines if the system should only update the particles but not render them
  64059. * @returns the current number of particles
  64060. */
  64061. render(preWarm?: boolean): number;
  64062. /**
  64063. * Rebuilds the particle system
  64064. */
  64065. rebuild(): void;
  64066. private _releaseBuffers;
  64067. private _releaseVAOs;
  64068. /**
  64069. * Disposes the particle system and free the associated resources
  64070. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64071. */
  64072. dispose(disposeTexture?: boolean): void;
  64073. /**
  64074. * Clones the particle system.
  64075. * @param name The name of the cloned object
  64076. * @param newEmitter The new emitter to use
  64077. * @returns the cloned particle system
  64078. */
  64079. clone(name: string, newEmitter: any): GPUParticleSystem;
  64080. /**
  64081. * Serializes the particle system to a JSON object.
  64082. * @returns the JSON object
  64083. */
  64084. serialize(): any;
  64085. /**
  64086. * Parses a JSON object to create a GPU particle system.
  64087. * @param parsedParticleSystem The JSON object to parse
  64088. * @param scene The scene to create the particle system in
  64089. * @param rootUrl The root url to use to load external dependencies like texture
  64090. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64091. * @returns the parsed GPU particle system
  64092. */
  64093. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64094. }
  64095. }
  64096. declare module "babylonjs/Particles/particleSystemSet" {
  64097. import { Nullable } from "babylonjs/types";
  64098. import { Color3 } from "babylonjs/Maths/math.color";
  64099. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64101. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64102. import { Scene, IDisposable } from "babylonjs/scene";
  64103. /**
  64104. * Represents a set of particle systems working together to create a specific effect
  64105. */
  64106. export class ParticleSystemSet implements IDisposable {
  64107. /**
  64108. * Gets or sets base Assets URL
  64109. */
  64110. static BaseAssetsUrl: string;
  64111. private _emitterCreationOptions;
  64112. private _emitterNode;
  64113. /**
  64114. * Gets the particle system list
  64115. */
  64116. systems: IParticleSystem[];
  64117. /**
  64118. * Gets the emitter node used with this set
  64119. */
  64120. get emitterNode(): Nullable<TransformNode>;
  64121. /**
  64122. * Creates a new emitter mesh as a sphere
  64123. * @param options defines the options used to create the sphere
  64124. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64125. * @param scene defines the hosting scene
  64126. */
  64127. setEmitterAsSphere(options: {
  64128. diameter: number;
  64129. segments: number;
  64130. color: Color3;
  64131. }, renderingGroupId: number, scene: Scene): void;
  64132. /**
  64133. * Starts all particle systems of the set
  64134. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64135. */
  64136. start(emitter?: AbstractMesh): void;
  64137. /**
  64138. * Release all associated resources
  64139. */
  64140. dispose(): void;
  64141. /**
  64142. * Serialize the set into a JSON compatible object
  64143. * @returns a JSON compatible representation of the set
  64144. */
  64145. serialize(): any;
  64146. /**
  64147. * Parse a new ParticleSystemSet from a serialized source
  64148. * @param data defines a JSON compatible representation of the set
  64149. * @param scene defines the hosting scene
  64150. * @param gpu defines if we want GPU particles or CPU particles
  64151. * @returns a new ParticleSystemSet
  64152. */
  64153. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64154. }
  64155. }
  64156. declare module "babylonjs/Particles/particleHelper" {
  64157. import { Nullable } from "babylonjs/types";
  64158. import { Scene } from "babylonjs/scene";
  64159. import { Vector3 } from "babylonjs/Maths/math.vector";
  64160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64161. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64162. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64163. /**
  64164. * This class is made for on one-liner static method to help creating particle system set.
  64165. */
  64166. export class ParticleHelper {
  64167. /**
  64168. * Gets or sets base Assets URL
  64169. */
  64170. static BaseAssetsUrl: string;
  64171. /**
  64172. * Create a default particle system that you can tweak
  64173. * @param emitter defines the emitter to use
  64174. * @param capacity defines the system capacity (default is 500 particles)
  64175. * @param scene defines the hosting scene
  64176. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64177. * @returns the new Particle system
  64178. */
  64179. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64180. /**
  64181. * This is the main static method (one-liner) of this helper to create different particle systems
  64182. * @param type This string represents the type to the particle system to create
  64183. * @param scene The scene where the particle system should live
  64184. * @param gpu If the system will use gpu
  64185. * @returns the ParticleSystemSet created
  64186. */
  64187. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64188. /**
  64189. * Static function used to export a particle system to a ParticleSystemSet variable.
  64190. * Please note that the emitter shape is not exported
  64191. * @param systems defines the particle systems to export
  64192. * @returns the created particle system set
  64193. */
  64194. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64195. }
  64196. }
  64197. declare module "babylonjs/Particles/particleSystemComponent" {
  64198. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64199. import { Effect } from "babylonjs/Materials/effect";
  64200. import "babylonjs/Shaders/particles.vertex";
  64201. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64202. module "babylonjs/Engines/engine" {
  64203. interface Engine {
  64204. /**
  64205. * Create an effect to use with particle systems.
  64206. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  64207. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  64208. * @param uniformsNames defines a list of attribute names
  64209. * @param samplers defines an array of string used to represent textures
  64210. * @param defines defines the string containing the defines to use to compile the shaders
  64211. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  64212. * @param onCompiled defines a function to call when the effect creation is successful
  64213. * @param onError defines a function to call when the effect creation has failed
  64214. * @returns the new Effect
  64215. */
  64216. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  64217. }
  64218. }
  64219. module "babylonjs/Meshes/mesh" {
  64220. interface Mesh {
  64221. /**
  64222. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  64223. * @returns an array of IParticleSystem
  64224. */
  64225. getEmittedParticleSystems(): IParticleSystem[];
  64226. /**
  64227. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  64228. * @returns an array of IParticleSystem
  64229. */
  64230. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  64231. }
  64232. }
  64233. /**
  64234. * @hidden
  64235. */
  64236. export var _IDoNeedToBeInTheBuild: number;
  64237. }
  64238. declare module "babylonjs/Particles/pointsCloudSystem" {
  64239. import { Color4 } from "babylonjs/Maths/math";
  64240. import { Mesh } from "babylonjs/Meshes/mesh";
  64241. import { Scene, IDisposable } from "babylonjs/scene";
  64242. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  64243. /** Defines the 4 color options */
  64244. export enum PointColor {
  64245. /** color value */
  64246. Color = 2,
  64247. /** uv value */
  64248. UV = 1,
  64249. /** random value */
  64250. Random = 0,
  64251. /** stated value */
  64252. Stated = 3
  64253. }
  64254. /**
  64255. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  64256. * 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.
  64257. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  64258. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  64259. *
  64260. * Full documentation here : TO BE ENTERED
  64261. */
  64262. export class PointsCloudSystem implements IDisposable {
  64263. /**
  64264. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  64265. * Example : var p = SPS.particles[i];
  64266. */
  64267. particles: CloudPoint[];
  64268. /**
  64269. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  64270. */
  64271. nbParticles: number;
  64272. /**
  64273. * This a counter for your own usage. It's not set by any SPS functions.
  64274. */
  64275. counter: number;
  64276. /**
  64277. * The PCS name. This name is also given to the underlying mesh.
  64278. */
  64279. name: string;
  64280. /**
  64281. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  64282. */
  64283. mesh: Mesh;
  64284. /**
  64285. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  64286. * Please read :
  64287. */
  64288. vars: any;
  64289. /**
  64290. * @hidden
  64291. */
  64292. _size: number;
  64293. private _scene;
  64294. private _promises;
  64295. private _positions;
  64296. private _indices;
  64297. private _normals;
  64298. private _colors;
  64299. private _uvs;
  64300. private _indices32;
  64301. private _positions32;
  64302. private _colors32;
  64303. private _uvs32;
  64304. private _updatable;
  64305. private _isVisibilityBoxLocked;
  64306. private _alwaysVisible;
  64307. private _groups;
  64308. private _groupCounter;
  64309. private _computeParticleColor;
  64310. private _computeParticleTexture;
  64311. private _computeParticleRotation;
  64312. private _computeBoundingBox;
  64313. private _isReady;
  64314. /**
  64315. * Creates a PCS (Points Cloud System) object
  64316. * @param name (String) is the PCS name, this will be the underlying mesh name
  64317. * @param pointSize (number) is the size for each point
  64318. * @param scene (Scene) is the scene in which the PCS is added
  64319. * @param options defines the options of the PCS e.g.
  64320. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  64321. */
  64322. constructor(name: string, pointSize: number, scene: Scene, options?: {
  64323. updatable?: boolean;
  64324. });
  64325. /**
  64326. * Builds the PCS underlying mesh. Returns a standard Mesh.
  64327. * If no points were added to the PCS, the returned mesh is just a single point.
  64328. * @returns a promise for the created mesh
  64329. */
  64330. buildMeshAsync(): Promise<Mesh>;
  64331. /**
  64332. * @hidden
  64333. */
  64334. private _buildMesh;
  64335. private _addParticle;
  64336. private _randomUnitVector;
  64337. private _getColorIndicesForCoord;
  64338. private _setPointsColorOrUV;
  64339. private _colorFromTexture;
  64340. private _calculateDensity;
  64341. /**
  64342. * Adds points to the PCS in random positions within a unit sphere
  64343. * @param nb (positive integer) the number of particles to be created from this model
  64344. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  64345. * @returns the number of groups in the system
  64346. */
  64347. addPoints(nb: number, pointFunction?: any): number;
  64348. /**
  64349. * Adds points to the PCS from the surface of 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. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64358. /**
  64359. * Adds points to the PCS inside the model shape
  64360. * @param mesh is any Mesh object that will be used as a surface model for the points
  64361. * @param nb (positive integer) the number of particles to be created from this model
  64362. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64363. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64364. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64365. * @returns the number of groups in the system
  64366. */
  64367. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64368. /**
  64369. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  64370. * This method calls `updateParticle()` for each particle of the SPS.
  64371. * For an animated SPS, it is usually called within the render loop.
  64372. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  64373. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  64374. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  64375. * @returns the PCS.
  64376. */
  64377. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64378. /**
  64379. * Disposes the PCS.
  64380. */
  64381. dispose(): void;
  64382. /**
  64383. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64384. * doc :
  64385. * @returns the PCS.
  64386. */
  64387. refreshVisibleSize(): PointsCloudSystem;
  64388. /**
  64389. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64390. * @param size the size (float) of the visibility box
  64391. * note : this doesn't lock the PCS mesh bounding box.
  64392. * doc :
  64393. */
  64394. setVisibilityBox(size: number): void;
  64395. /**
  64396. * Gets whether the PCS is always visible or not
  64397. * doc :
  64398. */
  64399. get isAlwaysVisible(): boolean;
  64400. /**
  64401. * Sets the PCS as always visible or not
  64402. * doc :
  64403. */
  64404. set isAlwaysVisible(val: boolean);
  64405. /**
  64406. * Tells to `setParticles()` to compute the particle rotations or not
  64407. * Default value : false. The PCS is faster when it's set to false
  64408. * Note : particle rotations are only applied to parent particles
  64409. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64410. */
  64411. set computeParticleRotation(val: boolean);
  64412. /**
  64413. * Tells to `setParticles()` to compute the particle colors or not.
  64414. * Default value : true. The PCS is faster when it's set to false.
  64415. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64416. */
  64417. set computeParticleColor(val: boolean);
  64418. set computeParticleTexture(val: boolean);
  64419. /**
  64420. * Gets if `setParticles()` computes the particle colors or not.
  64421. * Default value : false. The PCS is faster when it's set to false.
  64422. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64423. */
  64424. get computeParticleColor(): boolean;
  64425. /**
  64426. * Gets if `setParticles()` computes the particle textures or not.
  64427. * Default value : false. The PCS is faster when it's set to false.
  64428. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64429. */
  64430. get computeParticleTexture(): boolean;
  64431. /**
  64432. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64433. */
  64434. set computeBoundingBox(val: boolean);
  64435. /**
  64436. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64437. */
  64438. get computeBoundingBox(): boolean;
  64439. /**
  64440. * This function does nothing. It may be overwritten to set all the particle first values.
  64441. * The PCS doesn't call this function, you may have to call it by your own.
  64442. * doc :
  64443. */
  64444. initParticles(): void;
  64445. /**
  64446. * This function does nothing. It may be overwritten to recycle a particle
  64447. * The PCS doesn't call this function, you can to call it
  64448. * doc :
  64449. * @param particle The particle to recycle
  64450. * @returns the recycled particle
  64451. */
  64452. recycleParticle(particle: CloudPoint): CloudPoint;
  64453. /**
  64454. * Updates a particle : this function should be overwritten by the user.
  64455. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64456. * doc :
  64457. * @example : just set a particle position or velocity and recycle conditions
  64458. * @param particle The particle to update
  64459. * @returns the updated particle
  64460. */
  64461. updateParticle(particle: CloudPoint): CloudPoint;
  64462. /**
  64463. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64464. * This does nothing and may be overwritten by the user.
  64465. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64466. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64467. * @param update the boolean update value actually passed to setParticles()
  64468. */
  64469. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64470. /**
  64471. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64472. * This will be passed three parameters.
  64473. * This does nothing and may be overwritten by the user.
  64474. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64475. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64476. * @param update the boolean update value actually passed to setParticles()
  64477. */
  64478. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64479. }
  64480. }
  64481. declare module "babylonjs/Particles/cloudPoint" {
  64482. import { Nullable } from "babylonjs/types";
  64483. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  64484. import { Mesh } from "babylonjs/Meshes/mesh";
  64485. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64486. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  64487. /**
  64488. * Represents one particle of a points cloud system.
  64489. */
  64490. export class CloudPoint {
  64491. /**
  64492. * particle global index
  64493. */
  64494. idx: number;
  64495. /**
  64496. * The color of the particle
  64497. */
  64498. color: Nullable<Color4>;
  64499. /**
  64500. * The world space position of the particle.
  64501. */
  64502. position: Vector3;
  64503. /**
  64504. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64505. */
  64506. rotation: Vector3;
  64507. /**
  64508. * The world space rotation quaternion of the particle.
  64509. */
  64510. rotationQuaternion: Nullable<Quaternion>;
  64511. /**
  64512. * The uv of the particle.
  64513. */
  64514. uv: Nullable<Vector2>;
  64515. /**
  64516. * The current speed of the particle.
  64517. */
  64518. velocity: Vector3;
  64519. /**
  64520. * The pivot point in the particle local space.
  64521. */
  64522. pivot: Vector3;
  64523. /**
  64524. * Must the particle be translated from its pivot point in its local space ?
  64525. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64526. * Default : false
  64527. */
  64528. translateFromPivot: boolean;
  64529. /**
  64530. * Index of this particle in the global "positions" array (Internal use)
  64531. * @hidden
  64532. */
  64533. _pos: number;
  64534. /**
  64535. * @hidden Index of this particle in the global "indices" array (Internal use)
  64536. */
  64537. _ind: number;
  64538. /**
  64539. * Group this particle belongs to
  64540. */
  64541. _group: PointsGroup;
  64542. /**
  64543. * Group id of this particle
  64544. */
  64545. groupId: number;
  64546. /**
  64547. * Index of the particle in its group id (Internal use)
  64548. */
  64549. idxInGroup: number;
  64550. /**
  64551. * @hidden Particle BoundingInfo object (Internal use)
  64552. */
  64553. _boundingInfo: BoundingInfo;
  64554. /**
  64555. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64556. */
  64557. _pcs: PointsCloudSystem;
  64558. /**
  64559. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64560. */
  64561. _stillInvisible: boolean;
  64562. /**
  64563. * @hidden Last computed particle rotation matrix
  64564. */
  64565. _rotationMatrix: number[];
  64566. /**
  64567. * Parent particle Id, if any.
  64568. * Default null.
  64569. */
  64570. parentId: Nullable<number>;
  64571. /**
  64572. * @hidden Internal global position in the PCS.
  64573. */
  64574. _globalPosition: Vector3;
  64575. /**
  64576. * Creates a Point Cloud object.
  64577. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64578. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64579. * @param group (PointsGroup) is the group the particle belongs to
  64580. * @param groupId (integer) is the group identifier in the PCS.
  64581. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64582. * @param pcs defines the PCS it is associated to
  64583. */
  64584. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64585. /**
  64586. * get point size
  64587. */
  64588. get size(): Vector3;
  64589. /**
  64590. * Set point size
  64591. */
  64592. set size(scale: Vector3);
  64593. /**
  64594. * Legacy support, changed quaternion to rotationQuaternion
  64595. */
  64596. get quaternion(): Nullable<Quaternion>;
  64597. /**
  64598. * Legacy support, changed quaternion to rotationQuaternion
  64599. */
  64600. set quaternion(q: Nullable<Quaternion>);
  64601. /**
  64602. * Returns a boolean. True if the particle intersects a mesh, else false
  64603. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64604. * @param target is the object (point or mesh) what the intersection is computed against
  64605. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64606. * @returns true if it intersects
  64607. */
  64608. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64609. /**
  64610. * get the rotation matrix of the particle
  64611. * @hidden
  64612. */
  64613. getRotationMatrix(m: Matrix): void;
  64614. }
  64615. /**
  64616. * Represents a group of points in a points cloud system
  64617. * * PCS internal tool, don't use it manually.
  64618. */
  64619. export class PointsGroup {
  64620. /**
  64621. * The group id
  64622. * @hidden
  64623. */
  64624. groupID: number;
  64625. /**
  64626. * image data for group (internal use)
  64627. * @hidden
  64628. */
  64629. _groupImageData: Nullable<ArrayBufferView>;
  64630. /**
  64631. * Image Width (internal use)
  64632. * @hidden
  64633. */
  64634. _groupImgWidth: number;
  64635. /**
  64636. * Image Height (internal use)
  64637. * @hidden
  64638. */
  64639. _groupImgHeight: number;
  64640. /**
  64641. * Custom position function (internal use)
  64642. * @hidden
  64643. */
  64644. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64645. /**
  64646. * density per facet for surface points
  64647. * @hidden
  64648. */
  64649. _groupDensity: number[];
  64650. /**
  64651. * Only when points are colored by texture carries pointer to texture list array
  64652. * @hidden
  64653. */
  64654. _textureNb: number;
  64655. /**
  64656. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64657. * PCS internal tool, don't use it manually.
  64658. * @hidden
  64659. */
  64660. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64661. }
  64662. }
  64663. declare module "babylonjs/Particles/index" {
  64664. export * from "babylonjs/Particles/baseParticleSystem";
  64665. export * from "babylonjs/Particles/EmitterTypes/index";
  64666. export * from "babylonjs/Particles/gpuParticleSystem";
  64667. export * from "babylonjs/Particles/IParticleSystem";
  64668. export * from "babylonjs/Particles/particle";
  64669. export * from "babylonjs/Particles/particleHelper";
  64670. export * from "babylonjs/Particles/particleSystem";
  64671. export * from "babylonjs/Particles/particleSystemComponent";
  64672. export * from "babylonjs/Particles/particleSystemSet";
  64673. export * from "babylonjs/Particles/solidParticle";
  64674. export * from "babylonjs/Particles/solidParticleSystem";
  64675. export * from "babylonjs/Particles/cloudPoint";
  64676. export * from "babylonjs/Particles/pointsCloudSystem";
  64677. export * from "babylonjs/Particles/subEmitter";
  64678. }
  64679. declare module "babylonjs/Physics/physicsEngineComponent" {
  64680. import { Nullable } from "babylonjs/types";
  64681. import { Observable, Observer } from "babylonjs/Misc/observable";
  64682. import { Vector3 } from "babylonjs/Maths/math.vector";
  64683. import { Mesh } from "babylonjs/Meshes/mesh";
  64684. import { ISceneComponent } from "babylonjs/sceneComponent";
  64685. import { Scene } from "babylonjs/scene";
  64686. import { Node } from "babylonjs/node";
  64687. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64688. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64689. module "babylonjs/scene" {
  64690. interface Scene {
  64691. /** @hidden (Backing field) */
  64692. _physicsEngine: Nullable<IPhysicsEngine>;
  64693. /** @hidden */
  64694. _physicsTimeAccumulator: number;
  64695. /**
  64696. * Gets the current physics engine
  64697. * @returns a IPhysicsEngine or null if none attached
  64698. */
  64699. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64700. /**
  64701. * Enables physics to the current scene
  64702. * @param gravity defines the scene's gravity for the physics engine
  64703. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64704. * @return a boolean indicating if the physics engine was initialized
  64705. */
  64706. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64707. /**
  64708. * Disables and disposes the physics engine associated with the scene
  64709. */
  64710. disablePhysicsEngine(): void;
  64711. /**
  64712. * Gets a boolean indicating if there is an active physics engine
  64713. * @returns a boolean indicating if there is an active physics engine
  64714. */
  64715. isPhysicsEnabled(): boolean;
  64716. /**
  64717. * Deletes a physics compound impostor
  64718. * @param compound defines the compound to delete
  64719. */
  64720. deleteCompoundImpostor(compound: any): void;
  64721. /**
  64722. * An event triggered when physic simulation is about to be run
  64723. */
  64724. onBeforePhysicsObservable: Observable<Scene>;
  64725. /**
  64726. * An event triggered when physic simulation has been done
  64727. */
  64728. onAfterPhysicsObservable: Observable<Scene>;
  64729. }
  64730. }
  64731. module "babylonjs/Meshes/abstractMesh" {
  64732. interface AbstractMesh {
  64733. /** @hidden */
  64734. _physicsImpostor: Nullable<PhysicsImpostor>;
  64735. /**
  64736. * Gets or sets impostor used for physic simulation
  64737. * @see http://doc.babylonjs.com/features/physics_engine
  64738. */
  64739. physicsImpostor: Nullable<PhysicsImpostor>;
  64740. /**
  64741. * Gets the current physics impostor
  64742. * @see http://doc.babylonjs.com/features/physics_engine
  64743. * @returns a physics impostor or null
  64744. */
  64745. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64746. /** Apply a physic impulse to the mesh
  64747. * @param force defines the force to apply
  64748. * @param contactPoint defines where to apply the force
  64749. * @returns the current mesh
  64750. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64751. */
  64752. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64753. /**
  64754. * Creates a physic joint between two meshes
  64755. * @param otherMesh defines the other mesh to use
  64756. * @param pivot1 defines the pivot to use on this mesh
  64757. * @param pivot2 defines the pivot to use on the other mesh
  64758. * @param options defines additional options (can be plugin dependent)
  64759. * @returns the current mesh
  64760. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64761. */
  64762. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64763. /** @hidden */
  64764. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64765. }
  64766. }
  64767. /**
  64768. * Defines the physics engine scene component responsible to manage a physics engine
  64769. */
  64770. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64771. /**
  64772. * The component name helpful to identify the component in the list of scene components.
  64773. */
  64774. readonly name: string;
  64775. /**
  64776. * The scene the component belongs to.
  64777. */
  64778. scene: Scene;
  64779. /**
  64780. * Creates a new instance of the component for the given scene
  64781. * @param scene Defines the scene to register the component in
  64782. */
  64783. constructor(scene: Scene);
  64784. /**
  64785. * Registers the component in a given scene
  64786. */
  64787. register(): void;
  64788. /**
  64789. * Rebuilds the elements related to this component in case of
  64790. * context lost for instance.
  64791. */
  64792. rebuild(): void;
  64793. /**
  64794. * Disposes the component and the associated ressources
  64795. */
  64796. dispose(): void;
  64797. }
  64798. }
  64799. declare module "babylonjs/Physics/physicsHelper" {
  64800. import { Nullable } from "babylonjs/types";
  64801. import { Vector3 } from "babylonjs/Maths/math.vector";
  64802. import { Mesh } from "babylonjs/Meshes/mesh";
  64803. import { Scene } from "babylonjs/scene";
  64804. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64805. /**
  64806. * A helper for physics simulations
  64807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64808. */
  64809. export class PhysicsHelper {
  64810. private _scene;
  64811. private _physicsEngine;
  64812. /**
  64813. * Initializes the Physics helper
  64814. * @param scene Babylon.js scene
  64815. */
  64816. constructor(scene: Scene);
  64817. /**
  64818. * Applies a radial explosion impulse
  64819. * @param origin the origin of the explosion
  64820. * @param radiusOrEventOptions the radius or the options of radial explosion
  64821. * @param strength the explosion strength
  64822. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64823. * @returns A physics radial explosion event, or null
  64824. */
  64825. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64826. /**
  64827. * Applies a radial explosion force
  64828. * @param origin the origin of the explosion
  64829. * @param radiusOrEventOptions the radius or the options of radial explosion
  64830. * @param strength the explosion strength
  64831. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64832. * @returns A physics radial explosion event, or null
  64833. */
  64834. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64835. /**
  64836. * Creates a gravitational field
  64837. * @param origin the origin of the explosion
  64838. * @param radiusOrEventOptions the radius or the options of radial explosion
  64839. * @param strength the explosion strength
  64840. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64841. * @returns A physics gravitational field event, or null
  64842. */
  64843. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64844. /**
  64845. * Creates a physics updraft event
  64846. * @param origin the origin of the updraft
  64847. * @param radiusOrEventOptions the radius or the options of the updraft
  64848. * @param strength the strength of the updraft
  64849. * @param height the height of the updraft
  64850. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64851. * @returns A physics updraft event, or null
  64852. */
  64853. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64854. /**
  64855. * Creates a physics vortex event
  64856. * @param origin the of the vortex
  64857. * @param radiusOrEventOptions the radius or the options of the vortex
  64858. * @param strength the strength of the vortex
  64859. * @param height the height of the vortex
  64860. * @returns a Physics vortex event, or null
  64861. * A physics vortex event or null
  64862. */
  64863. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64864. }
  64865. /**
  64866. * Represents a physics radial explosion event
  64867. */
  64868. class PhysicsRadialExplosionEvent {
  64869. private _scene;
  64870. private _options;
  64871. private _sphere;
  64872. private _dataFetched;
  64873. /**
  64874. * Initializes a radial explosioin event
  64875. * @param _scene BabylonJS scene
  64876. * @param _options The options for the vortex event
  64877. */
  64878. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64879. /**
  64880. * Returns the data related to the radial explosion event (sphere).
  64881. * @returns The radial explosion event data
  64882. */
  64883. getData(): PhysicsRadialExplosionEventData;
  64884. /**
  64885. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64886. * @param impostor A physics imposter
  64887. * @param origin the origin of the explosion
  64888. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64889. */
  64890. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64891. /**
  64892. * Triggers affecterd impostors callbacks
  64893. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64894. */
  64895. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64896. /**
  64897. * Disposes the sphere.
  64898. * @param force Specifies if the sphere should be disposed by force
  64899. */
  64900. dispose(force?: boolean): void;
  64901. /*** Helpers ***/
  64902. private _prepareSphere;
  64903. private _intersectsWithSphere;
  64904. }
  64905. /**
  64906. * Represents a gravitational field event
  64907. */
  64908. class PhysicsGravitationalFieldEvent {
  64909. private _physicsHelper;
  64910. private _scene;
  64911. private _origin;
  64912. private _options;
  64913. private _tickCallback;
  64914. private _sphere;
  64915. private _dataFetched;
  64916. /**
  64917. * Initializes the physics gravitational field event
  64918. * @param _physicsHelper A physics helper
  64919. * @param _scene BabylonJS scene
  64920. * @param _origin The origin position of the gravitational field event
  64921. * @param _options The options for the vortex event
  64922. */
  64923. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64924. /**
  64925. * Returns the data related to the gravitational field event (sphere).
  64926. * @returns A gravitational field event
  64927. */
  64928. getData(): PhysicsGravitationalFieldEventData;
  64929. /**
  64930. * Enables the gravitational field.
  64931. */
  64932. enable(): void;
  64933. /**
  64934. * Disables the gravitational field.
  64935. */
  64936. disable(): void;
  64937. /**
  64938. * Disposes the sphere.
  64939. * @param force The force to dispose from the gravitational field event
  64940. */
  64941. dispose(force?: boolean): void;
  64942. private _tick;
  64943. }
  64944. /**
  64945. * Represents a physics updraft event
  64946. */
  64947. class PhysicsUpdraftEvent {
  64948. private _scene;
  64949. private _origin;
  64950. private _options;
  64951. private _physicsEngine;
  64952. private _originTop;
  64953. private _originDirection;
  64954. private _tickCallback;
  64955. private _cylinder;
  64956. private _cylinderPosition;
  64957. private _dataFetched;
  64958. /**
  64959. * Initializes the physics updraft event
  64960. * @param _scene BabylonJS scene
  64961. * @param _origin The origin position of the updraft
  64962. * @param _options The options for the updraft event
  64963. */
  64964. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64965. /**
  64966. * Returns the data related to the updraft event (cylinder).
  64967. * @returns A physics updraft event
  64968. */
  64969. getData(): PhysicsUpdraftEventData;
  64970. /**
  64971. * Enables the updraft.
  64972. */
  64973. enable(): void;
  64974. /**
  64975. * Disables the updraft.
  64976. */
  64977. disable(): void;
  64978. /**
  64979. * Disposes the cylinder.
  64980. * @param force Specifies if the updraft should be disposed by force
  64981. */
  64982. dispose(force?: boolean): void;
  64983. private getImpostorHitData;
  64984. private _tick;
  64985. /*** Helpers ***/
  64986. private _prepareCylinder;
  64987. private _intersectsWithCylinder;
  64988. }
  64989. /**
  64990. * Represents a physics vortex event
  64991. */
  64992. class PhysicsVortexEvent {
  64993. private _scene;
  64994. private _origin;
  64995. private _options;
  64996. private _physicsEngine;
  64997. private _originTop;
  64998. private _tickCallback;
  64999. private _cylinder;
  65000. private _cylinderPosition;
  65001. private _dataFetched;
  65002. /**
  65003. * Initializes the physics vortex event
  65004. * @param _scene The BabylonJS scene
  65005. * @param _origin The origin position of the vortex
  65006. * @param _options The options for the vortex event
  65007. */
  65008. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65009. /**
  65010. * Returns the data related to the vortex event (cylinder).
  65011. * @returns The physics vortex event data
  65012. */
  65013. getData(): PhysicsVortexEventData;
  65014. /**
  65015. * Enables the vortex.
  65016. */
  65017. enable(): void;
  65018. /**
  65019. * Disables the cortex.
  65020. */
  65021. disable(): void;
  65022. /**
  65023. * Disposes the sphere.
  65024. * @param force
  65025. */
  65026. dispose(force?: boolean): void;
  65027. private getImpostorHitData;
  65028. private _tick;
  65029. /*** Helpers ***/
  65030. private _prepareCylinder;
  65031. private _intersectsWithCylinder;
  65032. }
  65033. /**
  65034. * Options fot the radial explosion event
  65035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65036. */
  65037. export class PhysicsRadialExplosionEventOptions {
  65038. /**
  65039. * The radius of the sphere for the radial explosion.
  65040. */
  65041. radius: number;
  65042. /**
  65043. * The strenth of the explosion.
  65044. */
  65045. strength: number;
  65046. /**
  65047. * The strenght of the force in correspondence to the distance of the affected object
  65048. */
  65049. falloff: PhysicsRadialImpulseFalloff;
  65050. /**
  65051. * Sphere options for the radial explosion.
  65052. */
  65053. sphere: {
  65054. segments: number;
  65055. diameter: number;
  65056. };
  65057. /**
  65058. * Sphere options for the radial explosion.
  65059. */
  65060. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65061. }
  65062. /**
  65063. * Options fot the updraft event
  65064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65065. */
  65066. export class PhysicsUpdraftEventOptions {
  65067. /**
  65068. * The radius of the cylinder for the vortex
  65069. */
  65070. radius: number;
  65071. /**
  65072. * The strenth of the updraft.
  65073. */
  65074. strength: number;
  65075. /**
  65076. * The height of the cylinder for the updraft.
  65077. */
  65078. height: number;
  65079. /**
  65080. * The mode for the the updraft.
  65081. */
  65082. updraftMode: PhysicsUpdraftMode;
  65083. }
  65084. /**
  65085. * Options fot the vortex event
  65086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65087. */
  65088. export class PhysicsVortexEventOptions {
  65089. /**
  65090. * The radius of the cylinder for the vortex
  65091. */
  65092. radius: number;
  65093. /**
  65094. * The strenth of the vortex.
  65095. */
  65096. strength: number;
  65097. /**
  65098. * The height of the cylinder for the vortex.
  65099. */
  65100. height: number;
  65101. /**
  65102. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65103. */
  65104. centripetalForceThreshold: number;
  65105. /**
  65106. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65107. */
  65108. centripetalForceMultiplier: number;
  65109. /**
  65110. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65111. */
  65112. centrifugalForceMultiplier: number;
  65113. /**
  65114. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65115. */
  65116. updraftForceMultiplier: number;
  65117. }
  65118. /**
  65119. * The strenght 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 PhysicsRadialImpulseFalloff {
  65123. /** Defines that impulse is constant in strength across it's whole radius */
  65124. Constant = 0,
  65125. /** Defines that impulse gets weaker if it's further from the origin */
  65126. Linear = 1
  65127. }
  65128. /**
  65129. * The strength of the force in correspondence to the distance of the affected object
  65130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65131. */
  65132. export enum PhysicsUpdraftMode {
  65133. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65134. Center = 0,
  65135. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65136. Perpendicular = 1
  65137. }
  65138. /**
  65139. * Interface for a physics hit data
  65140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65141. */
  65142. export interface PhysicsHitData {
  65143. /**
  65144. * The force applied at the contact point
  65145. */
  65146. force: Vector3;
  65147. /**
  65148. * The contact point
  65149. */
  65150. contactPoint: Vector3;
  65151. /**
  65152. * The distance from the origin to the contact point
  65153. */
  65154. distanceFromOrigin: number;
  65155. }
  65156. /**
  65157. * Interface for radial explosion event data
  65158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65159. */
  65160. export interface PhysicsRadialExplosionEventData {
  65161. /**
  65162. * A sphere used for the radial explosion event
  65163. */
  65164. sphere: Mesh;
  65165. }
  65166. /**
  65167. * Interface for gravitational field event data
  65168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65169. */
  65170. export interface PhysicsGravitationalFieldEventData {
  65171. /**
  65172. * A sphere mesh used for the gravitational field event
  65173. */
  65174. sphere: Mesh;
  65175. }
  65176. /**
  65177. * Interface for updraft event data
  65178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65179. */
  65180. export interface PhysicsUpdraftEventData {
  65181. /**
  65182. * A cylinder used for the updraft event
  65183. */
  65184. cylinder: Mesh;
  65185. }
  65186. /**
  65187. * Interface for vortex event data
  65188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65189. */
  65190. export interface PhysicsVortexEventData {
  65191. /**
  65192. * A cylinder used for the vortex event
  65193. */
  65194. cylinder: Mesh;
  65195. }
  65196. /**
  65197. * Interface for an affected physics impostor
  65198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65199. */
  65200. export interface PhysicsAffectedImpostorWithData {
  65201. /**
  65202. * The impostor affected by the effect
  65203. */
  65204. impostor: PhysicsImpostor;
  65205. /**
  65206. * The data about the hit/horce from the explosion
  65207. */
  65208. hitData: PhysicsHitData;
  65209. }
  65210. }
  65211. declare module "babylonjs/Physics/Plugins/index" {
  65212. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  65213. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  65214. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  65215. }
  65216. declare module "babylonjs/Physics/index" {
  65217. export * from "babylonjs/Physics/IPhysicsEngine";
  65218. export * from "babylonjs/Physics/physicsEngine";
  65219. export * from "babylonjs/Physics/physicsEngineComponent";
  65220. export * from "babylonjs/Physics/physicsHelper";
  65221. export * from "babylonjs/Physics/physicsImpostor";
  65222. export * from "babylonjs/Physics/physicsJoint";
  65223. export * from "babylonjs/Physics/Plugins/index";
  65224. }
  65225. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  65226. /** @hidden */
  65227. export var blackAndWhitePixelShader: {
  65228. name: string;
  65229. shader: string;
  65230. };
  65231. }
  65232. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  65233. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65234. import { Camera } from "babylonjs/Cameras/camera";
  65235. import { Engine } from "babylonjs/Engines/engine";
  65236. import "babylonjs/Shaders/blackAndWhite.fragment";
  65237. /**
  65238. * Post process used to render in black and white
  65239. */
  65240. export class BlackAndWhitePostProcess extends PostProcess {
  65241. /**
  65242. * Linear about to convert he result to black and white (default: 1)
  65243. */
  65244. degree: number;
  65245. /**
  65246. * Creates a black and white post process
  65247. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65248. * @param name The name of the effect.
  65249. * @param options The required width/height ratio to downsize to before computing the render pass.
  65250. * @param camera The camera to apply the render pass to.
  65251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65252. * @param engine The engine which the post process will be applied. (default: current engine)
  65253. * @param reusable If the post process can be reused on the same frame. (default: false)
  65254. */
  65255. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65256. }
  65257. }
  65258. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  65259. import { Nullable } from "babylonjs/types";
  65260. import { Camera } from "babylonjs/Cameras/camera";
  65261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65262. import { Engine } from "babylonjs/Engines/engine";
  65263. /**
  65264. * This represents a set of one or more post processes in Babylon.
  65265. * A post process can be used to apply a shader to a texture after it is rendered.
  65266. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65267. */
  65268. export class PostProcessRenderEffect {
  65269. private _postProcesses;
  65270. private _getPostProcesses;
  65271. private _singleInstance;
  65272. private _cameras;
  65273. private _indicesForCamera;
  65274. /**
  65275. * Name of the effect
  65276. * @hidden
  65277. */
  65278. _name: string;
  65279. /**
  65280. * Instantiates a post process render effect.
  65281. * A post process can be used to apply a shader to a texture after it is rendered.
  65282. * @param engine The engine the effect is tied to
  65283. * @param name The name of the effect
  65284. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  65285. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  65286. */
  65287. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  65288. /**
  65289. * Checks if all the post processes in the effect are supported.
  65290. */
  65291. get isSupported(): boolean;
  65292. /**
  65293. * Updates the current state of the effect
  65294. * @hidden
  65295. */
  65296. _update(): void;
  65297. /**
  65298. * Attaches the effect on cameras
  65299. * @param cameras The camera to attach to.
  65300. * @hidden
  65301. */
  65302. _attachCameras(cameras: Camera): void;
  65303. /**
  65304. * Attaches the effect on cameras
  65305. * @param cameras The camera to attach to.
  65306. * @hidden
  65307. */
  65308. _attachCameras(cameras: Camera[]): void;
  65309. /**
  65310. * Detaches the effect on cameras
  65311. * @param cameras The camera to detatch from.
  65312. * @hidden
  65313. */
  65314. _detachCameras(cameras: Camera): void;
  65315. /**
  65316. * Detatches the effect on cameras
  65317. * @param cameras The camera to detatch from.
  65318. * @hidden
  65319. */
  65320. _detachCameras(cameras: Camera[]): void;
  65321. /**
  65322. * Enables the effect on given cameras
  65323. * @param cameras The camera to enable.
  65324. * @hidden
  65325. */
  65326. _enable(cameras: Camera): void;
  65327. /**
  65328. * Enables the effect on given cameras
  65329. * @param cameras The camera to enable.
  65330. * @hidden
  65331. */
  65332. _enable(cameras: Nullable<Camera[]>): void;
  65333. /**
  65334. * Disables the effect on the given cameras
  65335. * @param cameras The camera to disable.
  65336. * @hidden
  65337. */
  65338. _disable(cameras: Camera): void;
  65339. /**
  65340. * Disables the effect on the given cameras
  65341. * @param cameras The camera to disable.
  65342. * @hidden
  65343. */
  65344. _disable(cameras: Nullable<Camera[]>): void;
  65345. /**
  65346. * Gets a list of the post processes contained in the effect.
  65347. * @param camera The camera to get the post processes on.
  65348. * @returns The list of the post processes in the effect.
  65349. */
  65350. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  65351. }
  65352. }
  65353. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  65354. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65355. /** @hidden */
  65356. export var extractHighlightsPixelShader: {
  65357. name: string;
  65358. shader: string;
  65359. };
  65360. }
  65361. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  65362. import { Nullable } from "babylonjs/types";
  65363. import { Camera } from "babylonjs/Cameras/camera";
  65364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65365. import { Engine } from "babylonjs/Engines/engine";
  65366. import "babylonjs/Shaders/extractHighlights.fragment";
  65367. /**
  65368. * 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.
  65369. */
  65370. export class ExtractHighlightsPostProcess extends PostProcess {
  65371. /**
  65372. * The luminance threshold, pixels below this value will be set to black.
  65373. */
  65374. threshold: number;
  65375. /** @hidden */
  65376. _exposure: number;
  65377. /**
  65378. * Post process which has the input texture to be used when performing highlight extraction
  65379. * @hidden
  65380. */
  65381. _inputPostProcess: Nullable<PostProcess>;
  65382. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65383. }
  65384. }
  65385. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  65386. /** @hidden */
  65387. export var bloomMergePixelShader: {
  65388. name: string;
  65389. shader: string;
  65390. };
  65391. }
  65392. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  65393. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65394. import { Nullable } from "babylonjs/types";
  65395. import { Engine } from "babylonjs/Engines/engine";
  65396. import { Camera } from "babylonjs/Cameras/camera";
  65397. import "babylonjs/Shaders/bloomMerge.fragment";
  65398. /**
  65399. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65400. */
  65401. export class BloomMergePostProcess extends PostProcess {
  65402. /** Weight of the bloom to be added to the original input. */
  65403. weight: number;
  65404. /**
  65405. * Creates a new instance of @see BloomMergePostProcess
  65406. * @param name The name of the effect.
  65407. * @param originalFromInput Post process which's input will be used for the merge.
  65408. * @param blurred Blurred highlights post process which's output will be used.
  65409. * @param weight Weight of the bloom to be added to the original input.
  65410. * @param options The required width/height ratio to downsize to before computing the render pass.
  65411. * @param camera The camera to apply the render pass to.
  65412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65413. * @param engine The engine which the post process will be applied. (default: current engine)
  65414. * @param reusable If the post process can be reused on the same frame. (default: false)
  65415. * @param textureType Type of textures used when performing the post process. (default: 0)
  65416. * @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)
  65417. */
  65418. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  65419. /** Weight of the bloom to be added to the original input. */
  65420. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65421. }
  65422. }
  65423. declare module "babylonjs/PostProcesses/bloomEffect" {
  65424. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65425. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65426. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65427. import { Camera } from "babylonjs/Cameras/camera";
  65428. import { Scene } from "babylonjs/scene";
  65429. /**
  65430. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  65431. */
  65432. export class BloomEffect extends PostProcessRenderEffect {
  65433. private bloomScale;
  65434. /**
  65435. * @hidden Internal
  65436. */
  65437. _effects: Array<PostProcess>;
  65438. /**
  65439. * @hidden Internal
  65440. */
  65441. _downscale: ExtractHighlightsPostProcess;
  65442. private _blurX;
  65443. private _blurY;
  65444. private _merge;
  65445. /**
  65446. * The luminance threshold to find bright areas of the image to bloom.
  65447. */
  65448. get threshold(): number;
  65449. set threshold(value: number);
  65450. /**
  65451. * The strength of the bloom.
  65452. */
  65453. get weight(): number;
  65454. set weight(value: number);
  65455. /**
  65456. * Specifies the size of the bloom blur kernel, relative to the final output size
  65457. */
  65458. get kernel(): number;
  65459. set kernel(value: number);
  65460. /**
  65461. * Creates a new instance of @see BloomEffect
  65462. * @param scene The scene the effect belongs to.
  65463. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65464. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65465. * @param bloomWeight The the strength of bloom.
  65466. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65467. * @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)
  65468. */
  65469. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65470. /**
  65471. * Disposes each of the internal effects for a given camera.
  65472. * @param camera The camera to dispose the effect on.
  65473. */
  65474. disposeEffects(camera: Camera): void;
  65475. /**
  65476. * @hidden Internal
  65477. */
  65478. _updateEffects(): void;
  65479. /**
  65480. * Internal
  65481. * @returns if all the contained post processes are ready.
  65482. * @hidden
  65483. */
  65484. _isReady(): boolean;
  65485. }
  65486. }
  65487. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  65488. /** @hidden */
  65489. export var chromaticAberrationPixelShader: {
  65490. name: string;
  65491. shader: string;
  65492. };
  65493. }
  65494. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  65495. import { Vector2 } from "babylonjs/Maths/math.vector";
  65496. import { Nullable } from "babylonjs/types";
  65497. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65498. import { Camera } from "babylonjs/Cameras/camera";
  65499. import { Engine } from "babylonjs/Engines/engine";
  65500. import "babylonjs/Shaders/chromaticAberration.fragment";
  65501. /**
  65502. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65503. */
  65504. export class ChromaticAberrationPostProcess extends PostProcess {
  65505. /**
  65506. * The amount of seperation of rgb channels (default: 30)
  65507. */
  65508. aberrationAmount: number;
  65509. /**
  65510. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65511. */
  65512. radialIntensity: number;
  65513. /**
  65514. * 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))
  65515. */
  65516. direction: Vector2;
  65517. /**
  65518. * 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))
  65519. */
  65520. centerPosition: Vector2;
  65521. /**
  65522. * Creates a new instance ChromaticAberrationPostProcess
  65523. * @param name The name of the effect.
  65524. * @param screenWidth The width of the screen to apply the effect on.
  65525. * @param screenHeight The height of the screen to apply the effect on.
  65526. * @param options The required width/height ratio to downsize to before computing the render pass.
  65527. * @param camera The camera to apply the render pass to.
  65528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65529. * @param engine The engine which the post process will be applied. (default: current engine)
  65530. * @param reusable If the post process can be reused on the same frame. (default: false)
  65531. * @param textureType Type of textures used when performing the post process. (default: 0)
  65532. * @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)
  65533. */
  65534. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65535. }
  65536. }
  65537. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  65538. /** @hidden */
  65539. export var circleOfConfusionPixelShader: {
  65540. name: string;
  65541. shader: string;
  65542. };
  65543. }
  65544. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  65545. import { Nullable } from "babylonjs/types";
  65546. import { Engine } from "babylonjs/Engines/engine";
  65547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65548. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65549. import { Camera } from "babylonjs/Cameras/camera";
  65550. import "babylonjs/Shaders/circleOfConfusion.fragment";
  65551. /**
  65552. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65553. */
  65554. export class CircleOfConfusionPostProcess extends PostProcess {
  65555. /**
  65556. * 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.
  65557. */
  65558. lensSize: number;
  65559. /**
  65560. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65561. */
  65562. fStop: number;
  65563. /**
  65564. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65565. */
  65566. focusDistance: number;
  65567. /**
  65568. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65569. */
  65570. focalLength: number;
  65571. private _depthTexture;
  65572. /**
  65573. * Creates a new instance CircleOfConfusionPostProcess
  65574. * @param name The name of the effect.
  65575. * @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.
  65576. * @param options The required width/height ratio to downsize to before computing the render pass.
  65577. * @param camera The camera to apply the render pass to.
  65578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65579. * @param engine The engine which the post process will be applied. (default: current engine)
  65580. * @param reusable If the post process can be reused on the same frame. (default: false)
  65581. * @param textureType Type of textures used when performing the post process. (default: 0)
  65582. * @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)
  65583. */
  65584. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65585. /**
  65586. * 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.
  65587. */
  65588. set depthTexture(value: RenderTargetTexture);
  65589. }
  65590. }
  65591. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  65592. /** @hidden */
  65593. export var colorCorrectionPixelShader: {
  65594. name: string;
  65595. shader: string;
  65596. };
  65597. }
  65598. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  65599. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65600. import { Engine } from "babylonjs/Engines/engine";
  65601. import { Camera } from "babylonjs/Cameras/camera";
  65602. import "babylonjs/Shaders/colorCorrection.fragment";
  65603. /**
  65604. *
  65605. * This post-process allows the modification of rendered colors by using
  65606. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65607. *
  65608. * The object needs to be provided an url to a texture containing the color
  65609. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65610. * Use an image editing software to tweak the LUT to match your needs.
  65611. *
  65612. * For an example of a color LUT, see here:
  65613. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65614. * For explanations on color grading, see here:
  65615. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65616. *
  65617. */
  65618. export class ColorCorrectionPostProcess extends PostProcess {
  65619. private _colorTableTexture;
  65620. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65621. }
  65622. }
  65623. declare module "babylonjs/Shaders/convolution.fragment" {
  65624. /** @hidden */
  65625. export var convolutionPixelShader: {
  65626. name: string;
  65627. shader: string;
  65628. };
  65629. }
  65630. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  65631. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65632. import { Nullable } from "babylonjs/types";
  65633. import { Camera } from "babylonjs/Cameras/camera";
  65634. import { Engine } from "babylonjs/Engines/engine";
  65635. import "babylonjs/Shaders/convolution.fragment";
  65636. /**
  65637. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65638. * input texture to perform effects such as edge detection or sharpening
  65639. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65640. */
  65641. export class ConvolutionPostProcess extends PostProcess {
  65642. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65643. kernel: number[];
  65644. /**
  65645. * Creates a new instance ConvolutionPostProcess
  65646. * @param name The name of the effect.
  65647. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65648. * @param options The required width/height ratio to downsize to before computing the render pass.
  65649. * @param camera The camera to apply the render pass to.
  65650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65651. * @param engine The engine which the post process will be applied. (default: current engine)
  65652. * @param reusable If the post process can be reused on the same frame. (default: false)
  65653. * @param textureType Type of textures used when performing the post process. (default: 0)
  65654. */
  65655. constructor(name: string,
  65656. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65657. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65658. /**
  65659. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65660. */
  65661. static EdgeDetect0Kernel: number[];
  65662. /**
  65663. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65664. */
  65665. static EdgeDetect1Kernel: number[];
  65666. /**
  65667. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65668. */
  65669. static EdgeDetect2Kernel: number[];
  65670. /**
  65671. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65672. */
  65673. static SharpenKernel: number[];
  65674. /**
  65675. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65676. */
  65677. static EmbossKernel: number[];
  65678. /**
  65679. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65680. */
  65681. static GaussianKernel: number[];
  65682. }
  65683. }
  65684. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  65685. import { Nullable } from "babylonjs/types";
  65686. import { Vector2 } from "babylonjs/Maths/math.vector";
  65687. import { Camera } from "babylonjs/Cameras/camera";
  65688. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65689. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65690. import { Engine } from "babylonjs/Engines/engine";
  65691. import { Scene } from "babylonjs/scene";
  65692. /**
  65693. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65694. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65695. * based on samples that have a large difference in distance than the center pixel.
  65696. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65697. */
  65698. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65699. direction: Vector2;
  65700. /**
  65701. * Creates a new instance CircleOfConfusionPostProcess
  65702. * @param name The name of the effect.
  65703. * @param scene The scene the effect belongs to.
  65704. * @param direction The direction the blur should be applied.
  65705. * @param kernel The size of the kernel used to blur.
  65706. * @param options The required width/height ratio to downsize to before computing the render pass.
  65707. * @param camera The camera to apply the render pass to.
  65708. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65709. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65711. * @param engine The engine which the post process will be applied. (default: current engine)
  65712. * @param reusable If the post process can be reused on the same frame. (default: false)
  65713. * @param textureType Type of textures used when performing the post process. (default: 0)
  65714. * @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)
  65715. */
  65716. 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);
  65717. }
  65718. }
  65719. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  65720. /** @hidden */
  65721. export var depthOfFieldMergePixelShader: {
  65722. name: string;
  65723. shader: string;
  65724. };
  65725. }
  65726. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  65727. import { Nullable } from "babylonjs/types";
  65728. import { Camera } from "babylonjs/Cameras/camera";
  65729. import { Effect } from "babylonjs/Materials/effect";
  65730. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65731. import { Engine } from "babylonjs/Engines/engine";
  65732. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  65733. /**
  65734. * Options to be set when merging outputs from the default pipeline.
  65735. */
  65736. export class DepthOfFieldMergePostProcessOptions {
  65737. /**
  65738. * The original image to merge on top of
  65739. */
  65740. originalFromInput: PostProcess;
  65741. /**
  65742. * Parameters to perform the merge of the depth of field effect
  65743. */
  65744. depthOfField?: {
  65745. circleOfConfusion: PostProcess;
  65746. blurSteps: Array<PostProcess>;
  65747. };
  65748. /**
  65749. * Parameters to perform the merge of bloom effect
  65750. */
  65751. bloom?: {
  65752. blurred: PostProcess;
  65753. weight: number;
  65754. };
  65755. }
  65756. /**
  65757. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65758. */
  65759. export class DepthOfFieldMergePostProcess extends PostProcess {
  65760. private blurSteps;
  65761. /**
  65762. * Creates a new instance of DepthOfFieldMergePostProcess
  65763. * @param name The name of the effect.
  65764. * @param originalFromInput Post process which's input will be used for the merge.
  65765. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65766. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65767. * @param options The required width/height ratio to downsize to before computing the render pass.
  65768. * @param camera The camera to apply the render pass to.
  65769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65770. * @param engine The engine which the post process will be applied. (default: current engine)
  65771. * @param reusable If the post process can be reused on the same frame. (default: false)
  65772. * @param textureType Type of textures used when performing the post process. (default: 0)
  65773. * @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)
  65774. */
  65775. 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);
  65776. /**
  65777. * Updates the effect with the current post process compile time values and recompiles the shader.
  65778. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65779. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65780. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65781. * @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
  65782. * @param onCompiled Called when the shader has been compiled.
  65783. * @param onError Called if there is an error when compiling a shader.
  65784. */
  65785. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65786. }
  65787. }
  65788. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  65789. import { Nullable } from "babylonjs/types";
  65790. import { Camera } from "babylonjs/Cameras/camera";
  65791. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65792. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65793. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65794. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65795. import { Scene } from "babylonjs/scene";
  65796. /**
  65797. * Specifies the level of max blur that should be applied when using the depth of field effect
  65798. */
  65799. export enum DepthOfFieldEffectBlurLevel {
  65800. /**
  65801. * Subtle blur
  65802. */
  65803. Low = 0,
  65804. /**
  65805. * Medium blur
  65806. */
  65807. Medium = 1,
  65808. /**
  65809. * Large blur
  65810. */
  65811. High = 2
  65812. }
  65813. /**
  65814. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65815. */
  65816. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65817. private _circleOfConfusion;
  65818. /**
  65819. * @hidden Internal, blurs from high to low
  65820. */
  65821. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65822. private _depthOfFieldBlurY;
  65823. private _dofMerge;
  65824. /**
  65825. * @hidden Internal post processes in depth of field effect
  65826. */
  65827. _effects: Array<PostProcess>;
  65828. /**
  65829. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65830. */
  65831. set focalLength(value: number);
  65832. get focalLength(): number;
  65833. /**
  65834. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65835. */
  65836. set fStop(value: number);
  65837. get fStop(): number;
  65838. /**
  65839. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65840. */
  65841. set focusDistance(value: number);
  65842. get focusDistance(): number;
  65843. /**
  65844. * 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.
  65845. */
  65846. set lensSize(value: number);
  65847. get lensSize(): number;
  65848. /**
  65849. * Creates a new instance DepthOfFieldEffect
  65850. * @param scene The scene the effect belongs to.
  65851. * @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.
  65852. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65853. * @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)
  65854. */
  65855. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65856. /**
  65857. * Get the current class name of the current effet
  65858. * @returns "DepthOfFieldEffect"
  65859. */
  65860. getClassName(): string;
  65861. /**
  65862. * 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.
  65863. */
  65864. set depthTexture(value: RenderTargetTexture);
  65865. /**
  65866. * Disposes each of the internal effects for a given camera.
  65867. * @param camera The camera to dispose the effect on.
  65868. */
  65869. disposeEffects(camera: Camera): void;
  65870. /**
  65871. * @hidden Internal
  65872. */
  65873. _updateEffects(): void;
  65874. /**
  65875. * Internal
  65876. * @returns if all the contained post processes are ready.
  65877. * @hidden
  65878. */
  65879. _isReady(): boolean;
  65880. }
  65881. }
  65882. declare module "babylonjs/Shaders/displayPass.fragment" {
  65883. /** @hidden */
  65884. export var displayPassPixelShader: {
  65885. name: string;
  65886. shader: string;
  65887. };
  65888. }
  65889. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  65890. import { Nullable } from "babylonjs/types";
  65891. import { Camera } from "babylonjs/Cameras/camera";
  65892. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65893. import { Engine } from "babylonjs/Engines/engine";
  65894. import "babylonjs/Shaders/displayPass.fragment";
  65895. /**
  65896. * DisplayPassPostProcess which produces an output the same as it's input
  65897. */
  65898. export class DisplayPassPostProcess extends PostProcess {
  65899. /**
  65900. * Creates the DisplayPassPostProcess
  65901. * @param name The name of the effect.
  65902. * @param options The required width/height ratio to downsize to before computing the render pass.
  65903. * @param camera The camera to apply the render pass to.
  65904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65905. * @param engine The engine which the post process will be applied. (default: current engine)
  65906. * @param reusable If the post process can be reused on the same frame. (default: false)
  65907. */
  65908. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65909. }
  65910. }
  65911. declare module "babylonjs/Shaders/filter.fragment" {
  65912. /** @hidden */
  65913. export var filterPixelShader: {
  65914. name: string;
  65915. shader: string;
  65916. };
  65917. }
  65918. declare module "babylonjs/PostProcesses/filterPostProcess" {
  65919. import { Nullable } from "babylonjs/types";
  65920. import { Matrix } from "babylonjs/Maths/math.vector";
  65921. import { Camera } from "babylonjs/Cameras/camera";
  65922. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65923. import { Engine } from "babylonjs/Engines/engine";
  65924. import "babylonjs/Shaders/filter.fragment";
  65925. /**
  65926. * Applies a kernel filter to the image
  65927. */
  65928. export class FilterPostProcess extends PostProcess {
  65929. /** The matrix to be applied to the image */
  65930. kernelMatrix: Matrix;
  65931. /**
  65932. *
  65933. * @param name The name of the effect.
  65934. * @param kernelMatrix The matrix to be applied to the image
  65935. * @param options The required width/height ratio to downsize to before computing the render pass.
  65936. * @param camera The camera to apply the render pass to.
  65937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65938. * @param engine The engine which the post process will be applied. (default: current engine)
  65939. * @param reusable If the post process can be reused on the same frame. (default: false)
  65940. */
  65941. constructor(name: string,
  65942. /** The matrix to be applied to the image */
  65943. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65944. }
  65945. }
  65946. declare module "babylonjs/Shaders/fxaa.fragment" {
  65947. /** @hidden */
  65948. export var fxaaPixelShader: {
  65949. name: string;
  65950. shader: string;
  65951. };
  65952. }
  65953. declare module "babylonjs/Shaders/fxaa.vertex" {
  65954. /** @hidden */
  65955. export var fxaaVertexShader: {
  65956. name: string;
  65957. shader: string;
  65958. };
  65959. }
  65960. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  65961. import { Nullable } from "babylonjs/types";
  65962. import { Camera } from "babylonjs/Cameras/camera";
  65963. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65964. import { Engine } from "babylonjs/Engines/engine";
  65965. import "babylonjs/Shaders/fxaa.fragment";
  65966. import "babylonjs/Shaders/fxaa.vertex";
  65967. /**
  65968. * Fxaa post process
  65969. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65970. */
  65971. export class FxaaPostProcess extends PostProcess {
  65972. /** @hidden */
  65973. texelWidth: number;
  65974. /** @hidden */
  65975. texelHeight: number;
  65976. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65977. private _getDefines;
  65978. }
  65979. }
  65980. declare module "babylonjs/Shaders/grain.fragment" {
  65981. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65982. /** @hidden */
  65983. export var grainPixelShader: {
  65984. name: string;
  65985. shader: string;
  65986. };
  65987. }
  65988. declare module "babylonjs/PostProcesses/grainPostProcess" {
  65989. import { Nullable } from "babylonjs/types";
  65990. import { Camera } from "babylonjs/Cameras/camera";
  65991. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65992. import { Engine } from "babylonjs/Engines/engine";
  65993. import "babylonjs/Shaders/grain.fragment";
  65994. /**
  65995. * The GrainPostProcess adds noise to the image at mid luminance levels
  65996. */
  65997. export class GrainPostProcess extends PostProcess {
  65998. /**
  65999. * The intensity of the grain added (default: 30)
  66000. */
  66001. intensity: number;
  66002. /**
  66003. * If the grain should be randomized on every frame
  66004. */
  66005. animated: boolean;
  66006. /**
  66007. * Creates a new instance of @see GrainPostProcess
  66008. * @param name The name of the effect.
  66009. * @param options The required width/height ratio to downsize to before computing the render pass.
  66010. * @param camera The camera to apply the render pass to.
  66011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66012. * @param engine The engine which the post process will be applied. (default: current engine)
  66013. * @param reusable If the post process can be reused on the same frame. (default: false)
  66014. * @param textureType Type of textures used when performing the post process. (default: 0)
  66015. * @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)
  66016. */
  66017. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66018. }
  66019. }
  66020. declare module "babylonjs/Shaders/highlights.fragment" {
  66021. /** @hidden */
  66022. export var highlightsPixelShader: {
  66023. name: string;
  66024. shader: string;
  66025. };
  66026. }
  66027. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66028. import { Nullable } from "babylonjs/types";
  66029. import { Camera } from "babylonjs/Cameras/camera";
  66030. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66031. import { Engine } from "babylonjs/Engines/engine";
  66032. import "babylonjs/Shaders/highlights.fragment";
  66033. /**
  66034. * Extracts highlights from the image
  66035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66036. */
  66037. export class HighlightsPostProcess extends PostProcess {
  66038. /**
  66039. * Extracts highlights from the image
  66040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66041. * @param name The name of the effect.
  66042. * @param options The required width/height ratio to downsize to before computing the render pass.
  66043. * @param camera The camera to apply the render pass to.
  66044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66045. * @param engine The engine which the post process will be applied. (default: current engine)
  66046. * @param reusable If the post process can be reused on the same frame. (default: false)
  66047. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66048. */
  66049. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66050. }
  66051. }
  66052. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66053. /** @hidden */
  66054. export var mrtFragmentDeclaration: {
  66055. name: string;
  66056. shader: string;
  66057. };
  66058. }
  66059. declare module "babylonjs/Shaders/geometry.fragment" {
  66060. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66061. /** @hidden */
  66062. export var geometryPixelShader: {
  66063. name: string;
  66064. shader: string;
  66065. };
  66066. }
  66067. declare module "babylonjs/Shaders/geometry.vertex" {
  66068. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66069. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66070. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66071. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66072. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66073. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66074. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66075. /** @hidden */
  66076. export var geometryVertexShader: {
  66077. name: string;
  66078. shader: string;
  66079. };
  66080. }
  66081. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66082. import { Matrix } from "babylonjs/Maths/math.vector";
  66083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66084. import { Mesh } from "babylonjs/Meshes/mesh";
  66085. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66086. import { Effect } from "babylonjs/Materials/effect";
  66087. import { Scene } from "babylonjs/scene";
  66088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66089. import "babylonjs/Shaders/geometry.fragment";
  66090. import "babylonjs/Shaders/geometry.vertex";
  66091. /** @hidden */
  66092. interface ISavedTransformationMatrix {
  66093. world: Matrix;
  66094. viewProjection: Matrix;
  66095. }
  66096. /**
  66097. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66098. */
  66099. export class GeometryBufferRenderer {
  66100. /**
  66101. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66102. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66103. */
  66104. static readonly POSITION_TEXTURE_TYPE: number;
  66105. /**
  66106. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66107. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66108. */
  66109. static readonly VELOCITY_TEXTURE_TYPE: number;
  66110. /**
  66111. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66112. * in order to compute objects velocities when enableVelocity is set to "true"
  66113. * @hidden
  66114. */
  66115. _previousTransformationMatrices: {
  66116. [index: number]: ISavedTransformationMatrix;
  66117. };
  66118. /**
  66119. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66120. * in order to compute objects velocities when enableVelocity is set to "true"
  66121. * @hidden
  66122. */
  66123. _previousBonesTransformationMatrices: {
  66124. [index: number]: Float32Array;
  66125. };
  66126. /**
  66127. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66128. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66129. */
  66130. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66131. private _scene;
  66132. private _multiRenderTarget;
  66133. private _ratio;
  66134. private _enablePosition;
  66135. private _enableVelocity;
  66136. private _positionIndex;
  66137. private _velocityIndex;
  66138. protected _effect: Effect;
  66139. protected _cachedDefines: string;
  66140. /**
  66141. * Set the render list (meshes to be rendered) used in the G buffer.
  66142. */
  66143. set renderList(meshes: Mesh[]);
  66144. /**
  66145. * Gets wether or not G buffer are supported by the running hardware.
  66146. * This requires draw buffer supports
  66147. */
  66148. get isSupported(): boolean;
  66149. /**
  66150. * Returns the index of the given texture type in the G-Buffer textures array
  66151. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66152. * @returns the index of the given texture type in the G-Buffer textures array
  66153. */
  66154. getTextureIndex(textureType: number): number;
  66155. /**
  66156. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66157. */
  66158. get enablePosition(): boolean;
  66159. /**
  66160. * Sets whether or not objects positions are enabled for the G buffer.
  66161. */
  66162. set enablePosition(enable: boolean);
  66163. /**
  66164. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66165. */
  66166. get enableVelocity(): boolean;
  66167. /**
  66168. * Sets wether or not objects velocities are enabled for the G buffer.
  66169. */
  66170. set enableVelocity(enable: boolean);
  66171. /**
  66172. * Gets the scene associated with the buffer.
  66173. */
  66174. get scene(): Scene;
  66175. /**
  66176. * Gets the ratio used by the buffer during its creation.
  66177. * How big is the buffer related to the main canvas.
  66178. */
  66179. get ratio(): number;
  66180. /** @hidden */
  66181. static _SceneComponentInitialization: (scene: Scene) => void;
  66182. /**
  66183. * Creates a new G Buffer for the scene
  66184. * @param scene The scene the buffer belongs to
  66185. * @param ratio How big is the buffer related to the main canvas.
  66186. */
  66187. constructor(scene: Scene, ratio?: number);
  66188. /**
  66189. * Checks wether everything is ready to render a submesh to the G buffer.
  66190. * @param subMesh the submesh to check readiness for
  66191. * @param useInstances is the mesh drawn using instance or not
  66192. * @returns true if ready otherwise false
  66193. */
  66194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66195. /**
  66196. * Gets the current underlying G Buffer.
  66197. * @returns the buffer
  66198. */
  66199. getGBuffer(): MultiRenderTarget;
  66200. /**
  66201. * Gets the number of samples used to render the buffer (anti aliasing).
  66202. */
  66203. get samples(): number;
  66204. /**
  66205. * Sets the number of samples used to render the buffer (anti aliasing).
  66206. */
  66207. set samples(value: number);
  66208. /**
  66209. * Disposes the renderer and frees up associated resources.
  66210. */
  66211. dispose(): void;
  66212. protected _createRenderTargets(): void;
  66213. private _copyBonesTransformationMatrices;
  66214. }
  66215. }
  66216. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  66217. import { Nullable } from "babylonjs/types";
  66218. import { Scene } from "babylonjs/scene";
  66219. import { ISceneComponent } from "babylonjs/sceneComponent";
  66220. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  66221. module "babylonjs/scene" {
  66222. interface Scene {
  66223. /** @hidden (Backing field) */
  66224. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66225. /**
  66226. * Gets or Sets the current geometry buffer associated to the scene.
  66227. */
  66228. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66229. /**
  66230. * Enables a GeometryBufferRender and associates it with the scene
  66231. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66232. * @returns the GeometryBufferRenderer
  66233. */
  66234. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66235. /**
  66236. * Disables the GeometryBufferRender associated with the scene
  66237. */
  66238. disableGeometryBufferRenderer(): void;
  66239. }
  66240. }
  66241. /**
  66242. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66243. * in several rendering techniques.
  66244. */
  66245. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66246. /**
  66247. * The component name helpful to identify the component in the list of scene components.
  66248. */
  66249. readonly name: string;
  66250. /**
  66251. * The scene the component belongs to.
  66252. */
  66253. scene: Scene;
  66254. /**
  66255. * Creates a new instance of the component for the given scene
  66256. * @param scene Defines the scene to register the component in
  66257. */
  66258. constructor(scene: Scene);
  66259. /**
  66260. * Registers the component in a given scene
  66261. */
  66262. register(): void;
  66263. /**
  66264. * Rebuilds the elements related to this component in case of
  66265. * context lost for instance.
  66266. */
  66267. rebuild(): void;
  66268. /**
  66269. * Disposes the component and the associated ressources
  66270. */
  66271. dispose(): void;
  66272. private _gatherRenderTargets;
  66273. }
  66274. }
  66275. declare module "babylonjs/Shaders/motionBlur.fragment" {
  66276. /** @hidden */
  66277. export var motionBlurPixelShader: {
  66278. name: string;
  66279. shader: string;
  66280. };
  66281. }
  66282. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  66283. import { Nullable } from "babylonjs/types";
  66284. import { Camera } from "babylonjs/Cameras/camera";
  66285. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66286. import { Scene } from "babylonjs/scene";
  66287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66288. import "babylonjs/Animations/animatable";
  66289. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66290. import "babylonjs/Shaders/motionBlur.fragment";
  66291. import { Engine } from "babylonjs/Engines/engine";
  66292. /**
  66293. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66294. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66295. * As an example, all you have to do is to create the post-process:
  66296. * var mb = new BABYLON.MotionBlurPostProcess(
  66297. * 'mb', // The name of the effect.
  66298. * scene, // The scene containing the objects to blur according to their velocity.
  66299. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66300. * camera // The camera to apply the render pass to.
  66301. * );
  66302. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66303. */
  66304. export class MotionBlurPostProcess extends PostProcess {
  66305. /**
  66306. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66307. */
  66308. motionStrength: number;
  66309. /**
  66310. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66311. */
  66312. get motionBlurSamples(): number;
  66313. /**
  66314. * Sets the number of iterations to be used for motion blur quality
  66315. */
  66316. set motionBlurSamples(samples: number);
  66317. private _motionBlurSamples;
  66318. private _geometryBufferRenderer;
  66319. /**
  66320. * Creates a new instance MotionBlurPostProcess
  66321. * @param name The name of the effect.
  66322. * @param scene The scene containing the objects to blur according to their velocity.
  66323. * @param options The required width/height ratio to downsize to before computing the render pass.
  66324. * @param camera The camera to apply the render pass to.
  66325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66326. * @param engine The engine which the post process will be applied. (default: current engine)
  66327. * @param reusable If the post process can be reused on the same frame. (default: false)
  66328. * @param textureType Type of textures used when performing the post process. (default: 0)
  66329. * @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)
  66330. */
  66331. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66332. /**
  66333. * Excludes the given skinned mesh from computing bones velocities.
  66334. * 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.
  66335. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66336. */
  66337. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66338. /**
  66339. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66340. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66341. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66342. */
  66343. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66344. /**
  66345. * Disposes the post process.
  66346. * @param camera The camera to dispose the post process on.
  66347. */
  66348. dispose(camera?: Camera): void;
  66349. }
  66350. }
  66351. declare module "babylonjs/Shaders/refraction.fragment" {
  66352. /** @hidden */
  66353. export var refractionPixelShader: {
  66354. name: string;
  66355. shader: string;
  66356. };
  66357. }
  66358. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  66359. import { Color3 } from "babylonjs/Maths/math.color";
  66360. import { Camera } from "babylonjs/Cameras/camera";
  66361. import { Texture } from "babylonjs/Materials/Textures/texture";
  66362. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66363. import { Engine } from "babylonjs/Engines/engine";
  66364. import "babylonjs/Shaders/refraction.fragment";
  66365. /**
  66366. * Post process which applies a refractin texture
  66367. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66368. */
  66369. export class RefractionPostProcess extends PostProcess {
  66370. /** the base color of the refraction (used to taint the rendering) */
  66371. color: Color3;
  66372. /** simulated refraction depth */
  66373. depth: number;
  66374. /** the coefficient of the base color (0 to remove base color tainting) */
  66375. colorLevel: number;
  66376. private _refTexture;
  66377. private _ownRefractionTexture;
  66378. /**
  66379. * Gets or sets the refraction texture
  66380. * Please note that you are responsible for disposing the texture if you set it manually
  66381. */
  66382. get refractionTexture(): Texture;
  66383. set refractionTexture(value: Texture);
  66384. /**
  66385. * Initializes the RefractionPostProcess
  66386. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66387. * @param name The name of the effect.
  66388. * @param refractionTextureUrl Url of the refraction texture to use
  66389. * @param color the base color of the refraction (used to taint the rendering)
  66390. * @param depth simulated refraction depth
  66391. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  66392. * @param camera The camera to apply the render pass to.
  66393. * @param options The required width/height ratio to downsize to before computing the render pass.
  66394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66395. * @param engine The engine which the post process will be applied. (default: current engine)
  66396. * @param reusable If the post process can be reused on the same frame. (default: false)
  66397. */
  66398. constructor(name: string, refractionTextureUrl: string,
  66399. /** the base color of the refraction (used to taint the rendering) */
  66400. color: Color3,
  66401. /** simulated refraction depth */
  66402. depth: number,
  66403. /** the coefficient of the base color (0 to remove base color tainting) */
  66404. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66405. /**
  66406. * Disposes of the post process
  66407. * @param camera Camera to dispose post process on
  66408. */
  66409. dispose(camera: Camera): void;
  66410. }
  66411. }
  66412. declare module "babylonjs/Shaders/sharpen.fragment" {
  66413. /** @hidden */
  66414. export var sharpenPixelShader: {
  66415. name: string;
  66416. shader: string;
  66417. };
  66418. }
  66419. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  66420. import { Nullable } from "babylonjs/types";
  66421. import { Camera } from "babylonjs/Cameras/camera";
  66422. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66423. import "babylonjs/Shaders/sharpen.fragment";
  66424. import { Engine } from "babylonjs/Engines/engine";
  66425. /**
  66426. * The SharpenPostProcess applies a sharpen kernel to every pixel
  66427. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66428. */
  66429. export class SharpenPostProcess extends PostProcess {
  66430. /**
  66431. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  66432. */
  66433. colorAmount: number;
  66434. /**
  66435. * How much sharpness should be applied (default: 0.3)
  66436. */
  66437. edgeAmount: number;
  66438. /**
  66439. * Creates a new instance ConvolutionPostProcess
  66440. * @param name The name of the effect.
  66441. * @param options The required width/height ratio to downsize to before computing the render pass.
  66442. * @param camera The camera to apply the render pass to.
  66443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66444. * @param engine The engine which the post process will be applied. (default: current engine)
  66445. * @param reusable If the post process can be reused on the same frame. (default: false)
  66446. * @param textureType Type of textures used when performing the post process. (default: 0)
  66447. * @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)
  66448. */
  66449. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66450. }
  66451. }
  66452. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  66453. import { Nullable } from "babylonjs/types";
  66454. import { Camera } from "babylonjs/Cameras/camera";
  66455. import { Engine } from "babylonjs/Engines/engine";
  66456. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66457. import { IInspectable } from "babylonjs/Misc/iInspectable";
  66458. /**
  66459. * PostProcessRenderPipeline
  66460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66461. */
  66462. export class PostProcessRenderPipeline {
  66463. private engine;
  66464. private _renderEffects;
  66465. private _renderEffectsForIsolatedPass;
  66466. /**
  66467. * List of inspectable custom properties (used by the Inspector)
  66468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66469. */
  66470. inspectableCustomProperties: IInspectable[];
  66471. /**
  66472. * @hidden
  66473. */
  66474. protected _cameras: Camera[];
  66475. /** @hidden */
  66476. _name: string;
  66477. /**
  66478. * Gets pipeline name
  66479. */
  66480. get name(): string;
  66481. /** Gets the list of attached cameras */
  66482. get cameras(): Camera[];
  66483. /**
  66484. * Initializes a PostProcessRenderPipeline
  66485. * @param engine engine to add the pipeline to
  66486. * @param name name of the pipeline
  66487. */
  66488. constructor(engine: Engine, name: string);
  66489. /**
  66490. * Gets the class name
  66491. * @returns "PostProcessRenderPipeline"
  66492. */
  66493. getClassName(): string;
  66494. /**
  66495. * If all the render effects in the pipeline are supported
  66496. */
  66497. get isSupported(): boolean;
  66498. /**
  66499. * Adds an effect to the pipeline
  66500. * @param renderEffect the effect to add
  66501. */
  66502. addEffect(renderEffect: PostProcessRenderEffect): void;
  66503. /** @hidden */
  66504. _rebuild(): void;
  66505. /** @hidden */
  66506. _enableEffect(renderEffectName: string, cameras: Camera): void;
  66507. /** @hidden */
  66508. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  66509. /** @hidden */
  66510. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66511. /** @hidden */
  66512. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66513. /** @hidden */
  66514. _attachCameras(cameras: Camera, unique: boolean): void;
  66515. /** @hidden */
  66516. _attachCameras(cameras: Camera[], unique: boolean): void;
  66517. /** @hidden */
  66518. _detachCameras(cameras: Camera): void;
  66519. /** @hidden */
  66520. _detachCameras(cameras: Nullable<Camera[]>): void;
  66521. /** @hidden */
  66522. _update(): void;
  66523. /** @hidden */
  66524. _reset(): void;
  66525. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  66526. /**
  66527. * Disposes of the pipeline
  66528. */
  66529. dispose(): void;
  66530. }
  66531. }
  66532. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  66533. import { Camera } from "babylonjs/Cameras/camera";
  66534. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66535. /**
  66536. * PostProcessRenderPipelineManager class
  66537. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66538. */
  66539. export class PostProcessRenderPipelineManager {
  66540. private _renderPipelines;
  66541. /**
  66542. * Initializes a PostProcessRenderPipelineManager
  66543. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66544. */
  66545. constructor();
  66546. /**
  66547. * Gets the list of supported render pipelines
  66548. */
  66549. get supportedPipelines(): PostProcessRenderPipeline[];
  66550. /**
  66551. * Adds a pipeline to the manager
  66552. * @param renderPipeline The pipeline to add
  66553. */
  66554. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  66555. /**
  66556. * Attaches a camera to the pipeline
  66557. * @param renderPipelineName The name of the pipeline to attach to
  66558. * @param cameras the camera to attach
  66559. * @param unique if the camera can be attached multiple times to the pipeline
  66560. */
  66561. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66562. /**
  66563. * Detaches a camera from the pipeline
  66564. * @param renderPipelineName The name of the pipeline to detach from
  66565. * @param cameras the camera to detach
  66566. */
  66567. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66568. /**
  66569. * Enables an effect by name on a pipeline
  66570. * @param renderPipelineName the name of the pipeline to enable the effect in
  66571. * @param renderEffectName the name of the effect to enable
  66572. * @param cameras the cameras that the effect should be enabled on
  66573. */
  66574. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66575. /**
  66576. * Disables an effect by name on a pipeline
  66577. * @param renderPipelineName the name of the pipeline to disable the effect in
  66578. * @param renderEffectName the name of the effect to disable
  66579. * @param cameras the cameras that the effect should be disabled on
  66580. */
  66581. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66582. /**
  66583. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66584. */
  66585. update(): void;
  66586. /** @hidden */
  66587. _rebuild(): void;
  66588. /**
  66589. * Disposes of the manager and pipelines
  66590. */
  66591. dispose(): void;
  66592. }
  66593. }
  66594. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  66595. import { ISceneComponent } from "babylonjs/sceneComponent";
  66596. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66597. import { Scene } from "babylonjs/scene";
  66598. module "babylonjs/scene" {
  66599. interface Scene {
  66600. /** @hidden (Backing field) */
  66601. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66602. /**
  66603. * Gets the postprocess render pipeline manager
  66604. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66605. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66606. */
  66607. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66608. }
  66609. }
  66610. /**
  66611. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66612. */
  66613. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66614. /**
  66615. * The component name helpfull to identify the component in the list of scene components.
  66616. */
  66617. readonly name: string;
  66618. /**
  66619. * The scene the component belongs to.
  66620. */
  66621. scene: Scene;
  66622. /**
  66623. * Creates a new instance of the component for the given scene
  66624. * @param scene Defines the scene to register the component in
  66625. */
  66626. constructor(scene: Scene);
  66627. /**
  66628. * Registers the component in a given scene
  66629. */
  66630. register(): void;
  66631. /**
  66632. * Rebuilds the elements related to this component in case of
  66633. * context lost for instance.
  66634. */
  66635. rebuild(): void;
  66636. /**
  66637. * Disposes the component and the associated ressources
  66638. */
  66639. dispose(): void;
  66640. private _gatherRenderTargets;
  66641. }
  66642. }
  66643. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  66644. import { Nullable } from "babylonjs/types";
  66645. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66646. import { Camera } from "babylonjs/Cameras/camera";
  66647. import { IDisposable } from "babylonjs/scene";
  66648. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  66649. import { Scene } from "babylonjs/scene";
  66650. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  66651. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66652. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66653. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  66654. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66655. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66656. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  66657. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66658. import { Animation } from "babylonjs/Animations/animation";
  66659. /**
  66660. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66661. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66662. */
  66663. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66664. private _scene;
  66665. private _camerasToBeAttached;
  66666. /**
  66667. * ID of the sharpen post process,
  66668. */
  66669. private readonly SharpenPostProcessId;
  66670. /**
  66671. * @ignore
  66672. * ID of the image processing post process;
  66673. */
  66674. readonly ImageProcessingPostProcessId: string;
  66675. /**
  66676. * @ignore
  66677. * ID of the Fast Approximate Anti-Aliasing post process;
  66678. */
  66679. readonly FxaaPostProcessId: string;
  66680. /**
  66681. * ID of the chromatic aberration post process,
  66682. */
  66683. private readonly ChromaticAberrationPostProcessId;
  66684. /**
  66685. * ID of the grain post process
  66686. */
  66687. private readonly GrainPostProcessId;
  66688. /**
  66689. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66690. */
  66691. sharpen: SharpenPostProcess;
  66692. private _sharpenEffect;
  66693. private bloom;
  66694. /**
  66695. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66696. */
  66697. depthOfField: DepthOfFieldEffect;
  66698. /**
  66699. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66700. */
  66701. fxaa: FxaaPostProcess;
  66702. /**
  66703. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66704. */
  66705. imageProcessing: ImageProcessingPostProcess;
  66706. /**
  66707. * Chromatic aberration post process which will shift rgb colors in the image
  66708. */
  66709. chromaticAberration: ChromaticAberrationPostProcess;
  66710. private _chromaticAberrationEffect;
  66711. /**
  66712. * Grain post process which add noise to the image
  66713. */
  66714. grain: GrainPostProcess;
  66715. private _grainEffect;
  66716. /**
  66717. * Glow post process which adds a glow to emissive areas of the image
  66718. */
  66719. private _glowLayer;
  66720. /**
  66721. * Animations which can be used to tweak settings over a period of time
  66722. */
  66723. animations: Animation[];
  66724. private _imageProcessingConfigurationObserver;
  66725. private _sharpenEnabled;
  66726. private _bloomEnabled;
  66727. private _depthOfFieldEnabled;
  66728. private _depthOfFieldBlurLevel;
  66729. private _fxaaEnabled;
  66730. private _imageProcessingEnabled;
  66731. private _defaultPipelineTextureType;
  66732. private _bloomScale;
  66733. private _chromaticAberrationEnabled;
  66734. private _grainEnabled;
  66735. private _buildAllowed;
  66736. /**
  66737. * Gets active scene
  66738. */
  66739. get scene(): Scene;
  66740. /**
  66741. * Enable or disable the sharpen process from the pipeline
  66742. */
  66743. set sharpenEnabled(enabled: boolean);
  66744. get sharpenEnabled(): boolean;
  66745. private _resizeObserver;
  66746. private _hardwareScaleLevel;
  66747. private _bloomKernel;
  66748. /**
  66749. * Specifies the size of the bloom blur kernel, relative to the final output size
  66750. */
  66751. get bloomKernel(): number;
  66752. set bloomKernel(value: number);
  66753. /**
  66754. * Specifies the weight of the bloom in the final rendering
  66755. */
  66756. private _bloomWeight;
  66757. /**
  66758. * Specifies the luma threshold for the area that will be blurred by the bloom
  66759. */
  66760. private _bloomThreshold;
  66761. private _hdr;
  66762. /**
  66763. * The strength of the bloom.
  66764. */
  66765. set bloomWeight(value: number);
  66766. get bloomWeight(): number;
  66767. /**
  66768. * The strength of the bloom.
  66769. */
  66770. set bloomThreshold(value: number);
  66771. get bloomThreshold(): number;
  66772. /**
  66773. * The scale of the bloom, lower value will provide better performance.
  66774. */
  66775. set bloomScale(value: number);
  66776. get bloomScale(): number;
  66777. /**
  66778. * Enable or disable the bloom from the pipeline
  66779. */
  66780. set bloomEnabled(enabled: boolean);
  66781. get bloomEnabled(): boolean;
  66782. private _rebuildBloom;
  66783. /**
  66784. * If the depth of field is enabled.
  66785. */
  66786. get depthOfFieldEnabled(): boolean;
  66787. set depthOfFieldEnabled(enabled: boolean);
  66788. /**
  66789. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66790. */
  66791. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66792. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66793. /**
  66794. * If the anti aliasing is enabled.
  66795. */
  66796. set fxaaEnabled(enabled: boolean);
  66797. get fxaaEnabled(): boolean;
  66798. private _samples;
  66799. /**
  66800. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66801. */
  66802. set samples(sampleCount: number);
  66803. get samples(): number;
  66804. /**
  66805. * If image processing is enabled.
  66806. */
  66807. set imageProcessingEnabled(enabled: boolean);
  66808. get imageProcessingEnabled(): boolean;
  66809. /**
  66810. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66811. */
  66812. set glowLayerEnabled(enabled: boolean);
  66813. get glowLayerEnabled(): boolean;
  66814. /**
  66815. * Gets the glow layer (or null if not defined)
  66816. */
  66817. get glowLayer(): Nullable<GlowLayer>;
  66818. /**
  66819. * Enable or disable the chromaticAberration process from the pipeline
  66820. */
  66821. set chromaticAberrationEnabled(enabled: boolean);
  66822. get chromaticAberrationEnabled(): boolean;
  66823. /**
  66824. * Enable or disable the grain process from the pipeline
  66825. */
  66826. set grainEnabled(enabled: boolean);
  66827. get grainEnabled(): boolean;
  66828. /**
  66829. * @constructor
  66830. * @param name - The rendering pipeline name (default: "")
  66831. * @param hdr - If high dynamic range textures should be used (default: true)
  66832. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66833. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66834. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66835. */
  66836. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66837. /**
  66838. * Get the class name
  66839. * @returns "DefaultRenderingPipeline"
  66840. */
  66841. getClassName(): string;
  66842. /**
  66843. * Force the compilation of the entire pipeline.
  66844. */
  66845. prepare(): void;
  66846. private _hasCleared;
  66847. private _prevPostProcess;
  66848. private _prevPrevPostProcess;
  66849. private _setAutoClearAndTextureSharing;
  66850. private _depthOfFieldSceneObserver;
  66851. private _buildPipeline;
  66852. private _disposePostProcesses;
  66853. /**
  66854. * Adds a camera to the pipeline
  66855. * @param camera the camera to be added
  66856. */
  66857. addCamera(camera: Camera): void;
  66858. /**
  66859. * Removes a camera from the pipeline
  66860. * @param camera the camera to remove
  66861. */
  66862. removeCamera(camera: Camera): void;
  66863. /**
  66864. * Dispose of the pipeline and stop all post processes
  66865. */
  66866. dispose(): void;
  66867. /**
  66868. * Serialize the rendering pipeline (Used when exporting)
  66869. * @returns the serialized object
  66870. */
  66871. serialize(): any;
  66872. /**
  66873. * Parse the serialized pipeline
  66874. * @param source Source pipeline.
  66875. * @param scene The scene to load the pipeline to.
  66876. * @param rootUrl The URL of the serialized pipeline.
  66877. * @returns An instantiated pipeline from the serialized object.
  66878. */
  66879. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66880. }
  66881. }
  66882. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  66883. /** @hidden */
  66884. export var lensHighlightsPixelShader: {
  66885. name: string;
  66886. shader: string;
  66887. };
  66888. }
  66889. declare module "babylonjs/Shaders/depthOfField.fragment" {
  66890. /** @hidden */
  66891. export var depthOfFieldPixelShader: {
  66892. name: string;
  66893. shader: string;
  66894. };
  66895. }
  66896. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  66897. import { Camera } from "babylonjs/Cameras/camera";
  66898. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66899. import { Scene } from "babylonjs/scene";
  66900. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66901. import "babylonjs/Shaders/chromaticAberration.fragment";
  66902. import "babylonjs/Shaders/lensHighlights.fragment";
  66903. import "babylonjs/Shaders/depthOfField.fragment";
  66904. /**
  66905. * BABYLON.JS Chromatic Aberration GLSL Shader
  66906. * Author: Olivier Guyot
  66907. * Separates very slightly R, G and B colors on the edges of the screen
  66908. * Inspired by Francois Tarlier & Martins Upitis
  66909. */
  66910. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66911. /**
  66912. * @ignore
  66913. * The chromatic aberration PostProcess id in the pipeline
  66914. */
  66915. LensChromaticAberrationEffect: string;
  66916. /**
  66917. * @ignore
  66918. * The highlights enhancing PostProcess id in the pipeline
  66919. */
  66920. HighlightsEnhancingEffect: string;
  66921. /**
  66922. * @ignore
  66923. * The depth-of-field PostProcess id in the pipeline
  66924. */
  66925. LensDepthOfFieldEffect: string;
  66926. private _scene;
  66927. private _depthTexture;
  66928. private _grainTexture;
  66929. private _chromaticAberrationPostProcess;
  66930. private _highlightsPostProcess;
  66931. private _depthOfFieldPostProcess;
  66932. private _edgeBlur;
  66933. private _grainAmount;
  66934. private _chromaticAberration;
  66935. private _distortion;
  66936. private _highlightsGain;
  66937. private _highlightsThreshold;
  66938. private _dofDistance;
  66939. private _dofAperture;
  66940. private _dofDarken;
  66941. private _dofPentagon;
  66942. private _blurNoise;
  66943. /**
  66944. * @constructor
  66945. *
  66946. * Effect parameters are as follow:
  66947. * {
  66948. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66949. * edge_blur: number; // from 0 to x (1 for realism)
  66950. * distortion: number; // from 0 to x (1 for realism)
  66951. * grain_amount: number; // from 0 to 1
  66952. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66953. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66954. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66955. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66956. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66957. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66958. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66959. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66960. * }
  66961. * Note: if an effect parameter is unset, effect is disabled
  66962. *
  66963. * @param name The rendering pipeline name
  66964. * @param parameters - An object containing all parameters (see above)
  66965. * @param scene The scene linked to this pipeline
  66966. * @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)
  66967. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66968. */
  66969. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66970. /**
  66971. * Get the class name
  66972. * @returns "LensRenderingPipeline"
  66973. */
  66974. getClassName(): string;
  66975. /**
  66976. * Gets associated scene
  66977. */
  66978. get scene(): Scene;
  66979. /**
  66980. * Gets or sets the edge blur
  66981. */
  66982. get edgeBlur(): number;
  66983. set edgeBlur(value: number);
  66984. /**
  66985. * Gets or sets the grain amount
  66986. */
  66987. get grainAmount(): number;
  66988. set grainAmount(value: number);
  66989. /**
  66990. * Gets or sets the chromatic aberration amount
  66991. */
  66992. get chromaticAberration(): number;
  66993. set chromaticAberration(value: number);
  66994. /**
  66995. * Gets or sets the depth of field aperture
  66996. */
  66997. get dofAperture(): number;
  66998. set dofAperture(value: number);
  66999. /**
  67000. * Gets or sets the edge distortion
  67001. */
  67002. get edgeDistortion(): number;
  67003. set edgeDistortion(value: number);
  67004. /**
  67005. * Gets or sets the depth of field distortion
  67006. */
  67007. get dofDistortion(): number;
  67008. set dofDistortion(value: number);
  67009. /**
  67010. * Gets or sets the darken out of focus amount
  67011. */
  67012. get darkenOutOfFocus(): number;
  67013. set darkenOutOfFocus(value: number);
  67014. /**
  67015. * Gets or sets a boolean indicating if blur noise is enabled
  67016. */
  67017. get blurNoise(): boolean;
  67018. set blurNoise(value: boolean);
  67019. /**
  67020. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67021. */
  67022. get pentagonBokeh(): boolean;
  67023. set pentagonBokeh(value: boolean);
  67024. /**
  67025. * Gets or sets the highlight grain amount
  67026. */
  67027. get highlightsGain(): number;
  67028. set highlightsGain(value: number);
  67029. /**
  67030. * Gets or sets the highlight threshold
  67031. */
  67032. get highlightsThreshold(): number;
  67033. set highlightsThreshold(value: number);
  67034. /**
  67035. * Sets the amount of blur at the edges
  67036. * @param amount blur amount
  67037. */
  67038. setEdgeBlur(amount: number): void;
  67039. /**
  67040. * Sets edge blur to 0
  67041. */
  67042. disableEdgeBlur(): void;
  67043. /**
  67044. * Sets the amout of grain
  67045. * @param amount Amount of grain
  67046. */
  67047. setGrainAmount(amount: number): void;
  67048. /**
  67049. * Set grain amount to 0
  67050. */
  67051. disableGrain(): void;
  67052. /**
  67053. * Sets the chromatic aberration amount
  67054. * @param amount amount of chromatic aberration
  67055. */
  67056. setChromaticAberration(amount: number): void;
  67057. /**
  67058. * Sets chromatic aberration amount to 0
  67059. */
  67060. disableChromaticAberration(): void;
  67061. /**
  67062. * Sets the EdgeDistortion amount
  67063. * @param amount amount of EdgeDistortion
  67064. */
  67065. setEdgeDistortion(amount: number): void;
  67066. /**
  67067. * Sets edge distortion to 0
  67068. */
  67069. disableEdgeDistortion(): void;
  67070. /**
  67071. * Sets the FocusDistance amount
  67072. * @param amount amount of FocusDistance
  67073. */
  67074. setFocusDistance(amount: number): void;
  67075. /**
  67076. * Disables depth of field
  67077. */
  67078. disableDepthOfField(): void;
  67079. /**
  67080. * Sets the Aperture amount
  67081. * @param amount amount of Aperture
  67082. */
  67083. setAperture(amount: number): void;
  67084. /**
  67085. * Sets the DarkenOutOfFocus amount
  67086. * @param amount amount of DarkenOutOfFocus
  67087. */
  67088. setDarkenOutOfFocus(amount: number): void;
  67089. private _pentagonBokehIsEnabled;
  67090. /**
  67091. * Creates a pentagon bokeh effect
  67092. */
  67093. enablePentagonBokeh(): void;
  67094. /**
  67095. * Disables the pentagon bokeh effect
  67096. */
  67097. disablePentagonBokeh(): void;
  67098. /**
  67099. * Enables noise blur
  67100. */
  67101. enableNoiseBlur(): void;
  67102. /**
  67103. * Disables noise blur
  67104. */
  67105. disableNoiseBlur(): void;
  67106. /**
  67107. * Sets the HighlightsGain amount
  67108. * @param amount amount of HighlightsGain
  67109. */
  67110. setHighlightsGain(amount: number): void;
  67111. /**
  67112. * Sets the HighlightsThreshold amount
  67113. * @param amount amount of HighlightsThreshold
  67114. */
  67115. setHighlightsThreshold(amount: number): void;
  67116. /**
  67117. * Disables highlights
  67118. */
  67119. disableHighlights(): void;
  67120. /**
  67121. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67122. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67123. */
  67124. dispose(disableDepthRender?: boolean): void;
  67125. private _createChromaticAberrationPostProcess;
  67126. private _createHighlightsPostProcess;
  67127. private _createDepthOfFieldPostProcess;
  67128. private _createGrainTexture;
  67129. }
  67130. }
  67131. declare module "babylonjs/Shaders/ssao2.fragment" {
  67132. /** @hidden */
  67133. export var ssao2PixelShader: {
  67134. name: string;
  67135. shader: string;
  67136. };
  67137. }
  67138. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67139. /** @hidden */
  67140. export var ssaoCombinePixelShader: {
  67141. name: string;
  67142. shader: string;
  67143. };
  67144. }
  67145. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67146. import { Camera } from "babylonjs/Cameras/camera";
  67147. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67148. import { Scene } from "babylonjs/scene";
  67149. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67150. import "babylonjs/Shaders/ssao2.fragment";
  67151. import "babylonjs/Shaders/ssaoCombine.fragment";
  67152. /**
  67153. * Render pipeline to produce ssao effect
  67154. */
  67155. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67156. /**
  67157. * @ignore
  67158. * The PassPostProcess id in the pipeline that contains the original scene color
  67159. */
  67160. SSAOOriginalSceneColorEffect: string;
  67161. /**
  67162. * @ignore
  67163. * The SSAO PostProcess id in the pipeline
  67164. */
  67165. SSAORenderEffect: string;
  67166. /**
  67167. * @ignore
  67168. * The horizontal blur PostProcess id in the pipeline
  67169. */
  67170. SSAOBlurHRenderEffect: string;
  67171. /**
  67172. * @ignore
  67173. * The vertical blur PostProcess id in the pipeline
  67174. */
  67175. SSAOBlurVRenderEffect: string;
  67176. /**
  67177. * @ignore
  67178. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67179. */
  67180. SSAOCombineRenderEffect: string;
  67181. /**
  67182. * The output strength of the SSAO post-process. Default value is 1.0.
  67183. */
  67184. totalStrength: number;
  67185. /**
  67186. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67187. */
  67188. maxZ: number;
  67189. /**
  67190. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67191. */
  67192. minZAspect: number;
  67193. private _samples;
  67194. /**
  67195. * Number of samples used for the SSAO calculations. Default value is 8
  67196. */
  67197. set samples(n: number);
  67198. get samples(): number;
  67199. private _textureSamples;
  67200. /**
  67201. * Number of samples to use for antialiasing
  67202. */
  67203. set textureSamples(n: number);
  67204. get textureSamples(): number;
  67205. /**
  67206. * Ratio object used for SSAO ratio and blur ratio
  67207. */
  67208. private _ratio;
  67209. /**
  67210. * Dynamically generated sphere sampler.
  67211. */
  67212. private _sampleSphere;
  67213. /**
  67214. * Blur filter offsets
  67215. */
  67216. private _samplerOffsets;
  67217. private _expensiveBlur;
  67218. /**
  67219. * If bilateral blur should be used
  67220. */
  67221. set expensiveBlur(b: boolean);
  67222. get expensiveBlur(): boolean;
  67223. /**
  67224. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67225. */
  67226. radius: number;
  67227. /**
  67228. * The base color of the SSAO post-process
  67229. * The final result is "base + ssao" between [0, 1]
  67230. */
  67231. base: number;
  67232. /**
  67233. * Support test.
  67234. */
  67235. static get IsSupported(): boolean;
  67236. private _scene;
  67237. private _depthTexture;
  67238. private _normalTexture;
  67239. private _randomTexture;
  67240. private _originalColorPostProcess;
  67241. private _ssaoPostProcess;
  67242. private _blurHPostProcess;
  67243. private _blurVPostProcess;
  67244. private _ssaoCombinePostProcess;
  67245. /**
  67246. * Gets active scene
  67247. */
  67248. get scene(): Scene;
  67249. /**
  67250. * @constructor
  67251. * @param name The rendering pipeline name
  67252. * @param scene The scene linked to this pipeline
  67253. * @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 }
  67254. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67255. */
  67256. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67257. /**
  67258. * Get the class name
  67259. * @returns "SSAO2RenderingPipeline"
  67260. */
  67261. getClassName(): string;
  67262. /**
  67263. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67264. */
  67265. dispose(disableGeometryBufferRenderer?: boolean): void;
  67266. private _createBlurPostProcess;
  67267. /** @hidden */
  67268. _rebuild(): void;
  67269. private _bits;
  67270. private _radicalInverse_VdC;
  67271. private _hammersley;
  67272. private _hemisphereSample_uniform;
  67273. private _generateHemisphere;
  67274. private _createSSAOPostProcess;
  67275. private _createSSAOCombinePostProcess;
  67276. private _createRandomTexture;
  67277. /**
  67278. * Serialize the rendering pipeline (Used when exporting)
  67279. * @returns the serialized object
  67280. */
  67281. serialize(): any;
  67282. /**
  67283. * Parse the serialized pipeline
  67284. * @param source Source pipeline.
  67285. * @param scene The scene to load the pipeline to.
  67286. * @param rootUrl The URL of the serialized pipeline.
  67287. * @returns An instantiated pipeline from the serialized object.
  67288. */
  67289. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67290. }
  67291. }
  67292. declare module "babylonjs/Shaders/ssao.fragment" {
  67293. /** @hidden */
  67294. export var ssaoPixelShader: {
  67295. name: string;
  67296. shader: string;
  67297. };
  67298. }
  67299. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  67300. import { Camera } from "babylonjs/Cameras/camera";
  67301. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67302. import { Scene } from "babylonjs/scene";
  67303. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67304. import "babylonjs/Shaders/ssao.fragment";
  67305. import "babylonjs/Shaders/ssaoCombine.fragment";
  67306. /**
  67307. * Render pipeline to produce ssao effect
  67308. */
  67309. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67310. /**
  67311. * @ignore
  67312. * The PassPostProcess id in the pipeline that contains the original scene color
  67313. */
  67314. SSAOOriginalSceneColorEffect: string;
  67315. /**
  67316. * @ignore
  67317. * The SSAO PostProcess id in the pipeline
  67318. */
  67319. SSAORenderEffect: string;
  67320. /**
  67321. * @ignore
  67322. * The horizontal blur PostProcess id in the pipeline
  67323. */
  67324. SSAOBlurHRenderEffect: string;
  67325. /**
  67326. * @ignore
  67327. * The vertical blur PostProcess id in the pipeline
  67328. */
  67329. SSAOBlurVRenderEffect: string;
  67330. /**
  67331. * @ignore
  67332. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67333. */
  67334. SSAOCombineRenderEffect: string;
  67335. /**
  67336. * The output strength of the SSAO post-process. Default value is 1.0.
  67337. */
  67338. totalStrength: number;
  67339. /**
  67340. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67341. */
  67342. radius: number;
  67343. /**
  67344. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67345. * Must not be equal to fallOff and superior to fallOff.
  67346. * Default value is 0.0075
  67347. */
  67348. area: number;
  67349. /**
  67350. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67351. * Must not be equal to area and inferior to area.
  67352. * Default value is 0.000001
  67353. */
  67354. fallOff: number;
  67355. /**
  67356. * The base color of the SSAO post-process
  67357. * The final result is "base + ssao" between [0, 1]
  67358. */
  67359. base: number;
  67360. private _scene;
  67361. private _depthTexture;
  67362. private _randomTexture;
  67363. private _originalColorPostProcess;
  67364. private _ssaoPostProcess;
  67365. private _blurHPostProcess;
  67366. private _blurVPostProcess;
  67367. private _ssaoCombinePostProcess;
  67368. private _firstUpdate;
  67369. /**
  67370. * Gets active scene
  67371. */
  67372. get scene(): Scene;
  67373. /**
  67374. * @constructor
  67375. * @param name - The rendering pipeline name
  67376. * @param scene - The scene linked to this pipeline
  67377. * @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 }
  67378. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67379. */
  67380. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67381. /**
  67382. * Get the class name
  67383. * @returns "SSAORenderingPipeline"
  67384. */
  67385. getClassName(): string;
  67386. /**
  67387. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67388. */
  67389. dispose(disableDepthRender?: boolean): void;
  67390. private _createBlurPostProcess;
  67391. /** @hidden */
  67392. _rebuild(): void;
  67393. private _createSSAOPostProcess;
  67394. private _createSSAOCombinePostProcess;
  67395. private _createRandomTexture;
  67396. }
  67397. }
  67398. declare module "babylonjs/Shaders/standard.fragment" {
  67399. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67400. /** @hidden */
  67401. export var standardPixelShader: {
  67402. name: string;
  67403. shader: string;
  67404. };
  67405. }
  67406. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  67407. import { Nullable } from "babylonjs/types";
  67408. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67409. import { Camera } from "babylonjs/Cameras/camera";
  67410. import { Texture } from "babylonjs/Materials/Textures/texture";
  67411. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67412. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67413. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67414. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67415. import { IDisposable } from "babylonjs/scene";
  67416. import { SpotLight } from "babylonjs/Lights/spotLight";
  67417. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67418. import { Scene } from "babylonjs/scene";
  67419. import { Animation } from "babylonjs/Animations/animation";
  67420. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67421. import "babylonjs/Shaders/standard.fragment";
  67422. /**
  67423. * Standard rendering pipeline
  67424. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67425. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  67426. */
  67427. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67428. /**
  67429. * Public members
  67430. */
  67431. /**
  67432. * Post-process which contains the original scene color before the pipeline applies all the effects
  67433. */
  67434. originalPostProcess: Nullable<PostProcess>;
  67435. /**
  67436. * Post-process used to down scale an image x4
  67437. */
  67438. downSampleX4PostProcess: Nullable<PostProcess>;
  67439. /**
  67440. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  67441. */
  67442. brightPassPostProcess: Nullable<PostProcess>;
  67443. /**
  67444. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  67445. */
  67446. blurHPostProcesses: PostProcess[];
  67447. /**
  67448. * Post-process array storing all the vertical blur post-processes used by the pipeline
  67449. */
  67450. blurVPostProcesses: PostProcess[];
  67451. /**
  67452. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  67453. */
  67454. textureAdderPostProcess: Nullable<PostProcess>;
  67455. /**
  67456. * Post-process used to create volumetric lighting effect
  67457. */
  67458. volumetricLightPostProcess: Nullable<PostProcess>;
  67459. /**
  67460. * Post-process used to smooth the previous volumetric light post-process on the X axis
  67461. */
  67462. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  67463. /**
  67464. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  67465. */
  67466. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  67467. /**
  67468. * Post-process used to merge the volumetric light effect and the real scene color
  67469. */
  67470. volumetricLightMergePostProces: Nullable<PostProcess>;
  67471. /**
  67472. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  67473. */
  67474. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  67475. /**
  67476. * Base post-process used to calculate the average luminance of the final image for HDR
  67477. */
  67478. luminancePostProcess: Nullable<PostProcess>;
  67479. /**
  67480. * Post-processes used to create down sample post-processes in order to get
  67481. * the average luminance of the final image for HDR
  67482. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  67483. */
  67484. luminanceDownSamplePostProcesses: PostProcess[];
  67485. /**
  67486. * Post-process used to create a HDR effect (light adaptation)
  67487. */
  67488. hdrPostProcess: Nullable<PostProcess>;
  67489. /**
  67490. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  67491. */
  67492. textureAdderFinalPostProcess: Nullable<PostProcess>;
  67493. /**
  67494. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  67495. */
  67496. lensFlareFinalPostProcess: Nullable<PostProcess>;
  67497. /**
  67498. * Post-process used to merge the final HDR post-process and the real scene color
  67499. */
  67500. hdrFinalPostProcess: Nullable<PostProcess>;
  67501. /**
  67502. * Post-process used to create a lens flare effect
  67503. */
  67504. lensFlarePostProcess: Nullable<PostProcess>;
  67505. /**
  67506. * Post-process that merges the result of the lens flare post-process and the real scene color
  67507. */
  67508. lensFlareComposePostProcess: Nullable<PostProcess>;
  67509. /**
  67510. * Post-process used to create a motion blur effect
  67511. */
  67512. motionBlurPostProcess: Nullable<PostProcess>;
  67513. /**
  67514. * Post-process used to create a depth of field effect
  67515. */
  67516. depthOfFieldPostProcess: Nullable<PostProcess>;
  67517. /**
  67518. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67519. */
  67520. fxaaPostProcess: Nullable<FxaaPostProcess>;
  67521. /**
  67522. * Represents the brightness threshold in order to configure the illuminated surfaces
  67523. */
  67524. brightThreshold: number;
  67525. /**
  67526. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  67527. */
  67528. blurWidth: number;
  67529. /**
  67530. * Sets if the blur for highlighted surfaces must be only horizontal
  67531. */
  67532. horizontalBlur: boolean;
  67533. /**
  67534. * Gets the overall exposure used by the pipeline
  67535. */
  67536. get exposure(): number;
  67537. /**
  67538. * Sets the overall exposure used by the pipeline
  67539. */
  67540. set exposure(value: number);
  67541. /**
  67542. * Texture used typically to simulate "dirty" on camera lens
  67543. */
  67544. lensTexture: Nullable<Texture>;
  67545. /**
  67546. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67547. */
  67548. volumetricLightCoefficient: number;
  67549. /**
  67550. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67551. */
  67552. volumetricLightPower: number;
  67553. /**
  67554. * Used the set the blur intensity to smooth the volumetric lights
  67555. */
  67556. volumetricLightBlurScale: number;
  67557. /**
  67558. * Light (spot or directional) used to generate the volumetric lights rays
  67559. * The source light must have a shadow generate so the pipeline can get its
  67560. * depth map
  67561. */
  67562. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67563. /**
  67564. * For eye adaptation, represents the minimum luminance the eye can see
  67565. */
  67566. hdrMinimumLuminance: number;
  67567. /**
  67568. * For eye adaptation, represents the decrease luminance speed
  67569. */
  67570. hdrDecreaseRate: number;
  67571. /**
  67572. * For eye adaptation, represents the increase luminance speed
  67573. */
  67574. hdrIncreaseRate: number;
  67575. /**
  67576. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67577. */
  67578. get hdrAutoExposure(): boolean;
  67579. /**
  67580. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67581. */
  67582. set hdrAutoExposure(value: boolean);
  67583. /**
  67584. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67585. */
  67586. lensColorTexture: Nullable<Texture>;
  67587. /**
  67588. * The overall strengh for the lens flare effect
  67589. */
  67590. lensFlareStrength: number;
  67591. /**
  67592. * Dispersion coefficient for lens flare ghosts
  67593. */
  67594. lensFlareGhostDispersal: number;
  67595. /**
  67596. * Main lens flare halo width
  67597. */
  67598. lensFlareHaloWidth: number;
  67599. /**
  67600. * Based on the lens distortion effect, defines how much the lens flare result
  67601. * is distorted
  67602. */
  67603. lensFlareDistortionStrength: number;
  67604. /**
  67605. * Configures the blur intensity used for for lens flare (halo)
  67606. */
  67607. lensFlareBlurWidth: number;
  67608. /**
  67609. * Lens star texture must be used to simulate rays on the flares and is available
  67610. * in the documentation
  67611. */
  67612. lensStarTexture: Nullable<Texture>;
  67613. /**
  67614. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67615. * flare effect by taking account of the dirt texture
  67616. */
  67617. lensFlareDirtTexture: Nullable<Texture>;
  67618. /**
  67619. * Represents the focal length for the depth of field effect
  67620. */
  67621. depthOfFieldDistance: number;
  67622. /**
  67623. * Represents the blur intensity for the blurred part of the depth of field effect
  67624. */
  67625. depthOfFieldBlurWidth: number;
  67626. /**
  67627. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67628. */
  67629. get motionStrength(): number;
  67630. /**
  67631. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67632. */
  67633. set motionStrength(strength: number);
  67634. /**
  67635. * Gets wether or not the motion blur post-process is object based or screen based.
  67636. */
  67637. get objectBasedMotionBlur(): boolean;
  67638. /**
  67639. * Sets wether or not the motion blur post-process should be object based or screen based
  67640. */
  67641. set objectBasedMotionBlur(value: boolean);
  67642. /**
  67643. * List of animations for the pipeline (IAnimatable implementation)
  67644. */
  67645. animations: Animation[];
  67646. /**
  67647. * Private members
  67648. */
  67649. private _scene;
  67650. private _currentDepthOfFieldSource;
  67651. private _basePostProcess;
  67652. private _fixedExposure;
  67653. private _currentExposure;
  67654. private _hdrAutoExposure;
  67655. private _hdrCurrentLuminance;
  67656. private _motionStrength;
  67657. private _isObjectBasedMotionBlur;
  67658. private _floatTextureType;
  67659. private _camerasToBeAttached;
  67660. private _ratio;
  67661. private _bloomEnabled;
  67662. private _depthOfFieldEnabled;
  67663. private _vlsEnabled;
  67664. private _lensFlareEnabled;
  67665. private _hdrEnabled;
  67666. private _motionBlurEnabled;
  67667. private _fxaaEnabled;
  67668. private _motionBlurSamples;
  67669. private _volumetricLightStepsCount;
  67670. private _samples;
  67671. /**
  67672. * @ignore
  67673. * Specifies if the bloom pipeline is enabled
  67674. */
  67675. get BloomEnabled(): boolean;
  67676. set BloomEnabled(enabled: boolean);
  67677. /**
  67678. * @ignore
  67679. * Specifies if the depth of field pipeline is enabed
  67680. */
  67681. get DepthOfFieldEnabled(): boolean;
  67682. set DepthOfFieldEnabled(enabled: boolean);
  67683. /**
  67684. * @ignore
  67685. * Specifies if the lens flare pipeline is enabed
  67686. */
  67687. get LensFlareEnabled(): boolean;
  67688. set LensFlareEnabled(enabled: boolean);
  67689. /**
  67690. * @ignore
  67691. * Specifies if the HDR pipeline is enabled
  67692. */
  67693. get HDREnabled(): boolean;
  67694. set HDREnabled(enabled: boolean);
  67695. /**
  67696. * @ignore
  67697. * Specifies if the volumetric lights scattering effect is enabled
  67698. */
  67699. get VLSEnabled(): boolean;
  67700. set VLSEnabled(enabled: boolean);
  67701. /**
  67702. * @ignore
  67703. * Specifies if the motion blur effect is enabled
  67704. */
  67705. get MotionBlurEnabled(): boolean;
  67706. set MotionBlurEnabled(enabled: boolean);
  67707. /**
  67708. * Specifies if anti-aliasing is enabled
  67709. */
  67710. get fxaaEnabled(): boolean;
  67711. set fxaaEnabled(enabled: boolean);
  67712. /**
  67713. * Specifies the number of steps used to calculate the volumetric lights
  67714. * Typically in interval [50, 200]
  67715. */
  67716. get volumetricLightStepsCount(): number;
  67717. set volumetricLightStepsCount(count: number);
  67718. /**
  67719. * Specifies the number of samples used for the motion blur effect
  67720. * Typically in interval [16, 64]
  67721. */
  67722. get motionBlurSamples(): number;
  67723. set motionBlurSamples(samples: number);
  67724. /**
  67725. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67726. */
  67727. get samples(): number;
  67728. set samples(sampleCount: number);
  67729. /**
  67730. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67731. * @constructor
  67732. * @param name The rendering pipeline name
  67733. * @param scene The scene linked to this pipeline
  67734. * @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)
  67735. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67736. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67737. */
  67738. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67739. private _buildPipeline;
  67740. private _createDownSampleX4PostProcess;
  67741. private _createBrightPassPostProcess;
  67742. private _createBlurPostProcesses;
  67743. private _createTextureAdderPostProcess;
  67744. private _createVolumetricLightPostProcess;
  67745. private _createLuminancePostProcesses;
  67746. private _createHdrPostProcess;
  67747. private _createLensFlarePostProcess;
  67748. private _createDepthOfFieldPostProcess;
  67749. private _createMotionBlurPostProcess;
  67750. private _getDepthTexture;
  67751. private _disposePostProcesses;
  67752. /**
  67753. * Dispose of the pipeline and stop all post processes
  67754. */
  67755. dispose(): void;
  67756. /**
  67757. * Serialize the rendering pipeline (Used when exporting)
  67758. * @returns the serialized object
  67759. */
  67760. serialize(): any;
  67761. /**
  67762. * Parse the serialized pipeline
  67763. * @param source Source pipeline.
  67764. * @param scene The scene to load the pipeline to.
  67765. * @param rootUrl The URL of the serialized pipeline.
  67766. * @returns An instantiated pipeline from the serialized object.
  67767. */
  67768. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67769. /**
  67770. * Luminance steps
  67771. */
  67772. static LuminanceSteps: number;
  67773. }
  67774. }
  67775. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  67776. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  67777. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  67778. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  67779. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  67780. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  67781. }
  67782. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  67783. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  67784. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67785. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67786. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67787. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67788. }
  67789. declare module "babylonjs/Shaders/tonemap.fragment" {
  67790. /** @hidden */
  67791. export var tonemapPixelShader: {
  67792. name: string;
  67793. shader: string;
  67794. };
  67795. }
  67796. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  67797. import { Camera } from "babylonjs/Cameras/camera";
  67798. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67799. import "babylonjs/Shaders/tonemap.fragment";
  67800. import { Engine } from "babylonjs/Engines/engine";
  67801. /** Defines operator used for tonemapping */
  67802. export enum TonemappingOperator {
  67803. /** Hable */
  67804. Hable = 0,
  67805. /** Reinhard */
  67806. Reinhard = 1,
  67807. /** HejiDawson */
  67808. HejiDawson = 2,
  67809. /** Photographic */
  67810. Photographic = 3
  67811. }
  67812. /**
  67813. * Defines a post process to apply tone mapping
  67814. */
  67815. export class TonemapPostProcess extends PostProcess {
  67816. private _operator;
  67817. /** Defines the required exposure adjustement */
  67818. exposureAdjustment: number;
  67819. /**
  67820. * Creates a new TonemapPostProcess
  67821. * @param name defines the name of the postprocess
  67822. * @param _operator defines the operator to use
  67823. * @param exposureAdjustment defines the required exposure adjustement
  67824. * @param camera defines the camera to use (can be null)
  67825. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67826. * @param engine defines the hosting engine (can be ignore if camera is set)
  67827. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67828. */
  67829. constructor(name: string, _operator: TonemappingOperator,
  67830. /** Defines the required exposure adjustement */
  67831. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67832. }
  67833. }
  67834. declare module "babylonjs/Shaders/depth.vertex" {
  67835. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67837. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67838. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67839. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67840. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67841. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67842. /** @hidden */
  67843. export var depthVertexShader: {
  67844. name: string;
  67845. shader: string;
  67846. };
  67847. }
  67848. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  67849. /** @hidden */
  67850. export var volumetricLightScatteringPixelShader: {
  67851. name: string;
  67852. shader: string;
  67853. };
  67854. }
  67855. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  67856. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67858. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67859. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67860. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67861. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67862. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67863. /** @hidden */
  67864. export var volumetricLightScatteringPassVertexShader: {
  67865. name: string;
  67866. shader: string;
  67867. };
  67868. }
  67869. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  67870. /** @hidden */
  67871. export var volumetricLightScatteringPassPixelShader: {
  67872. name: string;
  67873. shader: string;
  67874. };
  67875. }
  67876. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  67877. import { Vector3 } from "babylonjs/Maths/math.vector";
  67878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67879. import { Mesh } from "babylonjs/Meshes/mesh";
  67880. import { Camera } from "babylonjs/Cameras/camera";
  67881. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67882. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67883. import { Scene } from "babylonjs/scene";
  67884. import "babylonjs/Meshes/Builders/planeBuilder";
  67885. import "babylonjs/Shaders/depth.vertex";
  67886. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  67887. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  67888. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  67889. import { Engine } from "babylonjs/Engines/engine";
  67890. /**
  67891. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67892. */
  67893. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67894. private _volumetricLightScatteringPass;
  67895. private _volumetricLightScatteringRTT;
  67896. private _viewPort;
  67897. private _screenCoordinates;
  67898. private _cachedDefines;
  67899. /**
  67900. * If not undefined, the mesh position is computed from the attached node position
  67901. */
  67902. attachedNode: {
  67903. position: Vector3;
  67904. };
  67905. /**
  67906. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67907. */
  67908. customMeshPosition: Vector3;
  67909. /**
  67910. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67911. */
  67912. useCustomMeshPosition: boolean;
  67913. /**
  67914. * If the post-process should inverse the light scattering direction
  67915. */
  67916. invert: boolean;
  67917. /**
  67918. * The internal mesh used by the post-process
  67919. */
  67920. mesh: Mesh;
  67921. /**
  67922. * @hidden
  67923. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67924. */
  67925. get useDiffuseColor(): boolean;
  67926. set useDiffuseColor(useDiffuseColor: boolean);
  67927. /**
  67928. * Array containing the excluded meshes not rendered in the internal pass
  67929. */
  67930. excludedMeshes: AbstractMesh[];
  67931. /**
  67932. * Controls the overall intensity of the post-process
  67933. */
  67934. exposure: number;
  67935. /**
  67936. * Dissipates each sample's contribution in range [0, 1]
  67937. */
  67938. decay: number;
  67939. /**
  67940. * Controls the overall intensity of each sample
  67941. */
  67942. weight: number;
  67943. /**
  67944. * Controls the density of each sample
  67945. */
  67946. density: number;
  67947. /**
  67948. * @constructor
  67949. * @param name The post-process name
  67950. * @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)
  67951. * @param camera The camera that the post-process will be attached to
  67952. * @param mesh The mesh used to create the light scattering
  67953. * @param samples The post-process quality, default 100
  67954. * @param samplingModeThe post-process filtering mode
  67955. * @param engine The babylon engine
  67956. * @param reusable If the post-process is reusable
  67957. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67958. */
  67959. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67960. /**
  67961. * Returns the string "VolumetricLightScatteringPostProcess"
  67962. * @returns "VolumetricLightScatteringPostProcess"
  67963. */
  67964. getClassName(): string;
  67965. private _isReady;
  67966. /**
  67967. * Sets the new light position for light scattering effect
  67968. * @param position The new custom light position
  67969. */
  67970. setCustomMeshPosition(position: Vector3): void;
  67971. /**
  67972. * Returns the light position for light scattering effect
  67973. * @return Vector3 The custom light position
  67974. */
  67975. getCustomMeshPosition(): Vector3;
  67976. /**
  67977. * Disposes the internal assets and detaches the post-process from the camera
  67978. */
  67979. dispose(camera: Camera): void;
  67980. /**
  67981. * Returns the render target texture used by the post-process
  67982. * @return the render target texture used by the post-process
  67983. */
  67984. getPass(): RenderTargetTexture;
  67985. private _meshExcluded;
  67986. private _createPass;
  67987. private _updateMeshScreenCoordinates;
  67988. /**
  67989. * Creates a default mesh for the Volumeric Light Scattering post-process
  67990. * @param name The mesh name
  67991. * @param scene The scene where to create the mesh
  67992. * @return the default mesh
  67993. */
  67994. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67995. }
  67996. }
  67997. declare module "babylonjs/PostProcesses/index" {
  67998. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  67999. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  68000. export * from "babylonjs/PostProcesses/bloomEffect";
  68001. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  68002. export * from "babylonjs/PostProcesses/blurPostProcess";
  68003. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68004. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  68005. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  68006. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  68007. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68008. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  68009. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  68010. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  68011. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68012. export * from "babylonjs/PostProcesses/filterPostProcess";
  68013. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  68014. export * from "babylonjs/PostProcesses/grainPostProcess";
  68015. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  68016. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68017. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  68018. export * from "babylonjs/PostProcesses/passPostProcess";
  68019. export * from "babylonjs/PostProcesses/postProcess";
  68020. export * from "babylonjs/PostProcesses/postProcessManager";
  68021. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68022. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68023. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68024. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68025. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68026. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68027. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68028. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68029. }
  68030. declare module "babylonjs/Probes/index" {
  68031. export * from "babylonjs/Probes/reflectionProbe";
  68032. }
  68033. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68034. import { Scene } from "babylonjs/scene";
  68035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68036. import { SmartArray } from "babylonjs/Misc/smartArray";
  68037. import { ISceneComponent } from "babylonjs/sceneComponent";
  68038. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68039. import "babylonjs/Meshes/Builders/boxBuilder";
  68040. import "babylonjs/Shaders/color.fragment";
  68041. import "babylonjs/Shaders/color.vertex";
  68042. import { Color3 } from "babylonjs/Maths/math.color";
  68043. module "babylonjs/scene" {
  68044. interface Scene {
  68045. /** @hidden (Backing field) */
  68046. _boundingBoxRenderer: BoundingBoxRenderer;
  68047. /** @hidden (Backing field) */
  68048. _forceShowBoundingBoxes: boolean;
  68049. /**
  68050. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68051. */
  68052. forceShowBoundingBoxes: boolean;
  68053. /**
  68054. * Gets the bounding box renderer associated with the scene
  68055. * @returns a BoundingBoxRenderer
  68056. */
  68057. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68058. }
  68059. }
  68060. module "babylonjs/Meshes/abstractMesh" {
  68061. interface AbstractMesh {
  68062. /** @hidden (Backing field) */
  68063. _showBoundingBox: boolean;
  68064. /**
  68065. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68066. */
  68067. showBoundingBox: boolean;
  68068. }
  68069. }
  68070. /**
  68071. * Component responsible of rendering the bounding box of the meshes in a scene.
  68072. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68073. */
  68074. export class BoundingBoxRenderer implements ISceneComponent {
  68075. /**
  68076. * The component name helpfull to identify the component in the list of scene components.
  68077. */
  68078. readonly name: string;
  68079. /**
  68080. * The scene the component belongs to.
  68081. */
  68082. scene: Scene;
  68083. /**
  68084. * Color of the bounding box lines placed in front of an object
  68085. */
  68086. frontColor: Color3;
  68087. /**
  68088. * Color of the bounding box lines placed behind an object
  68089. */
  68090. backColor: Color3;
  68091. /**
  68092. * Defines if the renderer should show the back lines or not
  68093. */
  68094. showBackLines: boolean;
  68095. /**
  68096. * @hidden
  68097. */
  68098. renderList: SmartArray<BoundingBox>;
  68099. private _colorShader;
  68100. private _vertexBuffers;
  68101. private _indexBuffer;
  68102. private _fillIndexBuffer;
  68103. private _fillIndexData;
  68104. /**
  68105. * Instantiates a new bounding box renderer in a scene.
  68106. * @param scene the scene the renderer renders in
  68107. */
  68108. constructor(scene: Scene);
  68109. /**
  68110. * Registers the component in a given scene
  68111. */
  68112. register(): void;
  68113. private _evaluateSubMesh;
  68114. private _activeMesh;
  68115. private _prepareRessources;
  68116. private _createIndexBuffer;
  68117. /**
  68118. * Rebuilds the elements related to this component in case of
  68119. * context lost for instance.
  68120. */
  68121. rebuild(): void;
  68122. /**
  68123. * @hidden
  68124. */
  68125. reset(): void;
  68126. /**
  68127. * Render the bounding boxes of a specific rendering group
  68128. * @param renderingGroupId defines the rendering group to render
  68129. */
  68130. render(renderingGroupId: number): void;
  68131. /**
  68132. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68133. * @param mesh Define the mesh to render the occlusion bounding box for
  68134. */
  68135. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68136. /**
  68137. * Dispose and release the resources attached to this renderer.
  68138. */
  68139. dispose(): void;
  68140. }
  68141. }
  68142. declare module "babylonjs/Shaders/depth.fragment" {
  68143. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68144. /** @hidden */
  68145. export var depthPixelShader: {
  68146. name: string;
  68147. shader: string;
  68148. };
  68149. }
  68150. declare module "babylonjs/Rendering/depthRenderer" {
  68151. import { Nullable } from "babylonjs/types";
  68152. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68153. import { Scene } from "babylonjs/scene";
  68154. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68155. import { Camera } from "babylonjs/Cameras/camera";
  68156. import "babylonjs/Shaders/depth.fragment";
  68157. import "babylonjs/Shaders/depth.vertex";
  68158. /**
  68159. * This represents a depth renderer in Babylon.
  68160. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68161. */
  68162. export class DepthRenderer {
  68163. private _scene;
  68164. private _depthMap;
  68165. private _effect;
  68166. private readonly _storeNonLinearDepth;
  68167. private readonly _clearColor;
  68168. /** Get if the depth renderer is using packed depth or not */
  68169. readonly isPacked: boolean;
  68170. private _cachedDefines;
  68171. private _camera;
  68172. /**
  68173. * Specifiess that the depth renderer will only be used within
  68174. * the camera it is created for.
  68175. * This can help forcing its rendering during the camera processing.
  68176. */
  68177. useOnlyInActiveCamera: boolean;
  68178. /** @hidden */
  68179. static _SceneComponentInitialization: (scene: Scene) => void;
  68180. /**
  68181. * Instantiates a depth renderer
  68182. * @param scene The scene the renderer belongs to
  68183. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68184. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68185. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68186. */
  68187. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68188. /**
  68189. * Creates the depth rendering effect and checks if the effect is ready.
  68190. * @param subMesh The submesh to be used to render the depth map of
  68191. * @param useInstances If multiple world instances should be used
  68192. * @returns if the depth renderer is ready to render the depth map
  68193. */
  68194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68195. /**
  68196. * Gets the texture which the depth map will be written to.
  68197. * @returns The depth map texture
  68198. */
  68199. getDepthMap(): RenderTargetTexture;
  68200. /**
  68201. * Disposes of the depth renderer.
  68202. */
  68203. dispose(): void;
  68204. }
  68205. }
  68206. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  68207. import { Nullable } from "babylonjs/types";
  68208. import { Scene } from "babylonjs/scene";
  68209. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  68210. import { Camera } from "babylonjs/Cameras/camera";
  68211. import { ISceneComponent } from "babylonjs/sceneComponent";
  68212. module "babylonjs/scene" {
  68213. interface Scene {
  68214. /** @hidden (Backing field) */
  68215. _depthRenderer: {
  68216. [id: string]: DepthRenderer;
  68217. };
  68218. /**
  68219. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68220. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68221. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68222. * @returns the created depth renderer
  68223. */
  68224. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68225. /**
  68226. * Disables a depth renderer for a given camera
  68227. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68228. */
  68229. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68230. }
  68231. }
  68232. /**
  68233. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68234. * in several rendering techniques.
  68235. */
  68236. export class DepthRendererSceneComponent implements ISceneComponent {
  68237. /**
  68238. * The component name helpfull to identify the component in the list of scene components.
  68239. */
  68240. readonly name: string;
  68241. /**
  68242. * The scene the component belongs to.
  68243. */
  68244. scene: Scene;
  68245. /**
  68246. * Creates a new instance of the component for the given scene
  68247. * @param scene Defines the scene to register the component in
  68248. */
  68249. constructor(scene: Scene);
  68250. /**
  68251. * Registers the component in a given scene
  68252. */
  68253. register(): void;
  68254. /**
  68255. * Rebuilds the elements related to this component in case of
  68256. * context lost for instance.
  68257. */
  68258. rebuild(): void;
  68259. /**
  68260. * Disposes the component and the associated ressources
  68261. */
  68262. dispose(): void;
  68263. private _gatherRenderTargets;
  68264. private _gatherActiveCameraRenderTargets;
  68265. }
  68266. }
  68267. declare module "babylonjs/Shaders/outline.fragment" {
  68268. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68269. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  68270. /** @hidden */
  68271. export var outlinePixelShader: {
  68272. name: string;
  68273. shader: string;
  68274. };
  68275. }
  68276. declare module "babylonjs/Shaders/outline.vertex" {
  68277. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68278. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68279. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68280. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68281. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68282. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68283. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68284. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68285. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  68286. /** @hidden */
  68287. export var outlineVertexShader: {
  68288. name: string;
  68289. shader: string;
  68290. };
  68291. }
  68292. declare module "babylonjs/Rendering/outlineRenderer" {
  68293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68294. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  68295. import { Scene } from "babylonjs/scene";
  68296. import { ISceneComponent } from "babylonjs/sceneComponent";
  68297. import "babylonjs/Shaders/outline.fragment";
  68298. import "babylonjs/Shaders/outline.vertex";
  68299. module "babylonjs/scene" {
  68300. interface Scene {
  68301. /** @hidden */
  68302. _outlineRenderer: OutlineRenderer;
  68303. /**
  68304. * Gets the outline renderer associated with the scene
  68305. * @returns a OutlineRenderer
  68306. */
  68307. getOutlineRenderer(): OutlineRenderer;
  68308. }
  68309. }
  68310. module "babylonjs/Meshes/abstractMesh" {
  68311. interface AbstractMesh {
  68312. /** @hidden (Backing field) */
  68313. _renderOutline: boolean;
  68314. /**
  68315. * Gets or sets a boolean indicating if the outline must be rendered as well
  68316. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68317. */
  68318. renderOutline: boolean;
  68319. /** @hidden (Backing field) */
  68320. _renderOverlay: boolean;
  68321. /**
  68322. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68323. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68324. */
  68325. renderOverlay: boolean;
  68326. }
  68327. }
  68328. /**
  68329. * This class is responsible to draw bothe outline/overlay of meshes.
  68330. * It should not be used directly but through the available method on mesh.
  68331. */
  68332. export class OutlineRenderer implements ISceneComponent {
  68333. /**
  68334. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68335. */
  68336. private static _StencilReference;
  68337. /**
  68338. * The name of the component. Each component must have a unique name.
  68339. */
  68340. name: string;
  68341. /**
  68342. * The scene the component belongs to.
  68343. */
  68344. scene: Scene;
  68345. /**
  68346. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68347. */
  68348. zOffset: number;
  68349. private _engine;
  68350. private _effect;
  68351. private _cachedDefines;
  68352. private _savedDepthWrite;
  68353. /**
  68354. * Instantiates a new outline renderer. (There could be only one per scene).
  68355. * @param scene Defines the scene it belongs to
  68356. */
  68357. constructor(scene: Scene);
  68358. /**
  68359. * Register the component to one instance of a scene.
  68360. */
  68361. register(): void;
  68362. /**
  68363. * Rebuilds the elements related to this component in case of
  68364. * context lost for instance.
  68365. */
  68366. rebuild(): void;
  68367. /**
  68368. * Disposes the component and the associated ressources.
  68369. */
  68370. dispose(): void;
  68371. /**
  68372. * Renders the outline in the canvas.
  68373. * @param subMesh Defines the sumesh to render
  68374. * @param batch Defines the batch of meshes in case of instances
  68375. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68376. */
  68377. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68378. /**
  68379. * Returns whether or not the outline renderer is ready for a given submesh.
  68380. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68381. * @param subMesh Defines the submesh to check readyness for
  68382. * @param useInstances Defines wheter wee are trying to render instances or not
  68383. * @returns true if ready otherwise false
  68384. */
  68385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68386. private _beforeRenderingMesh;
  68387. private _afterRenderingMesh;
  68388. }
  68389. }
  68390. declare module "babylonjs/Rendering/index" {
  68391. export * from "babylonjs/Rendering/boundingBoxRenderer";
  68392. export * from "babylonjs/Rendering/depthRenderer";
  68393. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  68394. export * from "babylonjs/Rendering/edgesRenderer";
  68395. export * from "babylonjs/Rendering/geometryBufferRenderer";
  68396. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68397. export * from "babylonjs/Rendering/outlineRenderer";
  68398. export * from "babylonjs/Rendering/renderingGroup";
  68399. export * from "babylonjs/Rendering/renderingManager";
  68400. export * from "babylonjs/Rendering/utilityLayerRenderer";
  68401. }
  68402. declare module "babylonjs/Sprites/ISprites" {
  68403. /**
  68404. * Defines the basic options interface of a Sprite Frame Source Size.
  68405. */
  68406. export interface ISpriteJSONSpriteSourceSize {
  68407. /**
  68408. * number of the original width of the Frame
  68409. */
  68410. w: number;
  68411. /**
  68412. * number of the original height of the Frame
  68413. */
  68414. h: number;
  68415. }
  68416. /**
  68417. * Defines the basic options interface of a Sprite Frame Data.
  68418. */
  68419. export interface ISpriteJSONSpriteFrameData {
  68420. /**
  68421. * number of the x offset of the Frame
  68422. */
  68423. x: number;
  68424. /**
  68425. * number of the y offset of the Frame
  68426. */
  68427. y: number;
  68428. /**
  68429. * number of the width of the Frame
  68430. */
  68431. w: number;
  68432. /**
  68433. * number of the height of the Frame
  68434. */
  68435. h: number;
  68436. }
  68437. /**
  68438. * Defines the basic options interface of a JSON Sprite.
  68439. */
  68440. export interface ISpriteJSONSprite {
  68441. /**
  68442. * string name of the Frame
  68443. */
  68444. filename: string;
  68445. /**
  68446. * ISpriteJSONSpriteFrame basic object of the frame data
  68447. */
  68448. frame: ISpriteJSONSpriteFrameData;
  68449. /**
  68450. * boolean to flag is the frame was rotated.
  68451. */
  68452. rotated: boolean;
  68453. /**
  68454. * boolean to flag is the frame was trimmed.
  68455. */
  68456. trimmed: boolean;
  68457. /**
  68458. * ISpriteJSONSpriteFrame basic object of the source data
  68459. */
  68460. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68461. /**
  68462. * ISpriteJSONSpriteFrame basic object of the source data
  68463. */
  68464. sourceSize: ISpriteJSONSpriteSourceSize;
  68465. }
  68466. /**
  68467. * Defines the basic options interface of a JSON atlas.
  68468. */
  68469. export interface ISpriteJSONAtlas {
  68470. /**
  68471. * Array of objects that contain the frame data.
  68472. */
  68473. frames: Array<ISpriteJSONSprite>;
  68474. /**
  68475. * object basic object containing the sprite meta data.
  68476. */
  68477. meta?: object;
  68478. }
  68479. }
  68480. declare module "babylonjs/Shaders/spriteMap.fragment" {
  68481. /** @hidden */
  68482. export var spriteMapPixelShader: {
  68483. name: string;
  68484. shader: string;
  68485. };
  68486. }
  68487. declare module "babylonjs/Shaders/spriteMap.vertex" {
  68488. /** @hidden */
  68489. export var spriteMapVertexShader: {
  68490. name: string;
  68491. shader: string;
  68492. };
  68493. }
  68494. declare module "babylonjs/Sprites/spriteMap" {
  68495. import { IDisposable, Scene } from "babylonjs/scene";
  68496. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  68497. import { Texture } from "babylonjs/Materials/Textures/texture";
  68498. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68499. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  68500. import "babylonjs/Meshes/Builders/planeBuilder";
  68501. import "babylonjs/Shaders/spriteMap.fragment";
  68502. import "babylonjs/Shaders/spriteMap.vertex";
  68503. /**
  68504. * Defines the basic options interface of a SpriteMap
  68505. */
  68506. export interface ISpriteMapOptions {
  68507. /**
  68508. * Vector2 of the number of cells in the grid.
  68509. */
  68510. stageSize?: Vector2;
  68511. /**
  68512. * Vector2 of the size of the output plane in World Units.
  68513. */
  68514. outputSize?: Vector2;
  68515. /**
  68516. * Vector3 of the position of the output plane in World Units.
  68517. */
  68518. outputPosition?: Vector3;
  68519. /**
  68520. * Vector3 of the rotation of the output plane.
  68521. */
  68522. outputRotation?: Vector3;
  68523. /**
  68524. * number of layers that the system will reserve in resources.
  68525. */
  68526. layerCount?: number;
  68527. /**
  68528. * number of max animation frames a single cell will reserve in resources.
  68529. */
  68530. maxAnimationFrames?: number;
  68531. /**
  68532. * number cell index of the base tile when the system compiles.
  68533. */
  68534. baseTile?: number;
  68535. /**
  68536. * boolean flip the sprite after its been repositioned by the framing data.
  68537. */
  68538. flipU?: boolean;
  68539. /**
  68540. * Vector3 scalar of the global RGB values of the SpriteMap.
  68541. */
  68542. colorMultiply?: Vector3;
  68543. }
  68544. /**
  68545. * Defines the IDisposable interface in order to be cleanable from resources.
  68546. */
  68547. export interface ISpriteMap extends IDisposable {
  68548. /**
  68549. * String name of the SpriteMap.
  68550. */
  68551. name: string;
  68552. /**
  68553. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  68554. */
  68555. atlasJSON: ISpriteJSONAtlas;
  68556. /**
  68557. * Texture of the SpriteMap.
  68558. */
  68559. spriteSheet: Texture;
  68560. /**
  68561. * The parameters to initialize the SpriteMap with.
  68562. */
  68563. options: ISpriteMapOptions;
  68564. }
  68565. /**
  68566. * Class used to manage a grid restricted sprite deployment on an Output plane.
  68567. */
  68568. export class SpriteMap implements ISpriteMap {
  68569. /** The Name of the spriteMap */
  68570. name: string;
  68571. /** The JSON file with the frame and meta data */
  68572. atlasJSON: ISpriteJSONAtlas;
  68573. /** The systems Sprite Sheet Texture */
  68574. spriteSheet: Texture;
  68575. /** Arguments passed with the Constructor */
  68576. options: ISpriteMapOptions;
  68577. /** Public Sprite Storage array, parsed from atlasJSON */
  68578. sprites: Array<ISpriteJSONSprite>;
  68579. /** Returns the Number of Sprites in the System */
  68580. get spriteCount(): number;
  68581. /** Returns the Position of Output Plane*/
  68582. get position(): Vector3;
  68583. /** Returns the Position of Output Plane*/
  68584. set position(v: Vector3);
  68585. /** Returns the Rotation of Output Plane*/
  68586. get rotation(): Vector3;
  68587. /** Returns the Rotation of Output Plane*/
  68588. set rotation(v: Vector3);
  68589. /** Sets the AnimationMap*/
  68590. get animationMap(): RawTexture;
  68591. /** Sets the AnimationMap*/
  68592. set animationMap(v: RawTexture);
  68593. /** Scene that the SpriteMap was created in */
  68594. private _scene;
  68595. /** Texture Buffer of Float32 that holds tile frame data*/
  68596. private _frameMap;
  68597. /** Texture Buffers of Float32 that holds tileMap data*/
  68598. private _tileMaps;
  68599. /** Texture Buffer of Float32 that holds Animation Data*/
  68600. private _animationMap;
  68601. /** Custom ShaderMaterial Central to the System*/
  68602. private _material;
  68603. /** Custom ShaderMaterial Central to the System*/
  68604. private _output;
  68605. /** Systems Time Ticker*/
  68606. private _time;
  68607. /**
  68608. * Creates a new SpriteMap
  68609. * @param name defines the SpriteMaps Name
  68610. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  68611. * @param spriteSheet is the Texture that the Sprites are on.
  68612. * @param options a basic deployment configuration
  68613. * @param scene The Scene that the map is deployed on
  68614. */
  68615. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  68616. /**
  68617. * Returns tileID location
  68618. * @returns Vector2 the cell position ID
  68619. */
  68620. getTileID(): Vector2;
  68621. /**
  68622. * Gets the UV location of the mouse over the SpriteMap.
  68623. * @returns Vector2 the UV position of the mouse interaction
  68624. */
  68625. getMousePosition(): Vector2;
  68626. /**
  68627. * Creates the "frame" texture Buffer
  68628. * -------------------------------------
  68629. * Structure of frames
  68630. * "filename": "Falling-Water-2.png",
  68631. * "frame": {"x":69,"y":103,"w":24,"h":32},
  68632. * "rotated": true,
  68633. * "trimmed": true,
  68634. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  68635. * "sourceSize": {"w":32,"h":32}
  68636. * @returns RawTexture of the frameMap
  68637. */
  68638. private _createFrameBuffer;
  68639. /**
  68640. * Creates the tileMap texture Buffer
  68641. * @param buffer normally and array of numbers, or a false to generate from scratch
  68642. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  68643. * @returns RawTexture of the tileMap
  68644. */
  68645. private _createTileBuffer;
  68646. /**
  68647. * Modifies the data of the tileMaps
  68648. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  68649. * @param pos is the iVector2 Coordinates of the Tile
  68650. * @param tile The SpriteIndex of the new Tile
  68651. */
  68652. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  68653. /**
  68654. * Creates the animationMap texture Buffer
  68655. * @param buffer normally and array of numbers, or a false to generate from scratch
  68656. * @returns RawTexture of the animationMap
  68657. */
  68658. private _createTileAnimationBuffer;
  68659. /**
  68660. * Modifies the data of the animationMap
  68661. * @param cellID is the Index of the Sprite
  68662. * @param _frame is the target Animation frame
  68663. * @param toCell is the Target Index of the next frame of the animation
  68664. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  68665. * @param speed is a global scalar of the time variable on the map.
  68666. */
  68667. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  68668. /**
  68669. * Exports the .tilemaps file
  68670. */
  68671. saveTileMaps(): void;
  68672. /**
  68673. * Imports the .tilemaps file
  68674. * @param url of the .tilemaps file
  68675. */
  68676. loadTileMaps(url: string): void;
  68677. /**
  68678. * Release associated resources
  68679. */
  68680. dispose(): void;
  68681. }
  68682. }
  68683. declare module "babylonjs/Sprites/spritePackedManager" {
  68684. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  68685. import { Scene } from "babylonjs/scene";
  68686. /**
  68687. * Class used to manage multiple sprites of different sizes on the same spritesheet
  68688. * @see http://doc.babylonjs.com/babylon101/sprites
  68689. */
  68690. export class SpritePackedManager extends SpriteManager {
  68691. /** defines the packed manager's name */
  68692. name: string;
  68693. /**
  68694. * Creates a new sprite manager from a packed sprite sheet
  68695. * @param name defines the manager's name
  68696. * @param imgUrl defines the sprite sheet url
  68697. * @param capacity defines the maximum allowed number of sprites
  68698. * @param scene defines the hosting scene
  68699. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68700. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68701. * @param samplingMode defines the smapling mode to use with spritesheet
  68702. * @param fromPacked set to true; do not alter
  68703. */
  68704. constructor(
  68705. /** defines the packed manager's name */
  68706. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68707. }
  68708. }
  68709. declare module "babylonjs/Sprites/index" {
  68710. export * from "babylonjs/Sprites/sprite";
  68711. export * from "babylonjs/Sprites/ISprites";
  68712. export * from "babylonjs/Sprites/spriteManager";
  68713. export * from "babylonjs/Sprites/spriteMap";
  68714. export * from "babylonjs/Sprites/spritePackedManager";
  68715. export * from "babylonjs/Sprites/spriteSceneComponent";
  68716. }
  68717. declare module "babylonjs/States/index" {
  68718. export * from "babylonjs/States/alphaCullingState";
  68719. export * from "babylonjs/States/depthCullingState";
  68720. export * from "babylonjs/States/stencilState";
  68721. }
  68722. declare module "babylonjs/Misc/assetsManager" {
  68723. import { Scene } from "babylonjs/scene";
  68724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68725. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68726. import { Skeleton } from "babylonjs/Bones/skeleton";
  68727. import { Observable } from "babylonjs/Misc/observable";
  68728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68729. import { Texture } from "babylonjs/Materials/Textures/texture";
  68730. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  68731. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  68732. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  68733. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  68734. /**
  68735. * Defines the list of states available for a task inside a AssetsManager
  68736. */
  68737. export enum AssetTaskState {
  68738. /**
  68739. * Initialization
  68740. */
  68741. INIT = 0,
  68742. /**
  68743. * Running
  68744. */
  68745. RUNNING = 1,
  68746. /**
  68747. * Done
  68748. */
  68749. DONE = 2,
  68750. /**
  68751. * Error
  68752. */
  68753. ERROR = 3
  68754. }
  68755. /**
  68756. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68757. */
  68758. export abstract class AbstractAssetTask {
  68759. /**
  68760. * Task name
  68761. */ name: string;
  68762. /**
  68763. * Callback called when the task is successful
  68764. */
  68765. onSuccess: (task: any) => void;
  68766. /**
  68767. * Callback called when the task is not successful
  68768. */
  68769. onError: (task: any, message?: string, exception?: any) => void;
  68770. /**
  68771. * Creates a new AssetsManager
  68772. * @param name defines the name of the task
  68773. */
  68774. constructor(
  68775. /**
  68776. * Task name
  68777. */ name: string);
  68778. private _isCompleted;
  68779. private _taskState;
  68780. private _errorObject;
  68781. /**
  68782. * Get if the task is completed
  68783. */
  68784. get isCompleted(): boolean;
  68785. /**
  68786. * Gets the current state of the task
  68787. */
  68788. get taskState(): AssetTaskState;
  68789. /**
  68790. * Gets the current error object (if task is in error)
  68791. */
  68792. get errorObject(): {
  68793. message?: string;
  68794. exception?: any;
  68795. };
  68796. /**
  68797. * Internal only
  68798. * @hidden
  68799. */
  68800. _setErrorObject(message?: string, exception?: any): void;
  68801. /**
  68802. * Execute the current task
  68803. * @param scene defines the scene where you want your assets to be loaded
  68804. * @param onSuccess is a callback called when the task is successfully executed
  68805. * @param onError is a callback called if an error occurs
  68806. */
  68807. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68808. /**
  68809. * Execute the current task
  68810. * @param scene defines the scene where you want your assets to be loaded
  68811. * @param onSuccess is a callback called when the task is successfully executed
  68812. * @param onError is a callback called if an error occurs
  68813. */
  68814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68815. /**
  68816. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68817. * This can be used with failed tasks that have the reason for failure fixed.
  68818. */
  68819. reset(): void;
  68820. private onErrorCallback;
  68821. private onDoneCallback;
  68822. }
  68823. /**
  68824. * Define the interface used by progress events raised during assets loading
  68825. */
  68826. export interface IAssetsProgressEvent {
  68827. /**
  68828. * Defines the number of remaining tasks to process
  68829. */
  68830. remainingCount: number;
  68831. /**
  68832. * Defines the total number of tasks
  68833. */
  68834. totalCount: number;
  68835. /**
  68836. * Defines the task that was just processed
  68837. */
  68838. task: AbstractAssetTask;
  68839. }
  68840. /**
  68841. * Class used to share progress information about assets loading
  68842. */
  68843. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68844. /**
  68845. * Defines the number of remaining tasks to process
  68846. */
  68847. remainingCount: number;
  68848. /**
  68849. * Defines the total number of tasks
  68850. */
  68851. totalCount: number;
  68852. /**
  68853. * Defines the task that was just processed
  68854. */
  68855. task: AbstractAssetTask;
  68856. /**
  68857. * Creates a AssetsProgressEvent
  68858. * @param remainingCount defines the number of remaining tasks to process
  68859. * @param totalCount defines the total number of tasks
  68860. * @param task defines the task that was just processed
  68861. */
  68862. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68863. }
  68864. /**
  68865. * Define a task used by AssetsManager to load meshes
  68866. */
  68867. export class MeshAssetTask extends AbstractAssetTask {
  68868. /**
  68869. * Defines the name of the task
  68870. */
  68871. name: string;
  68872. /**
  68873. * Defines the list of mesh's names you want to load
  68874. */
  68875. meshesNames: any;
  68876. /**
  68877. * Defines the root url to use as a base to load your meshes and associated resources
  68878. */
  68879. rootUrl: string;
  68880. /**
  68881. * Defines the filename of the scene to load from
  68882. */
  68883. sceneFilename: string;
  68884. /**
  68885. * Gets the list of loaded meshes
  68886. */
  68887. loadedMeshes: Array<AbstractMesh>;
  68888. /**
  68889. * Gets the list of loaded particle systems
  68890. */
  68891. loadedParticleSystems: Array<IParticleSystem>;
  68892. /**
  68893. * Gets the list of loaded skeletons
  68894. */
  68895. loadedSkeletons: Array<Skeleton>;
  68896. /**
  68897. * Gets the list of loaded animation groups
  68898. */
  68899. loadedAnimationGroups: Array<AnimationGroup>;
  68900. /**
  68901. * Callback called when the task is successful
  68902. */
  68903. onSuccess: (task: MeshAssetTask) => void;
  68904. /**
  68905. * Callback called when the task is successful
  68906. */
  68907. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68908. /**
  68909. * Creates a new MeshAssetTask
  68910. * @param name defines the name of the task
  68911. * @param meshesNames defines the list of mesh's names you want to load
  68912. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68913. * @param sceneFilename defines the filename of the scene to load from
  68914. */
  68915. constructor(
  68916. /**
  68917. * Defines the name of the task
  68918. */
  68919. name: string,
  68920. /**
  68921. * Defines the list of mesh's names you want to load
  68922. */
  68923. meshesNames: any,
  68924. /**
  68925. * Defines the root url to use as a base to load your meshes and associated resources
  68926. */
  68927. rootUrl: string,
  68928. /**
  68929. * Defines the filename of the scene to load from
  68930. */
  68931. sceneFilename: string);
  68932. /**
  68933. * Execute the current task
  68934. * @param scene defines the scene where you want your assets to be loaded
  68935. * @param onSuccess is a callback called when the task is successfully executed
  68936. * @param onError is a callback called if an error occurs
  68937. */
  68938. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68939. }
  68940. /**
  68941. * Define a task used by AssetsManager to load text content
  68942. */
  68943. export class TextFileAssetTask extends AbstractAssetTask {
  68944. /**
  68945. * Defines the name of the task
  68946. */
  68947. name: string;
  68948. /**
  68949. * Defines the location of the file to load
  68950. */
  68951. url: string;
  68952. /**
  68953. * Gets the loaded text string
  68954. */
  68955. text: string;
  68956. /**
  68957. * Callback called when the task is successful
  68958. */
  68959. onSuccess: (task: TextFileAssetTask) => void;
  68960. /**
  68961. * Callback called when the task is successful
  68962. */
  68963. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68964. /**
  68965. * Creates a new TextFileAssetTask object
  68966. * @param name defines the name of the task
  68967. * @param url defines the location of the file to load
  68968. */
  68969. constructor(
  68970. /**
  68971. * Defines the name of the task
  68972. */
  68973. name: string,
  68974. /**
  68975. * Defines the location of the file to load
  68976. */
  68977. url: string);
  68978. /**
  68979. * Execute the current task
  68980. * @param scene defines the scene where you want your assets to be loaded
  68981. * @param onSuccess is a callback called when the task is successfully executed
  68982. * @param onError is a callback called if an error occurs
  68983. */
  68984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68985. }
  68986. /**
  68987. * Define a task used by AssetsManager to load binary data
  68988. */
  68989. export class BinaryFileAssetTask extends AbstractAssetTask {
  68990. /**
  68991. * Defines the name of the task
  68992. */
  68993. name: string;
  68994. /**
  68995. * Defines the location of the file to load
  68996. */
  68997. url: string;
  68998. /**
  68999. * Gets the lodaded data (as an array buffer)
  69000. */
  69001. data: ArrayBuffer;
  69002. /**
  69003. * Callback called when the task is successful
  69004. */
  69005. onSuccess: (task: BinaryFileAssetTask) => void;
  69006. /**
  69007. * Callback called when the task is successful
  69008. */
  69009. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69010. /**
  69011. * Creates a new BinaryFileAssetTask object
  69012. * @param name defines the name of the new task
  69013. * @param url defines the location of the file to load
  69014. */
  69015. constructor(
  69016. /**
  69017. * Defines the name of the task
  69018. */
  69019. name: string,
  69020. /**
  69021. * Defines the location of the file to load
  69022. */
  69023. url: string);
  69024. /**
  69025. * Execute the current task
  69026. * @param scene defines the scene where you want your assets to be loaded
  69027. * @param onSuccess is a callback called when the task is successfully executed
  69028. * @param onError is a callback called if an error occurs
  69029. */
  69030. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69031. }
  69032. /**
  69033. * Define a task used by AssetsManager to load images
  69034. */
  69035. export class ImageAssetTask extends AbstractAssetTask {
  69036. /**
  69037. * Defines the name of the task
  69038. */
  69039. name: string;
  69040. /**
  69041. * Defines the location of the image to load
  69042. */
  69043. url: string;
  69044. /**
  69045. * Gets the loaded images
  69046. */
  69047. image: HTMLImageElement;
  69048. /**
  69049. * Callback called when the task is successful
  69050. */
  69051. onSuccess: (task: ImageAssetTask) => void;
  69052. /**
  69053. * Callback called when the task is successful
  69054. */
  69055. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69056. /**
  69057. * Creates a new ImageAssetTask
  69058. * @param name defines the name of the task
  69059. * @param url defines the location of the image to load
  69060. */
  69061. constructor(
  69062. /**
  69063. * Defines the name of the task
  69064. */
  69065. name: string,
  69066. /**
  69067. * Defines the location of the image to load
  69068. */
  69069. url: string);
  69070. /**
  69071. * Execute the current task
  69072. * @param scene defines the scene where you want your assets to be loaded
  69073. * @param onSuccess is a callback called when the task is successfully executed
  69074. * @param onError is a callback called if an error occurs
  69075. */
  69076. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69077. }
  69078. /**
  69079. * Defines the interface used by texture loading tasks
  69080. */
  69081. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69082. /**
  69083. * Gets the loaded texture
  69084. */
  69085. texture: TEX;
  69086. }
  69087. /**
  69088. * Define a task used by AssetsManager to load 2D textures
  69089. */
  69090. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69091. /**
  69092. * Defines the name of the task
  69093. */
  69094. name: string;
  69095. /**
  69096. * Defines the location of the file to load
  69097. */
  69098. url: string;
  69099. /**
  69100. * Defines if mipmap should not be generated (default is false)
  69101. */
  69102. noMipmap?: boolean | undefined;
  69103. /**
  69104. * Defines if texture must be inverted on Y axis (default is false)
  69105. */
  69106. invertY?: boolean | undefined;
  69107. /**
  69108. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69109. */
  69110. samplingMode: number;
  69111. /**
  69112. * Gets the loaded texture
  69113. */
  69114. texture: Texture;
  69115. /**
  69116. * Callback called when the task is successful
  69117. */
  69118. onSuccess: (task: TextureAssetTask) => void;
  69119. /**
  69120. * Callback called when the task is successful
  69121. */
  69122. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69123. /**
  69124. * Creates a new TextureAssetTask object
  69125. * @param name defines the name of the task
  69126. * @param url defines the location of the file to load
  69127. * @param noMipmap defines if mipmap should not be generated (default is false)
  69128. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69129. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69130. */
  69131. constructor(
  69132. /**
  69133. * Defines the name of the task
  69134. */
  69135. name: string,
  69136. /**
  69137. * Defines the location of the file to load
  69138. */
  69139. url: string,
  69140. /**
  69141. * Defines if mipmap should not be generated (default is false)
  69142. */
  69143. noMipmap?: boolean | undefined,
  69144. /**
  69145. * Defines if texture must be inverted on Y axis (default is false)
  69146. */
  69147. invertY?: boolean | undefined,
  69148. /**
  69149. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69150. */
  69151. samplingMode?: number);
  69152. /**
  69153. * Execute the current task
  69154. * @param scene defines the scene where you want your assets to be loaded
  69155. * @param onSuccess is a callback called when the task is successfully executed
  69156. * @param onError is a callback called if an error occurs
  69157. */
  69158. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69159. }
  69160. /**
  69161. * Define a task used by AssetsManager to load cube textures
  69162. */
  69163. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69164. /**
  69165. * Defines the name of the task
  69166. */
  69167. name: string;
  69168. /**
  69169. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69170. */
  69171. url: string;
  69172. /**
  69173. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69174. */
  69175. extensions?: string[] | undefined;
  69176. /**
  69177. * Defines if mipmaps should not be generated (default is false)
  69178. */
  69179. noMipmap?: boolean | undefined;
  69180. /**
  69181. * Defines the explicit list of files (undefined by default)
  69182. */
  69183. files?: string[] | undefined;
  69184. /**
  69185. * Gets the loaded texture
  69186. */
  69187. texture: CubeTexture;
  69188. /**
  69189. * Callback called when the task is successful
  69190. */
  69191. onSuccess: (task: CubeTextureAssetTask) => void;
  69192. /**
  69193. * Callback called when the task is successful
  69194. */
  69195. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69196. /**
  69197. * Creates a new CubeTextureAssetTask
  69198. * @param name defines the name of the task
  69199. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69200. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69201. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69202. * @param files defines the explicit list of files (undefined by default)
  69203. */
  69204. constructor(
  69205. /**
  69206. * Defines the name of the task
  69207. */
  69208. name: string,
  69209. /**
  69210. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69211. */
  69212. url: string,
  69213. /**
  69214. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69215. */
  69216. extensions?: string[] | undefined,
  69217. /**
  69218. * Defines if mipmaps should not be generated (default is false)
  69219. */
  69220. noMipmap?: boolean | undefined,
  69221. /**
  69222. * Defines the explicit list of files (undefined by default)
  69223. */
  69224. files?: string[] | undefined);
  69225. /**
  69226. * Execute the current task
  69227. * @param scene defines the scene where you want your assets to be loaded
  69228. * @param onSuccess is a callback called when the task is successfully executed
  69229. * @param onError is a callback called if an error occurs
  69230. */
  69231. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69232. }
  69233. /**
  69234. * Define a task used by AssetsManager to load HDR cube textures
  69235. */
  69236. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69237. /**
  69238. * Defines the name of the task
  69239. */
  69240. name: string;
  69241. /**
  69242. * Defines the location of the file to load
  69243. */
  69244. url: string;
  69245. /**
  69246. * Defines the desired size (the more it increases the longer the generation will be)
  69247. */
  69248. size: number;
  69249. /**
  69250. * Defines if mipmaps should not be generated (default is false)
  69251. */
  69252. noMipmap: boolean;
  69253. /**
  69254. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69255. */
  69256. generateHarmonics: boolean;
  69257. /**
  69258. * 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)
  69259. */
  69260. gammaSpace: boolean;
  69261. /**
  69262. * Internal Use Only
  69263. */
  69264. reserved: boolean;
  69265. /**
  69266. * Gets the loaded texture
  69267. */
  69268. texture: HDRCubeTexture;
  69269. /**
  69270. * Callback called when the task is successful
  69271. */
  69272. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69273. /**
  69274. * Callback called when the task is successful
  69275. */
  69276. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69277. /**
  69278. * Creates a new HDRCubeTextureAssetTask object
  69279. * @param name defines the name of the task
  69280. * @param url defines the location of the file to load
  69281. * @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.
  69282. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69283. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69284. * @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)
  69285. * @param reserved Internal use only
  69286. */
  69287. constructor(
  69288. /**
  69289. * Defines the name of the task
  69290. */
  69291. name: string,
  69292. /**
  69293. * Defines the location of the file to load
  69294. */
  69295. url: string,
  69296. /**
  69297. * Defines the desired size (the more it increases the longer the generation will be)
  69298. */
  69299. size: number,
  69300. /**
  69301. * Defines if mipmaps should not be generated (default is false)
  69302. */
  69303. noMipmap?: boolean,
  69304. /**
  69305. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69306. */
  69307. generateHarmonics?: boolean,
  69308. /**
  69309. * 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)
  69310. */
  69311. gammaSpace?: boolean,
  69312. /**
  69313. * Internal Use Only
  69314. */
  69315. reserved?: boolean);
  69316. /**
  69317. * Execute the current task
  69318. * @param scene defines the scene where you want your assets to be loaded
  69319. * @param onSuccess is a callback called when the task is successfully executed
  69320. * @param onError is a callback called if an error occurs
  69321. */
  69322. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69323. }
  69324. /**
  69325. * Define a task used by AssetsManager to load Equirectangular cube textures
  69326. */
  69327. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69328. /**
  69329. * Defines the name of the task
  69330. */
  69331. name: string;
  69332. /**
  69333. * Defines the location of the file to load
  69334. */
  69335. url: string;
  69336. /**
  69337. * Defines the desired size (the more it increases the longer the generation will be)
  69338. */
  69339. size: number;
  69340. /**
  69341. * Defines if mipmaps should not be generated (default is false)
  69342. */
  69343. noMipmap: boolean;
  69344. /**
  69345. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69346. * but the standard material would require them in Gamma space) (default is true)
  69347. */
  69348. gammaSpace: boolean;
  69349. /**
  69350. * Gets the loaded texture
  69351. */
  69352. texture: EquiRectangularCubeTexture;
  69353. /**
  69354. * Callback called when the task is successful
  69355. */
  69356. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69357. /**
  69358. * Callback called when the task is successful
  69359. */
  69360. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69361. /**
  69362. * Creates a new EquiRectangularCubeTextureAssetTask object
  69363. * @param name defines the name of the task
  69364. * @param url defines the location of the file to load
  69365. * @param size defines the desired size (the more it increases the longer the generation will be)
  69366. * If the size is omitted this implies you are using a preprocessed cubemap.
  69367. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69368. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69369. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69370. * (default is true)
  69371. */
  69372. constructor(
  69373. /**
  69374. * Defines the name of the task
  69375. */
  69376. name: string,
  69377. /**
  69378. * Defines the location of the file to load
  69379. */
  69380. url: string,
  69381. /**
  69382. * Defines the desired size (the more it increases the longer the generation will be)
  69383. */
  69384. size: number,
  69385. /**
  69386. * Defines if mipmaps should not be generated (default is false)
  69387. */
  69388. noMipmap?: boolean,
  69389. /**
  69390. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69391. * but the standard material would require them in Gamma space) (default is true)
  69392. */
  69393. gammaSpace?: boolean);
  69394. /**
  69395. * Execute the current task
  69396. * @param scene defines the scene where you want your assets to be loaded
  69397. * @param onSuccess is a callback called when the task is successfully executed
  69398. * @param onError is a callback called if an error occurs
  69399. */
  69400. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69401. }
  69402. /**
  69403. * This class can be used to easily import assets into a scene
  69404. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69405. */
  69406. export class AssetsManager {
  69407. private _scene;
  69408. private _isLoading;
  69409. protected _tasks: AbstractAssetTask[];
  69410. protected _waitingTasksCount: number;
  69411. protected _totalTasksCount: number;
  69412. /**
  69413. * Callback called when all tasks are processed
  69414. */
  69415. onFinish: (tasks: AbstractAssetTask[]) => void;
  69416. /**
  69417. * Callback called when a task is successful
  69418. */
  69419. onTaskSuccess: (task: AbstractAssetTask) => void;
  69420. /**
  69421. * Callback called when a task had an error
  69422. */
  69423. onTaskError: (task: AbstractAssetTask) => void;
  69424. /**
  69425. * Callback called when a task is done (whatever the result is)
  69426. */
  69427. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69428. /**
  69429. * Observable called when all tasks are processed
  69430. */
  69431. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69432. /**
  69433. * Observable called when a task had an error
  69434. */
  69435. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69436. /**
  69437. * Observable called when all tasks were executed
  69438. */
  69439. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69440. /**
  69441. * Observable called when a task is done (whatever the result is)
  69442. */
  69443. onProgressObservable: Observable<IAssetsProgressEvent>;
  69444. /**
  69445. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69446. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69447. */
  69448. useDefaultLoadingScreen: boolean;
  69449. /**
  69450. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69451. * when all assets have been downloaded.
  69452. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69453. */
  69454. autoHideLoadingUI: boolean;
  69455. /**
  69456. * Creates a new AssetsManager
  69457. * @param scene defines the scene to work on
  69458. */
  69459. constructor(scene: Scene);
  69460. /**
  69461. * Add a MeshAssetTask to the list of active tasks
  69462. * @param taskName defines the name of the new task
  69463. * @param meshesNames defines the name of meshes to load
  69464. * @param rootUrl defines the root url to use to locate files
  69465. * @param sceneFilename defines the filename of the scene file
  69466. * @returns a new MeshAssetTask object
  69467. */
  69468. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69469. /**
  69470. * Add a TextFileAssetTask to the list of active tasks
  69471. * @param taskName defines the name of the new task
  69472. * @param url defines the url of the file to load
  69473. * @returns a new TextFileAssetTask object
  69474. */
  69475. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69476. /**
  69477. * Add a BinaryFileAssetTask to the list of active tasks
  69478. * @param taskName defines the name of the new task
  69479. * @param url defines the url of the file to load
  69480. * @returns a new BinaryFileAssetTask object
  69481. */
  69482. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69483. /**
  69484. * Add a ImageAssetTask to the list of active tasks
  69485. * @param taskName defines the name of the new task
  69486. * @param url defines the url of the file to load
  69487. * @returns a new ImageAssetTask object
  69488. */
  69489. addImageTask(taskName: string, url: string): ImageAssetTask;
  69490. /**
  69491. * Add a TextureAssetTask 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 noMipmap defines if the texture must not receive mipmaps (false by default)
  69495. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69496. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69497. * @returns a new TextureAssetTask object
  69498. */
  69499. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69500. /**
  69501. * Add a CubeTextureAssetTask to the list of active tasks
  69502. * @param taskName defines the name of the new task
  69503. * @param url defines the url of the file to load
  69504. * @param extensions defines the extension to use to load the cube map (can be null)
  69505. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69506. * @param files defines the list of files to load (can be null)
  69507. * @returns a new CubeTextureAssetTask object
  69508. */
  69509. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69510. /**
  69511. *
  69512. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69513. * @param taskName defines the name of the new task
  69514. * @param url defines the url of the file to load
  69515. * @param size defines the size you want for the cubemap (can be null)
  69516. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69517. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69518. * @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)
  69519. * @param reserved Internal use only
  69520. * @returns a new HDRCubeTextureAssetTask object
  69521. */
  69522. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69523. /**
  69524. *
  69525. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69526. * @param taskName defines the name of the new task
  69527. * @param url defines the url of the file to load
  69528. * @param size defines the size you want for the cubemap (can be null)
  69529. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69530. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69531. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69532. * @returns a new EquiRectangularCubeTextureAssetTask object
  69533. */
  69534. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69535. /**
  69536. * Remove a task from the assets manager.
  69537. * @param task the task to remove
  69538. */
  69539. removeTask(task: AbstractAssetTask): void;
  69540. private _decreaseWaitingTasksCount;
  69541. private _runTask;
  69542. /**
  69543. * Reset the AssetsManager and remove all tasks
  69544. * @return the current instance of the AssetsManager
  69545. */
  69546. reset(): AssetsManager;
  69547. /**
  69548. * Start the loading process
  69549. * @return the current instance of the AssetsManager
  69550. */
  69551. load(): AssetsManager;
  69552. /**
  69553. * Start the loading process as an async operation
  69554. * @return a promise returning the list of failed tasks
  69555. */
  69556. loadAsync(): Promise<void>;
  69557. }
  69558. }
  69559. declare module "babylonjs/Misc/deferred" {
  69560. /**
  69561. * Wrapper class for promise with external resolve and reject.
  69562. */
  69563. export class Deferred<T> {
  69564. /**
  69565. * The promise associated with this deferred object.
  69566. */
  69567. readonly promise: Promise<T>;
  69568. private _resolve;
  69569. private _reject;
  69570. /**
  69571. * The resolve method of the promise associated with this deferred object.
  69572. */
  69573. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  69574. /**
  69575. * The reject method of the promise associated with this deferred object.
  69576. */
  69577. get reject(): (reason?: any) => void;
  69578. /**
  69579. * Constructor for this deferred object.
  69580. */
  69581. constructor();
  69582. }
  69583. }
  69584. declare module "babylonjs/Misc/meshExploder" {
  69585. import { Mesh } from "babylonjs/Meshes/mesh";
  69586. /**
  69587. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  69588. */
  69589. export class MeshExploder {
  69590. private _centerMesh;
  69591. private _meshes;
  69592. private _meshesOrigins;
  69593. private _toCenterVectors;
  69594. private _scaledDirection;
  69595. private _newPosition;
  69596. private _centerPosition;
  69597. /**
  69598. * Explodes meshes from a center mesh.
  69599. * @param meshes The meshes to explode.
  69600. * @param centerMesh The mesh to be center of explosion.
  69601. */
  69602. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  69603. private _setCenterMesh;
  69604. /**
  69605. * Get class name
  69606. * @returns "MeshExploder"
  69607. */
  69608. getClassName(): string;
  69609. /**
  69610. * "Exploded meshes"
  69611. * @returns Array of meshes with the centerMesh at index 0.
  69612. */
  69613. getMeshes(): Array<Mesh>;
  69614. /**
  69615. * Explodes meshes giving a specific direction
  69616. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  69617. */
  69618. explode(direction?: number): void;
  69619. }
  69620. }
  69621. declare module "babylonjs/Misc/filesInput" {
  69622. import { Engine } from "babylonjs/Engines/engine";
  69623. import { Scene } from "babylonjs/scene";
  69624. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  69625. /**
  69626. * Class used to help managing file picking and drag'n'drop
  69627. */
  69628. export class FilesInput {
  69629. /**
  69630. * List of files ready to be loaded
  69631. */
  69632. static get FilesToLoad(): {
  69633. [key: string]: File;
  69634. };
  69635. /**
  69636. * Callback called when a file is processed
  69637. */
  69638. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  69639. private _engine;
  69640. private _currentScene;
  69641. private _sceneLoadedCallback;
  69642. private _progressCallback;
  69643. private _additionalRenderLoopLogicCallback;
  69644. private _textureLoadingCallback;
  69645. private _startingProcessingFilesCallback;
  69646. private _onReloadCallback;
  69647. private _errorCallback;
  69648. private _elementToMonitor;
  69649. private _sceneFileToLoad;
  69650. private _filesToLoad;
  69651. /**
  69652. * Creates a new FilesInput
  69653. * @param engine defines the rendering engine
  69654. * @param scene defines the hosting scene
  69655. * @param sceneLoadedCallback callback called when scene is loaded
  69656. * @param progressCallback callback called to track progress
  69657. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  69658. * @param textureLoadingCallback callback called when a texture is loading
  69659. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  69660. * @param onReloadCallback callback called when a reload is requested
  69661. * @param errorCallback callback call if an error occurs
  69662. */
  69663. 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);
  69664. private _dragEnterHandler;
  69665. private _dragOverHandler;
  69666. private _dropHandler;
  69667. /**
  69668. * Calls this function to listen to drag'n'drop events on a specific DOM element
  69669. * @param elementToMonitor defines the DOM element to track
  69670. */
  69671. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  69672. /**
  69673. * Release all associated resources
  69674. */
  69675. dispose(): void;
  69676. private renderFunction;
  69677. private drag;
  69678. private drop;
  69679. private _traverseFolder;
  69680. private _processFiles;
  69681. /**
  69682. * Load files from a drop event
  69683. * @param event defines the drop event to use as source
  69684. */
  69685. loadFiles(event: any): void;
  69686. private _processReload;
  69687. /**
  69688. * Reload the current scene from the loaded files
  69689. */
  69690. reload(): void;
  69691. }
  69692. }
  69693. declare module "babylonjs/Misc/HighDynamicRange/index" {
  69694. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  69695. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  69696. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  69697. }
  69698. declare module "babylonjs/Misc/sceneOptimizer" {
  69699. import { Scene, IDisposable } from "babylonjs/scene";
  69700. import { Observable } from "babylonjs/Misc/observable";
  69701. /**
  69702. * Defines the root class used to create scene optimization to use with SceneOptimizer
  69703. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69704. */
  69705. export class SceneOptimization {
  69706. /**
  69707. * Defines the priority of this optimization (0 by default which means first in the list)
  69708. */
  69709. priority: number;
  69710. /**
  69711. * Gets a string describing the action executed by the current optimization
  69712. * @returns description string
  69713. */
  69714. getDescription(): string;
  69715. /**
  69716. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69717. * @param scene defines the current scene where to apply this optimization
  69718. * @param optimizer defines the current optimizer
  69719. * @returns true if everything that can be done was applied
  69720. */
  69721. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69722. /**
  69723. * Creates the SceneOptimization object
  69724. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69725. * @param desc defines the description associated with the optimization
  69726. */
  69727. constructor(
  69728. /**
  69729. * Defines the priority of this optimization (0 by default which means first in the list)
  69730. */
  69731. priority?: number);
  69732. }
  69733. /**
  69734. * Defines an optimization used to reduce the size of render target textures
  69735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69736. */
  69737. export class TextureOptimization extends SceneOptimization {
  69738. /**
  69739. * Defines the priority of this optimization (0 by default which means first in the list)
  69740. */
  69741. priority: number;
  69742. /**
  69743. * 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
  69744. */
  69745. maximumSize: number;
  69746. /**
  69747. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69748. */
  69749. step: number;
  69750. /**
  69751. * Gets a string describing the action executed by the current optimization
  69752. * @returns description string
  69753. */
  69754. getDescription(): string;
  69755. /**
  69756. * Creates the TextureOptimization object
  69757. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69758. * @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
  69759. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69760. */
  69761. constructor(
  69762. /**
  69763. * Defines the priority of this optimization (0 by default which means first in the list)
  69764. */
  69765. priority?: number,
  69766. /**
  69767. * 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
  69768. */
  69769. maximumSize?: number,
  69770. /**
  69771. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69772. */
  69773. step?: number);
  69774. /**
  69775. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69776. * @param scene defines the current scene where to apply this optimization
  69777. * @param optimizer defines the current optimizer
  69778. * @returns true if everything that can be done was applied
  69779. */
  69780. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69781. }
  69782. /**
  69783. * Defines an optimization used to increase or decrease the rendering resolution
  69784. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69785. */
  69786. export class HardwareScalingOptimization extends SceneOptimization {
  69787. /**
  69788. * Defines the priority of this optimization (0 by default which means first in the list)
  69789. */
  69790. priority: number;
  69791. /**
  69792. * Defines the maximum scale to use (2 by default)
  69793. */
  69794. maximumScale: number;
  69795. /**
  69796. * Defines the step to use between two passes (0.5 by default)
  69797. */
  69798. step: number;
  69799. private _currentScale;
  69800. private _directionOffset;
  69801. /**
  69802. * Gets a string describing the action executed by the current optimization
  69803. * @return description string
  69804. */
  69805. getDescription(): string;
  69806. /**
  69807. * Creates the HardwareScalingOptimization object
  69808. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69809. * @param maximumScale defines the maximum scale to use (2 by default)
  69810. * @param step defines the step to use between two passes (0.5 by default)
  69811. */
  69812. constructor(
  69813. /**
  69814. * Defines the priority of this optimization (0 by default which means first in the list)
  69815. */
  69816. priority?: number,
  69817. /**
  69818. * Defines the maximum scale to use (2 by default)
  69819. */
  69820. maximumScale?: number,
  69821. /**
  69822. * Defines the step to use between two passes (0.5 by default)
  69823. */
  69824. step?: number);
  69825. /**
  69826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69827. * @param scene defines the current scene where to apply this optimization
  69828. * @param optimizer defines the current optimizer
  69829. * @returns true if everything that can be done was applied
  69830. */
  69831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69832. }
  69833. /**
  69834. * Defines an optimization used to remove shadows
  69835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69836. */
  69837. export class ShadowsOptimization extends SceneOptimization {
  69838. /**
  69839. * Gets a string describing the action executed by the current optimization
  69840. * @return description string
  69841. */
  69842. getDescription(): string;
  69843. /**
  69844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69845. * @param scene defines the current scene where to apply this optimization
  69846. * @param optimizer defines the current optimizer
  69847. * @returns true if everything that can be done was applied
  69848. */
  69849. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69850. }
  69851. /**
  69852. * Defines an optimization used to turn post-processes off
  69853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69854. */
  69855. export class PostProcessesOptimization extends SceneOptimization {
  69856. /**
  69857. * Gets a string describing the action executed by the current optimization
  69858. * @return description string
  69859. */
  69860. getDescription(): string;
  69861. /**
  69862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69863. * @param scene defines the current scene where to apply this optimization
  69864. * @param optimizer defines the current optimizer
  69865. * @returns true if everything that can be done was applied
  69866. */
  69867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69868. }
  69869. /**
  69870. * Defines an optimization used to turn lens flares off
  69871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69872. */
  69873. export class LensFlaresOptimization extends SceneOptimization {
  69874. /**
  69875. * Gets a string describing the action executed by the current optimization
  69876. * @return description string
  69877. */
  69878. getDescription(): string;
  69879. /**
  69880. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69881. * @param scene defines the current scene where to apply this optimization
  69882. * @param optimizer defines the current optimizer
  69883. * @returns true if everything that can be done was applied
  69884. */
  69885. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69886. }
  69887. /**
  69888. * Defines an optimization based on user defined callback.
  69889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69890. */
  69891. export class CustomOptimization extends SceneOptimization {
  69892. /**
  69893. * Callback called to apply the custom optimization.
  69894. */
  69895. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69896. /**
  69897. * Callback called to get custom description
  69898. */
  69899. onGetDescription: () => string;
  69900. /**
  69901. * Gets a string describing the action executed by the current optimization
  69902. * @returns description string
  69903. */
  69904. getDescription(): string;
  69905. /**
  69906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69907. * @param scene defines the current scene where to apply this optimization
  69908. * @param optimizer defines the current optimizer
  69909. * @returns true if everything that can be done was applied
  69910. */
  69911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69912. }
  69913. /**
  69914. * Defines an optimization used to turn particles off
  69915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69916. */
  69917. export class ParticlesOptimization extends SceneOptimization {
  69918. /**
  69919. * Gets a string describing the action executed by the current optimization
  69920. * @return description string
  69921. */
  69922. getDescription(): string;
  69923. /**
  69924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69925. * @param scene defines the current scene where to apply this optimization
  69926. * @param optimizer defines the current optimizer
  69927. * @returns true if everything that can be done was applied
  69928. */
  69929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69930. }
  69931. /**
  69932. * Defines an optimization used to turn render targets off
  69933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69934. */
  69935. export class RenderTargetsOptimization extends SceneOptimization {
  69936. /**
  69937. * Gets a string describing the action executed by the current optimization
  69938. * @return description string
  69939. */
  69940. getDescription(): string;
  69941. /**
  69942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69943. * @param scene defines the current scene where to apply this optimization
  69944. * @param optimizer defines the current optimizer
  69945. * @returns true if everything that can be done was applied
  69946. */
  69947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69948. }
  69949. /**
  69950. * Defines an optimization used to merge meshes with compatible materials
  69951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69952. */
  69953. export class MergeMeshesOptimization extends SceneOptimization {
  69954. private static _UpdateSelectionTree;
  69955. /**
  69956. * Gets or sets a boolean which defines if optimization octree has to be updated
  69957. */
  69958. static get UpdateSelectionTree(): boolean;
  69959. /**
  69960. * Gets or sets a boolean which defines if optimization octree has to be updated
  69961. */
  69962. static set UpdateSelectionTree(value: boolean);
  69963. /**
  69964. * Gets a string describing the action executed by the current optimization
  69965. * @return description string
  69966. */
  69967. getDescription(): string;
  69968. private _canBeMerged;
  69969. /**
  69970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69971. * @param scene defines the current scene where to apply this optimization
  69972. * @param optimizer defines the current optimizer
  69973. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69974. * @returns true if everything that can be done was applied
  69975. */
  69976. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69977. }
  69978. /**
  69979. * Defines a list of options used by SceneOptimizer
  69980. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69981. */
  69982. export class SceneOptimizerOptions {
  69983. /**
  69984. * Defines the target frame rate to reach (60 by default)
  69985. */
  69986. targetFrameRate: number;
  69987. /**
  69988. * Defines the interval between two checkes (2000ms by default)
  69989. */
  69990. trackerDuration: number;
  69991. /**
  69992. * Gets the list of optimizations to apply
  69993. */
  69994. optimizations: SceneOptimization[];
  69995. /**
  69996. * Creates a new list of options used by SceneOptimizer
  69997. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69998. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69999. */
  70000. constructor(
  70001. /**
  70002. * Defines the target frame rate to reach (60 by default)
  70003. */
  70004. targetFrameRate?: number,
  70005. /**
  70006. * Defines the interval between two checkes (2000ms by default)
  70007. */
  70008. trackerDuration?: number);
  70009. /**
  70010. * Add a new optimization
  70011. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70012. * @returns the current SceneOptimizerOptions
  70013. */
  70014. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70015. /**
  70016. * Add a new custom optimization
  70017. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70018. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70019. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70020. * @returns the current SceneOptimizerOptions
  70021. */
  70022. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70023. /**
  70024. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70025. * @param targetFrameRate defines the target frame rate (60 by default)
  70026. * @returns a SceneOptimizerOptions object
  70027. */
  70028. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70029. /**
  70030. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70031. * @param targetFrameRate defines the target frame rate (60 by default)
  70032. * @returns a SceneOptimizerOptions object
  70033. */
  70034. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70035. /**
  70036. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70037. * @param targetFrameRate defines the target frame rate (60 by default)
  70038. * @returns a SceneOptimizerOptions object
  70039. */
  70040. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70041. }
  70042. /**
  70043. * Class used to run optimizations in order to reach a target frame rate
  70044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70045. */
  70046. export class SceneOptimizer implements IDisposable {
  70047. private _isRunning;
  70048. private _options;
  70049. private _scene;
  70050. private _currentPriorityLevel;
  70051. private _targetFrameRate;
  70052. private _trackerDuration;
  70053. private _currentFrameRate;
  70054. private _sceneDisposeObserver;
  70055. private _improvementMode;
  70056. /**
  70057. * Defines an observable called when the optimizer reaches the target frame rate
  70058. */
  70059. onSuccessObservable: Observable<SceneOptimizer>;
  70060. /**
  70061. * Defines an observable called when the optimizer enables an optimization
  70062. */
  70063. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70064. /**
  70065. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70066. */
  70067. onFailureObservable: Observable<SceneOptimizer>;
  70068. /**
  70069. * Gets a boolean indicating if the optimizer is in improvement mode
  70070. */
  70071. get isInImprovementMode(): boolean;
  70072. /**
  70073. * Gets the current priority level (0 at start)
  70074. */
  70075. get currentPriorityLevel(): number;
  70076. /**
  70077. * Gets the current frame rate checked by the SceneOptimizer
  70078. */
  70079. get currentFrameRate(): number;
  70080. /**
  70081. * Gets or sets the current target frame rate (60 by default)
  70082. */
  70083. get targetFrameRate(): number;
  70084. /**
  70085. * Gets or sets the current target frame rate (60 by default)
  70086. */
  70087. set targetFrameRate(value: number);
  70088. /**
  70089. * Gets or sets the current interval between two checks (every 2000ms by default)
  70090. */
  70091. get trackerDuration(): number;
  70092. /**
  70093. * Gets or sets the current interval between two checks (every 2000ms by default)
  70094. */
  70095. set trackerDuration(value: number);
  70096. /**
  70097. * Gets the list of active optimizations
  70098. */
  70099. get optimizations(): SceneOptimization[];
  70100. /**
  70101. * Creates a new SceneOptimizer
  70102. * @param scene defines the scene to work on
  70103. * @param options defines the options to use with the SceneOptimizer
  70104. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70105. * @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)
  70106. */
  70107. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70108. /**
  70109. * Stops the current optimizer
  70110. */
  70111. stop(): void;
  70112. /**
  70113. * Reset the optimizer to initial step (current priority level = 0)
  70114. */
  70115. reset(): void;
  70116. /**
  70117. * Start the optimizer. By default it will try to reach a specific framerate
  70118. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70119. */
  70120. start(): void;
  70121. private _checkCurrentState;
  70122. /**
  70123. * Release all resources
  70124. */
  70125. dispose(): void;
  70126. /**
  70127. * Helper function to create a SceneOptimizer with one single line of code
  70128. * @param scene defines the scene to work on
  70129. * @param options defines the options to use with the SceneOptimizer
  70130. * @param onSuccess defines a callback to call on success
  70131. * @param onFailure defines a callback to call on failure
  70132. * @returns the new SceneOptimizer object
  70133. */
  70134. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70135. }
  70136. }
  70137. declare module "babylonjs/Misc/sceneSerializer" {
  70138. import { Scene } from "babylonjs/scene";
  70139. /**
  70140. * Class used to serialize a scene into a string
  70141. */
  70142. export class SceneSerializer {
  70143. /**
  70144. * Clear cache used by a previous serialization
  70145. */
  70146. static ClearCache(): void;
  70147. /**
  70148. * Serialize a scene into a JSON compatible object
  70149. * @param scene defines the scene to serialize
  70150. * @returns a JSON compatible object
  70151. */
  70152. static Serialize(scene: Scene): any;
  70153. /**
  70154. * Serialize a mesh into a JSON compatible object
  70155. * @param toSerialize defines the mesh to serialize
  70156. * @param withParents defines if parents must be serialized as well
  70157. * @param withChildren defines if children must be serialized as well
  70158. * @returns a JSON compatible object
  70159. */
  70160. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70161. }
  70162. }
  70163. declare module "babylonjs/Misc/textureTools" {
  70164. import { Texture } from "babylonjs/Materials/Textures/texture";
  70165. /**
  70166. * Class used to host texture specific utilities
  70167. */
  70168. export class TextureTools {
  70169. /**
  70170. * Uses the GPU to create a copy texture rescaled at a given size
  70171. * @param texture Texture to copy from
  70172. * @param width defines the desired width
  70173. * @param height defines the desired height
  70174. * @param useBilinearMode defines if bilinear mode has to be used
  70175. * @return the generated texture
  70176. */
  70177. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70178. }
  70179. }
  70180. declare module "babylonjs/Misc/videoRecorder" {
  70181. import { Nullable } from "babylonjs/types";
  70182. import { Engine } from "babylonjs/Engines/engine";
  70183. /**
  70184. * This represents the different options available for the video capture.
  70185. */
  70186. export interface VideoRecorderOptions {
  70187. /** Defines the mime type of the video. */
  70188. mimeType: string;
  70189. /** Defines the FPS the video should be recorded at. */
  70190. fps: number;
  70191. /** Defines the chunk size for the recording data. */
  70192. recordChunckSize: number;
  70193. /** The audio tracks to attach to the recording. */
  70194. audioTracks?: MediaStreamTrack[];
  70195. }
  70196. /**
  70197. * This can help with recording videos from BabylonJS.
  70198. * This is based on the available WebRTC functionalities of the browser.
  70199. *
  70200. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70201. */
  70202. export class VideoRecorder {
  70203. private static readonly _defaultOptions;
  70204. /**
  70205. * Returns whether or not the VideoRecorder is available in your browser.
  70206. * @param engine Defines the Babylon Engine.
  70207. * @returns true if supported otherwise false.
  70208. */
  70209. static IsSupported(engine: Engine): boolean;
  70210. private readonly _options;
  70211. private _canvas;
  70212. private _mediaRecorder;
  70213. private _recordedChunks;
  70214. private _fileName;
  70215. private _resolve;
  70216. private _reject;
  70217. /**
  70218. * True when a recording is already in progress.
  70219. */
  70220. get isRecording(): boolean;
  70221. /**
  70222. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70223. * @param engine Defines the BabylonJS Engine you wish to record.
  70224. * @param options Defines options that can be used to customize the capture.
  70225. */
  70226. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70227. /**
  70228. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70229. */
  70230. stopRecording(): void;
  70231. /**
  70232. * Starts recording the canvas for a max duration specified in parameters.
  70233. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70234. * If null no automatic download will start and you can rely on the promise to get the data back.
  70235. * @param maxDuration Defines the maximum recording time in seconds.
  70236. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70237. * @return A promise callback at the end of the recording with the video data in Blob.
  70238. */
  70239. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70240. /**
  70241. * Releases internal resources used during the recording.
  70242. */
  70243. dispose(): void;
  70244. private _handleDataAvailable;
  70245. private _handleError;
  70246. private _handleStop;
  70247. }
  70248. }
  70249. declare module "babylonjs/Misc/screenshotTools" {
  70250. import { Camera } from "babylonjs/Cameras/camera";
  70251. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  70252. import { Engine } from "babylonjs/Engines/engine";
  70253. /**
  70254. * Class containing a set of static utilities functions for screenshots
  70255. */
  70256. export class ScreenshotTools {
  70257. /**
  70258. * Captures a screenshot of the current rendering
  70259. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70260. * @param engine defines the rendering engine
  70261. * @param camera defines the source camera
  70262. * @param size This parameter can be set to a single number or to an object with the
  70263. * following (optional) properties: precision, width, height. If a single number is passed,
  70264. * it will be used for both width and height. If an object is passed, the screenshot size
  70265. * will be derived from the parameters. The precision property is a multiplier allowing
  70266. * rendering at a higher or lower resolution
  70267. * @param successCallback defines the callback receives a single parameter which contains the
  70268. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70269. * src parameter of an <img> to display it
  70270. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70271. * Check your browser for supported MIME types
  70272. */
  70273. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70274. /**
  70275. * Captures a screenshot of the current rendering
  70276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70277. * @param engine defines the rendering engine
  70278. * @param camera defines the source camera
  70279. * @param size This parameter can be set to a single number or to an object with the
  70280. * following (optional) properties: precision, width, height. If a single number is passed,
  70281. * it will be used for both width and height. If an object is passed, the screenshot size
  70282. * will be derived from the parameters. The precision property is a multiplier allowing
  70283. * rendering at a higher or lower resolution
  70284. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70285. * Check your browser for supported MIME types
  70286. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70287. * to the src parameter of an <img> to display it
  70288. */
  70289. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70290. /**
  70291. * Generates an image screenshot from the specified camera.
  70292. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70293. * @param engine The engine to use for rendering
  70294. * @param camera The camera to use for rendering
  70295. * @param size This parameter can be set to a single number or to an object with the
  70296. * following (optional) properties: precision, width, height. If a single number is passed,
  70297. * it will be used for both width and height. If an object is passed, the screenshot size
  70298. * will be derived from the parameters. The precision property is a multiplier allowing
  70299. * rendering at a higher or lower resolution
  70300. * @param successCallback The callback receives a single parameter which contains the
  70301. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70302. * src parameter of an <img> to display it
  70303. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70304. * Check your browser for supported MIME types
  70305. * @param samples Texture samples (default: 1)
  70306. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70307. * @param fileName A name for for the downloaded file.
  70308. */
  70309. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  70310. /**
  70311. * Generates an image screenshot from the specified camera.
  70312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70313. * @param engine The engine to use for rendering
  70314. * @param camera The camera to use for rendering
  70315. * @param size This parameter can be set to a single number or to an object with the
  70316. * following (optional) properties: precision, width, height. If a single number is passed,
  70317. * it will be used for both width and height. If an object is passed, the screenshot size
  70318. * will be derived from the parameters. The precision property is a multiplier allowing
  70319. * rendering at a higher or lower resolution
  70320. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70321. * Check your browser for supported MIME types
  70322. * @param samples Texture samples (default: 1)
  70323. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70324. * @param fileName A name for for the downloaded file.
  70325. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70326. * to the src parameter of an <img> to display it
  70327. */
  70328. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  70329. /**
  70330. * Gets height and width for screenshot size
  70331. * @private
  70332. */
  70333. private static _getScreenshotSize;
  70334. }
  70335. }
  70336. declare module "babylonjs/Misc/dataReader" {
  70337. /**
  70338. * Interface for a data buffer
  70339. */
  70340. export interface IDataBuffer {
  70341. /**
  70342. * Reads bytes from the data buffer.
  70343. * @param byteOffset The byte offset to read
  70344. * @param byteLength The byte length to read
  70345. * @returns A promise that resolves when the bytes are read
  70346. */
  70347. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70348. /**
  70349. * The byte length of the buffer.
  70350. */
  70351. readonly byteLength: number;
  70352. }
  70353. /**
  70354. * Utility class for reading from a data buffer
  70355. */
  70356. export class DataReader {
  70357. /**
  70358. * The data buffer associated with this data reader.
  70359. */
  70360. readonly buffer: IDataBuffer;
  70361. /**
  70362. * The current byte offset from the beginning of the data buffer.
  70363. */
  70364. byteOffset: number;
  70365. private _dataView;
  70366. private _dataByteOffset;
  70367. /**
  70368. * Constructor
  70369. * @param buffer The buffer to read
  70370. */
  70371. constructor(buffer: IDataBuffer);
  70372. /**
  70373. * Loads the given byte length.
  70374. * @param byteLength The byte length to load
  70375. * @returns A promise that resolves when the load is complete
  70376. */
  70377. loadAsync(byteLength: number): Promise<void>;
  70378. /**
  70379. * Read a unsigned 32-bit integer from the currently loaded data range.
  70380. * @returns The 32-bit integer read
  70381. */
  70382. readUint32(): number;
  70383. /**
  70384. * Read a byte array from the currently loaded data range.
  70385. * @param byteLength The byte length to read
  70386. * @returns The byte array read
  70387. */
  70388. readUint8Array(byteLength: number): Uint8Array;
  70389. /**
  70390. * Read a string from the currently loaded data range.
  70391. * @param byteLength The byte length to read
  70392. * @returns The string read
  70393. */
  70394. readString(byteLength: number): string;
  70395. /**
  70396. * Skips the given byte length the currently loaded data range.
  70397. * @param byteLength The byte length to skip
  70398. */
  70399. skipBytes(byteLength: number): void;
  70400. }
  70401. }
  70402. declare module "babylonjs/Misc/index" {
  70403. export * from "babylonjs/Misc/andOrNotEvaluator";
  70404. export * from "babylonjs/Misc/assetsManager";
  70405. export * from "babylonjs/Misc/basis";
  70406. export * from "babylonjs/Misc/dds";
  70407. export * from "babylonjs/Misc/decorators";
  70408. export * from "babylonjs/Misc/deferred";
  70409. export * from "babylonjs/Misc/environmentTextureTools";
  70410. export * from "babylonjs/Misc/meshExploder";
  70411. export * from "babylonjs/Misc/filesInput";
  70412. export * from "babylonjs/Misc/HighDynamicRange/index";
  70413. export * from "babylonjs/Misc/khronosTextureContainer";
  70414. export * from "babylonjs/Misc/observable";
  70415. export * from "babylonjs/Misc/performanceMonitor";
  70416. export * from "babylonjs/Misc/promise";
  70417. export * from "babylonjs/Misc/sceneOptimizer";
  70418. export * from "babylonjs/Misc/sceneSerializer";
  70419. export * from "babylonjs/Misc/smartArray";
  70420. export * from "babylonjs/Misc/stringDictionary";
  70421. export * from "babylonjs/Misc/tags";
  70422. export * from "babylonjs/Misc/textureTools";
  70423. export * from "babylonjs/Misc/tga";
  70424. export * from "babylonjs/Misc/tools";
  70425. export * from "babylonjs/Misc/videoRecorder";
  70426. export * from "babylonjs/Misc/virtualJoystick";
  70427. export * from "babylonjs/Misc/workerPool";
  70428. export * from "babylonjs/Misc/logger";
  70429. export * from "babylonjs/Misc/typeStore";
  70430. export * from "babylonjs/Misc/filesInputStore";
  70431. export * from "babylonjs/Misc/deepCopier";
  70432. export * from "babylonjs/Misc/pivotTools";
  70433. export * from "babylonjs/Misc/precisionDate";
  70434. export * from "babylonjs/Misc/screenshotTools";
  70435. export * from "babylonjs/Misc/typeStore";
  70436. export * from "babylonjs/Misc/webRequest";
  70437. export * from "babylonjs/Misc/iInspectable";
  70438. export * from "babylonjs/Misc/brdfTextureTools";
  70439. export * from "babylonjs/Misc/rgbdTextureTools";
  70440. export * from "babylonjs/Misc/gradients";
  70441. export * from "babylonjs/Misc/perfCounter";
  70442. export * from "babylonjs/Misc/fileRequest";
  70443. export * from "babylonjs/Misc/customAnimationFrameRequester";
  70444. export * from "babylonjs/Misc/retryStrategy";
  70445. export * from "babylonjs/Misc/interfaces/screenshotSize";
  70446. export * from "babylonjs/Misc/canvasGenerator";
  70447. export * from "babylonjs/Misc/fileTools";
  70448. export * from "babylonjs/Misc/stringTools";
  70449. export * from "babylonjs/Misc/dataReader";
  70450. }
  70451. declare module "babylonjs/index" {
  70452. export * from "babylonjs/abstractScene";
  70453. export * from "babylonjs/Actions/index";
  70454. export * from "babylonjs/Animations/index";
  70455. export * from "babylonjs/assetContainer";
  70456. export * from "babylonjs/Audio/index";
  70457. export * from "babylonjs/Behaviors/index";
  70458. export * from "babylonjs/Bones/index";
  70459. export * from "babylonjs/Cameras/index";
  70460. export * from "babylonjs/Collisions/index";
  70461. export * from "babylonjs/Culling/index";
  70462. export * from "babylonjs/Debug/index";
  70463. export * from "babylonjs/Engines/index";
  70464. export * from "babylonjs/Events/index";
  70465. export * from "babylonjs/Gamepads/index";
  70466. export * from "babylonjs/Gizmos/index";
  70467. export * from "babylonjs/Helpers/index";
  70468. export * from "babylonjs/Instrumentation/index";
  70469. export * from "babylonjs/Layers/index";
  70470. export * from "babylonjs/LensFlares/index";
  70471. export * from "babylonjs/Lights/index";
  70472. export * from "babylonjs/Loading/index";
  70473. export * from "babylonjs/Materials/index";
  70474. export * from "babylonjs/Maths/index";
  70475. export * from "babylonjs/Meshes/index";
  70476. export * from "babylonjs/Morph/index";
  70477. export * from "babylonjs/Navigation/index";
  70478. export * from "babylonjs/node";
  70479. export * from "babylonjs/Offline/index";
  70480. export * from "babylonjs/Particles/index";
  70481. export * from "babylonjs/Physics/index";
  70482. export * from "babylonjs/PostProcesses/index";
  70483. export * from "babylonjs/Probes/index";
  70484. export * from "babylonjs/Rendering/index";
  70485. export * from "babylonjs/scene";
  70486. export * from "babylonjs/sceneComponent";
  70487. export * from "babylonjs/Sprites/index";
  70488. export * from "babylonjs/States/index";
  70489. export * from "babylonjs/Misc/index";
  70490. export * from "babylonjs/types";
  70491. }
  70492. declare module "babylonjs/Animations/pathCursor" {
  70493. import { Vector3 } from "babylonjs/Maths/math.vector";
  70494. import { Path2 } from "babylonjs/Maths/math.path";
  70495. /**
  70496. * A cursor which tracks a point on a path
  70497. */
  70498. export class PathCursor {
  70499. private path;
  70500. /**
  70501. * Stores path cursor callbacks for when an onchange event is triggered
  70502. */
  70503. private _onchange;
  70504. /**
  70505. * The value of the path cursor
  70506. */
  70507. value: number;
  70508. /**
  70509. * The animation array of the path cursor
  70510. */
  70511. animations: Animation[];
  70512. /**
  70513. * Initializes the path cursor
  70514. * @param path The path to track
  70515. */
  70516. constructor(path: Path2);
  70517. /**
  70518. * Gets the cursor point on the path
  70519. * @returns A point on the path cursor at the cursor location
  70520. */
  70521. getPoint(): Vector3;
  70522. /**
  70523. * Moves the cursor ahead by the step amount
  70524. * @param step The amount to move the cursor forward
  70525. * @returns This path cursor
  70526. */
  70527. moveAhead(step?: number): PathCursor;
  70528. /**
  70529. * Moves the cursor behind by the step amount
  70530. * @param step The amount to move the cursor back
  70531. * @returns This path cursor
  70532. */
  70533. moveBack(step?: number): PathCursor;
  70534. /**
  70535. * Moves the cursor by the step amount
  70536. * If the step amount is greater than one, an exception is thrown
  70537. * @param step The amount to move the cursor
  70538. * @returns This path cursor
  70539. */
  70540. move(step: number): PathCursor;
  70541. /**
  70542. * Ensures that the value is limited between zero and one
  70543. * @returns This path cursor
  70544. */
  70545. private ensureLimits;
  70546. /**
  70547. * Runs onchange callbacks on change (used by the animation engine)
  70548. * @returns This path cursor
  70549. */
  70550. private raiseOnChange;
  70551. /**
  70552. * Executes a function on change
  70553. * @param f A path cursor onchange callback
  70554. * @returns This path cursor
  70555. */
  70556. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70557. }
  70558. }
  70559. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  70560. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  70561. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  70562. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  70563. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  70564. }
  70565. declare module "babylonjs/Engines/Processors/Expressions/index" {
  70566. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  70567. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  70568. }
  70569. declare module "babylonjs/Engines/Processors/index" {
  70570. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  70571. export * from "babylonjs/Engines/Processors/Expressions/index";
  70572. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  70573. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  70574. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  70575. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  70576. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  70577. export * from "babylonjs/Engines/Processors/shaderProcessor";
  70578. }
  70579. declare module "babylonjs/Legacy/legacy" {
  70580. import * as Babylon from "babylonjs/index";
  70581. export * from "babylonjs/index";
  70582. }
  70583. declare module "babylonjs/Shaders/blur.fragment" {
  70584. /** @hidden */
  70585. export var blurPixelShader: {
  70586. name: string;
  70587. shader: string;
  70588. };
  70589. }
  70590. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  70591. /** @hidden */
  70592. export var pointCloudVertexDeclaration: {
  70593. name: string;
  70594. shader: string;
  70595. };
  70596. }
  70597. declare module "babylonjs" {
  70598. export * from "babylonjs/Legacy/legacy";
  70599. }
  70600. declare module BABYLON {
  70601. /** Alias type for value that can be null */
  70602. export type Nullable<T> = T | null;
  70603. /**
  70604. * Alias type for number that are floats
  70605. * @ignorenaming
  70606. */
  70607. export type float = number;
  70608. /**
  70609. * Alias type for number that are doubles.
  70610. * @ignorenaming
  70611. */
  70612. export type double = number;
  70613. /**
  70614. * Alias type for number that are integer
  70615. * @ignorenaming
  70616. */
  70617. export type int = number;
  70618. /** Alias type for number array or Float32Array */
  70619. export type FloatArray = number[] | Float32Array;
  70620. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  70621. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  70622. /**
  70623. * Alias for types that can be used by a Buffer or VertexBuffer.
  70624. */
  70625. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  70626. /**
  70627. * Alias type for primitive types
  70628. * @ignorenaming
  70629. */
  70630. type Primitive = undefined | null | boolean | string | number | Function;
  70631. /**
  70632. * Type modifier to make all the properties of an object Readonly
  70633. */
  70634. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  70635. /**
  70636. * Type modifier to make all the properties of an object Readonly recursively
  70637. */
  70638. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  70639. /**
  70640. * Type modifier to make object properties readonly.
  70641. */
  70642. export type DeepImmutableObject<T> = {
  70643. readonly [K in keyof T]: DeepImmutable<T[K]>;
  70644. };
  70645. /** @hidden */
  70646. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  70647. }
  70648. }
  70649. declare module BABYLON {
  70650. /**
  70651. * A class serves as a medium between the observable and its observers
  70652. */
  70653. export class EventState {
  70654. /**
  70655. * Create a new EventState
  70656. * @param mask defines the mask associated with this state
  70657. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70658. * @param target defines the original target of the state
  70659. * @param currentTarget defines the current target of the state
  70660. */
  70661. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  70662. /**
  70663. * Initialize the current event state
  70664. * @param mask defines the mask associated with this state
  70665. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70666. * @param target defines the original target of the state
  70667. * @param currentTarget defines the current target of the state
  70668. * @returns the current event state
  70669. */
  70670. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  70671. /**
  70672. * An Observer can set this property to true to prevent subsequent observers of being notified
  70673. */
  70674. skipNextObservers: boolean;
  70675. /**
  70676. * Get the mask value that were used to trigger the event corresponding to this EventState object
  70677. */
  70678. mask: number;
  70679. /**
  70680. * The object that originally notified the event
  70681. */
  70682. target?: any;
  70683. /**
  70684. * The current object in the bubbling phase
  70685. */
  70686. currentTarget?: any;
  70687. /**
  70688. * This will be populated with the return value of the last function that was executed.
  70689. * If it is the first function in the callback chain it will be the event data.
  70690. */
  70691. lastReturnValue?: any;
  70692. }
  70693. /**
  70694. * Represent an Observer registered to a given Observable object.
  70695. */
  70696. export class Observer<T> {
  70697. /**
  70698. * Defines the callback to call when the observer is notified
  70699. */
  70700. callback: (eventData: T, eventState: EventState) => void;
  70701. /**
  70702. * Defines the mask of the observer (used to filter notifications)
  70703. */
  70704. mask: number;
  70705. /**
  70706. * Defines the current scope used to restore the JS context
  70707. */
  70708. scope: any;
  70709. /** @hidden */
  70710. _willBeUnregistered: boolean;
  70711. /**
  70712. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  70713. */
  70714. unregisterOnNextCall: boolean;
  70715. /**
  70716. * Creates a new observer
  70717. * @param callback defines the callback to call when the observer is notified
  70718. * @param mask defines the mask of the observer (used to filter notifications)
  70719. * @param scope defines the current scope used to restore the JS context
  70720. */
  70721. constructor(
  70722. /**
  70723. * Defines the callback to call when the observer is notified
  70724. */
  70725. callback: (eventData: T, eventState: EventState) => void,
  70726. /**
  70727. * Defines the mask of the observer (used to filter notifications)
  70728. */
  70729. mask: number,
  70730. /**
  70731. * Defines the current scope used to restore the JS context
  70732. */
  70733. scope?: any);
  70734. }
  70735. /**
  70736. * Represent a list of observers registered to multiple Observables object.
  70737. */
  70738. export class MultiObserver<T> {
  70739. private _observers;
  70740. private _observables;
  70741. /**
  70742. * Release associated resources
  70743. */
  70744. dispose(): void;
  70745. /**
  70746. * Raise a callback when one of the observable will notify
  70747. * @param observables defines a list of observables to watch
  70748. * @param callback defines the callback to call on notification
  70749. * @param mask defines the mask used to filter notifications
  70750. * @param scope defines the current scope used to restore the JS context
  70751. * @returns the new MultiObserver
  70752. */
  70753. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  70754. }
  70755. /**
  70756. * The Observable class is a simple implementation of the Observable pattern.
  70757. *
  70758. * 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.
  70759. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  70760. * 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).
  70761. * 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.
  70762. */
  70763. export class Observable<T> {
  70764. private _observers;
  70765. private _eventState;
  70766. private _onObserverAdded;
  70767. /**
  70768. * Gets the list of observers
  70769. */
  70770. get observers(): Array<Observer<T>>;
  70771. /**
  70772. * Creates a new observable
  70773. * @param onObserverAdded defines a callback to call when a new observer is added
  70774. */
  70775. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  70776. /**
  70777. * Create a new Observer with the specified callback
  70778. * @param callback the callback that will be executed for that Observer
  70779. * @param mask the mask used to filter observers
  70780. * @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.
  70781. * @param scope optional scope for the callback to be called from
  70782. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  70783. * @returns the new observer created for the callback
  70784. */
  70785. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  70786. /**
  70787. * Create a new Observer with the specified callback and unregisters after the next notification
  70788. * @param callback the callback that will be executed for that Observer
  70789. * @returns the new observer created for the callback
  70790. */
  70791. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  70792. /**
  70793. * Remove an Observer from the Observable object
  70794. * @param observer the instance of the Observer to remove
  70795. * @returns false if it doesn't belong to this Observable
  70796. */
  70797. remove(observer: Nullable<Observer<T>>): boolean;
  70798. /**
  70799. * Remove a callback from the Observable object
  70800. * @param callback the callback to remove
  70801. * @param scope optional scope. If used only the callbacks with this scope will be removed
  70802. * @returns false if it doesn't belong to this Observable
  70803. */
  70804. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  70805. private _deferUnregister;
  70806. private _remove;
  70807. /**
  70808. * Moves the observable to the top of the observer list making it get called first when notified
  70809. * @param observer the observer to move
  70810. */
  70811. makeObserverTopPriority(observer: Observer<T>): void;
  70812. /**
  70813. * Moves the observable to the bottom of the observer list making it get called last when notified
  70814. * @param observer the observer to move
  70815. */
  70816. makeObserverBottomPriority(observer: Observer<T>): void;
  70817. /**
  70818. * Notify all Observers by calling their respective callback with the given data
  70819. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  70820. * @param eventData defines the data to send to all observers
  70821. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  70822. * @param target defines the original target of the state
  70823. * @param currentTarget defines the current target of the state
  70824. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  70825. */
  70826. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  70827. /**
  70828. * Calling this will execute each callback, expecting it to be a promise or return a value.
  70829. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  70830. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  70831. * and it is crucial that all callbacks will be executed.
  70832. * The order of the callbacks is kept, callbacks are not executed parallel.
  70833. *
  70834. * @param eventData The data to be sent to each callback
  70835. * @param mask is used to filter observers defaults to -1
  70836. * @param target defines the callback target (see EventState)
  70837. * @param currentTarget defines he current object in the bubbling phase
  70838. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  70839. */
  70840. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  70841. /**
  70842. * Notify a specific observer
  70843. * @param observer defines the observer to notify
  70844. * @param eventData defines the data to be sent to each callback
  70845. * @param mask is used to filter observers defaults to -1
  70846. */
  70847. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  70848. /**
  70849. * Gets a boolean indicating if the observable has at least one observer
  70850. * @returns true is the Observable has at least one Observer registered
  70851. */
  70852. hasObservers(): boolean;
  70853. /**
  70854. * Clear the list of observers
  70855. */
  70856. clear(): void;
  70857. /**
  70858. * Clone the current observable
  70859. * @returns a new observable
  70860. */
  70861. clone(): Observable<T>;
  70862. /**
  70863. * Does this observable handles observer registered with a given mask
  70864. * @param mask defines the mask to be tested
  70865. * @return whether or not one observer registered with the given mask is handeled
  70866. **/
  70867. hasSpecificMask(mask?: number): boolean;
  70868. }
  70869. }
  70870. declare module BABYLON {
  70871. /**
  70872. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  70873. * Babylon.js
  70874. */
  70875. export class DomManagement {
  70876. /**
  70877. * Checks if the window object exists
  70878. * @returns true if the window object exists
  70879. */
  70880. static IsWindowObjectExist(): boolean;
  70881. /**
  70882. * Checks if the navigator object exists
  70883. * @returns true if the navigator object exists
  70884. */
  70885. static IsNavigatorAvailable(): boolean;
  70886. /**
  70887. * Extracts text content from a DOM element hierarchy
  70888. * @param element defines the root element
  70889. * @returns a string
  70890. */
  70891. static GetDOMTextContent(element: HTMLElement): string;
  70892. }
  70893. }
  70894. declare module BABYLON {
  70895. /**
  70896. * Logger used througouht the application to allow configuration of
  70897. * the log level required for the messages.
  70898. */
  70899. export class Logger {
  70900. /**
  70901. * No log
  70902. */
  70903. static readonly NoneLogLevel: number;
  70904. /**
  70905. * Only message logs
  70906. */
  70907. static readonly MessageLogLevel: number;
  70908. /**
  70909. * Only warning logs
  70910. */
  70911. static readonly WarningLogLevel: number;
  70912. /**
  70913. * Only error logs
  70914. */
  70915. static readonly ErrorLogLevel: number;
  70916. /**
  70917. * All logs
  70918. */
  70919. static readonly AllLogLevel: number;
  70920. private static _LogCache;
  70921. /**
  70922. * Gets a value indicating the number of loading errors
  70923. * @ignorenaming
  70924. */
  70925. static errorsCount: number;
  70926. /**
  70927. * Callback called when a new log is added
  70928. */
  70929. static OnNewCacheEntry: (entry: string) => void;
  70930. private static _AddLogEntry;
  70931. private static _FormatMessage;
  70932. private static _LogDisabled;
  70933. private static _LogEnabled;
  70934. private static _WarnDisabled;
  70935. private static _WarnEnabled;
  70936. private static _ErrorDisabled;
  70937. private static _ErrorEnabled;
  70938. /**
  70939. * Log a message to the console
  70940. */
  70941. static Log: (message: string) => void;
  70942. /**
  70943. * Write a warning message to the console
  70944. */
  70945. static Warn: (message: string) => void;
  70946. /**
  70947. * Write an error message to the console
  70948. */
  70949. static Error: (message: string) => void;
  70950. /**
  70951. * Gets current log cache (list of logs)
  70952. */
  70953. static get LogCache(): string;
  70954. /**
  70955. * Clears the log cache
  70956. */
  70957. static ClearLogCache(): void;
  70958. /**
  70959. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  70960. */
  70961. static set LogLevels(level: number);
  70962. }
  70963. }
  70964. declare module BABYLON {
  70965. /** @hidden */
  70966. export class _TypeStore {
  70967. /** @hidden */
  70968. static RegisteredTypes: {
  70969. [key: string]: Object;
  70970. };
  70971. /** @hidden */
  70972. static GetClass(fqdn: string): any;
  70973. }
  70974. }
  70975. declare module BABYLON {
  70976. /**
  70977. * Helper to manipulate strings
  70978. */
  70979. export class StringTools {
  70980. /**
  70981. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70982. * @param str Source string
  70983. * @param suffix Suffix to search for in the source string
  70984. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70985. */
  70986. static EndsWith(str: string, suffix: string): boolean;
  70987. /**
  70988. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70989. * @param str Source string
  70990. * @param suffix Suffix to search for in the source string
  70991. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70992. */
  70993. static StartsWith(str: string, suffix: string): boolean;
  70994. /**
  70995. * Decodes a buffer into a string
  70996. * @param buffer The buffer to decode
  70997. * @returns The decoded string
  70998. */
  70999. static Decode(buffer: Uint8Array | Uint16Array): string;
  71000. /**
  71001. * Encode a buffer to a base64 string
  71002. * @param buffer defines the buffer to encode
  71003. * @returns the encoded string
  71004. */
  71005. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  71006. }
  71007. }
  71008. declare module BABYLON {
  71009. /**
  71010. * Class containing a set of static utilities functions for deep copy.
  71011. */
  71012. export class DeepCopier {
  71013. /**
  71014. * Tries to copy an object by duplicating every property
  71015. * @param source defines the source object
  71016. * @param destination defines the target object
  71017. * @param doNotCopyList defines a list of properties to avoid
  71018. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  71019. */
  71020. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  71021. }
  71022. }
  71023. declare module BABYLON {
  71024. /**
  71025. * Class containing a set of static utilities functions for precision date
  71026. */
  71027. export class PrecisionDate {
  71028. /**
  71029. * Gets either window.performance.now() if supported or Date.now() else
  71030. */
  71031. static get Now(): number;
  71032. }
  71033. }
  71034. declare module BABYLON {
  71035. /** @hidden */
  71036. export class _DevTools {
  71037. static WarnImport(name: string): string;
  71038. }
  71039. }
  71040. declare module BABYLON {
  71041. /**
  71042. * Interface used to define the mechanism to get data from the network
  71043. */
  71044. export interface IWebRequest {
  71045. /**
  71046. * Returns client's response url
  71047. */
  71048. responseURL: string;
  71049. /**
  71050. * Returns client's status
  71051. */
  71052. status: number;
  71053. /**
  71054. * Returns client's status as a text
  71055. */
  71056. statusText: string;
  71057. }
  71058. }
  71059. declare module BABYLON {
  71060. /**
  71061. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71062. */
  71063. export class WebRequest implements IWebRequest {
  71064. private _xhr;
  71065. /**
  71066. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71067. * i.e. when loading files, where the server/service expects an Authorization header
  71068. */
  71069. static CustomRequestHeaders: {
  71070. [key: string]: string;
  71071. };
  71072. /**
  71073. * Add callback functions in this array to update all the requests before they get sent to the network
  71074. */
  71075. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71076. private _injectCustomRequestHeaders;
  71077. /**
  71078. * Gets or sets a function to be called when loading progress changes
  71079. */
  71080. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71081. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71082. /**
  71083. * Returns client's state
  71084. */
  71085. get readyState(): number;
  71086. /**
  71087. * Returns client's status
  71088. */
  71089. get status(): number;
  71090. /**
  71091. * Returns client's status as a text
  71092. */
  71093. get statusText(): string;
  71094. /**
  71095. * Returns client's response
  71096. */
  71097. get response(): any;
  71098. /**
  71099. * Returns client's response url
  71100. */
  71101. get responseURL(): string;
  71102. /**
  71103. * Returns client's response as text
  71104. */
  71105. get responseText(): string;
  71106. /**
  71107. * Gets or sets the expected response type
  71108. */
  71109. get responseType(): XMLHttpRequestResponseType;
  71110. set responseType(value: XMLHttpRequestResponseType);
  71111. /** @hidden */
  71112. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71113. /** @hidden */
  71114. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71115. /**
  71116. * Cancels any network activity
  71117. */
  71118. abort(): void;
  71119. /**
  71120. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71121. * @param body defines an optional request body
  71122. */
  71123. send(body?: Document | BodyInit | null): void;
  71124. /**
  71125. * Sets the request method, request URL
  71126. * @param method defines the method to use (GET, POST, etc..)
  71127. * @param url defines the url to connect with
  71128. */
  71129. open(method: string, url: string): void;
  71130. /**
  71131. * Sets the value of a request header.
  71132. * @param name The name of the header whose value is to be set
  71133. * @param value The value to set as the body of the header
  71134. */
  71135. setRequestHeader(name: string, value: string): void;
  71136. /**
  71137. * Get the string containing the text of a particular header's value.
  71138. * @param name The name of the header
  71139. * @returns The string containing the text of the given header name
  71140. */
  71141. getResponseHeader(name: string): Nullable<string>;
  71142. }
  71143. }
  71144. declare module BABYLON {
  71145. /**
  71146. * File request interface
  71147. */
  71148. export interface IFileRequest {
  71149. /**
  71150. * Raised when the request is complete (success or error).
  71151. */
  71152. onCompleteObservable: Observable<IFileRequest>;
  71153. /**
  71154. * Aborts the request for a file.
  71155. */
  71156. abort: () => void;
  71157. }
  71158. }
  71159. declare module BABYLON {
  71160. /**
  71161. * Define options used to create a render target texture
  71162. */
  71163. export class RenderTargetCreationOptions {
  71164. /**
  71165. * Specifies is mipmaps must be generated
  71166. */
  71167. generateMipMaps?: boolean;
  71168. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71169. generateDepthBuffer?: boolean;
  71170. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71171. generateStencilBuffer?: boolean;
  71172. /** Defines texture type (int by default) */
  71173. type?: number;
  71174. /** Defines sampling mode (trilinear by default) */
  71175. samplingMode?: number;
  71176. /** Defines format (RGBA by default) */
  71177. format?: number;
  71178. }
  71179. }
  71180. declare module BABYLON {
  71181. /**
  71182. * @hidden
  71183. **/
  71184. export class _TimeToken {
  71185. _startTimeQuery: Nullable<WebGLQuery>;
  71186. _endTimeQuery: Nullable<WebGLQuery>;
  71187. _timeElapsedQuery: Nullable<WebGLQuery>;
  71188. _timeElapsedQueryEnded: boolean;
  71189. }
  71190. }
  71191. declare module BABYLON {
  71192. /** Defines the cross module used constants to avoid circular dependncies */
  71193. export class Constants {
  71194. /** Defines that alpha blending is disabled */
  71195. static readonly ALPHA_DISABLE: number;
  71196. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  71197. static readonly ALPHA_ADD: number;
  71198. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71199. static readonly ALPHA_COMBINE: number;
  71200. /** Defines that alpha blending is DEST - SRC * DEST */
  71201. static readonly ALPHA_SUBTRACT: number;
  71202. /** Defines that alpha blending is SRC * DEST */
  71203. static readonly ALPHA_MULTIPLY: number;
  71204. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  71205. static readonly ALPHA_MAXIMIZED: number;
  71206. /** Defines that alpha blending is SRC + DEST */
  71207. static readonly ALPHA_ONEONE: number;
  71208. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  71209. static readonly ALPHA_PREMULTIPLIED: number;
  71210. /**
  71211. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  71212. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71213. */
  71214. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71215. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  71216. static readonly ALPHA_INTERPOLATE: number;
  71217. /**
  71218. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  71219. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71220. */
  71221. static readonly ALPHA_SCREENMODE: number;
  71222. /**
  71223. * Defines that alpha blending is SRC + DST
  71224. * Alpha will be set to SRC ALPHA + DST ALPHA
  71225. */
  71226. static readonly ALPHA_ONEONE_ONEONE: number;
  71227. /**
  71228. * Defines that alpha blending is SRC * DST ALPHA + DST
  71229. * Alpha will be set to 0
  71230. */
  71231. static readonly ALPHA_ALPHATOCOLOR: number;
  71232. /**
  71233. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71234. */
  71235. static readonly ALPHA_REVERSEONEMINUS: number;
  71236. /**
  71237. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  71238. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71239. */
  71240. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71241. /**
  71242. * Defines that alpha blending is SRC + DST
  71243. * Alpha will be set to SRC ALPHA
  71244. */
  71245. static readonly ALPHA_ONEONE_ONEZERO: number;
  71246. /**
  71247. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71248. * Alpha will be set to DST ALPHA
  71249. */
  71250. static readonly ALPHA_EXCLUSION: number;
  71251. /** Defines that alpha blending equation a SUM */
  71252. static readonly ALPHA_EQUATION_ADD: number;
  71253. /** Defines that alpha blending equation a SUBSTRACTION */
  71254. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71255. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71256. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71257. /** Defines that alpha blending equation a MAX operation */
  71258. static readonly ALPHA_EQUATION_MAX: number;
  71259. /** Defines that alpha blending equation a MIN operation */
  71260. static readonly ALPHA_EQUATION_MIN: number;
  71261. /**
  71262. * Defines that alpha blending equation a DARKEN operation:
  71263. * It takes the min of the src and sums the alpha channels.
  71264. */
  71265. static readonly ALPHA_EQUATION_DARKEN: number;
  71266. /** Defines that the ressource is not delayed*/
  71267. static readonly DELAYLOADSTATE_NONE: number;
  71268. /** Defines that the ressource was successfully delay loaded */
  71269. static readonly DELAYLOADSTATE_LOADED: number;
  71270. /** Defines that the ressource is currently delay loading */
  71271. static readonly DELAYLOADSTATE_LOADING: number;
  71272. /** Defines that the ressource is delayed and has not started loading */
  71273. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71274. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71275. static readonly NEVER: number;
  71276. /** 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 */
  71277. static readonly ALWAYS: number;
  71278. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71279. static readonly LESS: number;
  71280. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71281. static readonly EQUAL: number;
  71282. /** 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 */
  71283. static readonly LEQUAL: number;
  71284. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71285. static readonly GREATER: number;
  71286. /** 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 */
  71287. static readonly GEQUAL: number;
  71288. /** 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 */
  71289. static readonly NOTEQUAL: number;
  71290. /** Passed to stencilOperation to specify that stencil value must be kept */
  71291. static readonly KEEP: number;
  71292. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71293. static readonly REPLACE: number;
  71294. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71295. static readonly INCR: number;
  71296. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71297. static readonly DECR: number;
  71298. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71299. static readonly INVERT: number;
  71300. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71301. static readonly INCR_WRAP: number;
  71302. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71303. static readonly DECR_WRAP: number;
  71304. /** Texture is not repeating outside of 0..1 UVs */
  71305. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71306. /** Texture is repeating outside of 0..1 UVs */
  71307. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71308. /** Texture is repeating and mirrored */
  71309. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71310. /** ALPHA */
  71311. static readonly TEXTUREFORMAT_ALPHA: number;
  71312. /** LUMINANCE */
  71313. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71314. /** LUMINANCE_ALPHA */
  71315. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71316. /** RGB */
  71317. static readonly TEXTUREFORMAT_RGB: number;
  71318. /** RGBA */
  71319. static readonly TEXTUREFORMAT_RGBA: number;
  71320. /** RED */
  71321. static readonly TEXTUREFORMAT_RED: number;
  71322. /** RED (2nd reference) */
  71323. static readonly TEXTUREFORMAT_R: number;
  71324. /** RG */
  71325. static readonly TEXTUREFORMAT_RG: number;
  71326. /** RED_INTEGER */
  71327. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71328. /** RED_INTEGER (2nd reference) */
  71329. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71330. /** RG_INTEGER */
  71331. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71332. /** RGB_INTEGER */
  71333. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71334. /** RGBA_INTEGER */
  71335. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71336. /** UNSIGNED_BYTE */
  71337. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71338. /** UNSIGNED_BYTE (2nd reference) */
  71339. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71340. /** FLOAT */
  71341. static readonly TEXTURETYPE_FLOAT: number;
  71342. /** HALF_FLOAT */
  71343. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71344. /** BYTE */
  71345. static readonly TEXTURETYPE_BYTE: number;
  71346. /** SHORT */
  71347. static readonly TEXTURETYPE_SHORT: number;
  71348. /** UNSIGNED_SHORT */
  71349. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71350. /** INT */
  71351. static readonly TEXTURETYPE_INT: number;
  71352. /** UNSIGNED_INT */
  71353. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71354. /** UNSIGNED_SHORT_4_4_4_4 */
  71355. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71356. /** UNSIGNED_SHORT_5_5_5_1 */
  71357. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71358. /** UNSIGNED_SHORT_5_6_5 */
  71359. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71360. /** UNSIGNED_INT_2_10_10_10_REV */
  71361. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71362. /** UNSIGNED_INT_24_8 */
  71363. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71364. /** UNSIGNED_INT_10F_11F_11F_REV */
  71365. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71366. /** UNSIGNED_INT_5_9_9_9_REV */
  71367. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71368. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71369. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71370. /** nearest is mag = nearest and min = nearest and mip = nearest */
  71371. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71372. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71373. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71374. /** Trilinear is mag = linear and min = linear and mip = linear */
  71375. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71376. /** nearest is mag = nearest and min = nearest and mip = linear */
  71377. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71379. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71380. /** Trilinear is mag = linear and min = linear and mip = linear */
  71381. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71382. /** mag = nearest and min = nearest and mip = nearest */
  71383. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71384. /** mag = nearest and min = linear and mip = nearest */
  71385. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71386. /** mag = nearest and min = linear and mip = linear */
  71387. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71388. /** mag = nearest and min = linear and mip = none */
  71389. static readonly TEXTURE_NEAREST_LINEAR: number;
  71390. /** mag = nearest and min = nearest and mip = none */
  71391. static readonly TEXTURE_NEAREST_NEAREST: number;
  71392. /** mag = linear and min = nearest and mip = nearest */
  71393. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71394. /** mag = linear and min = nearest and mip = linear */
  71395. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71396. /** mag = linear and min = linear and mip = none */
  71397. static readonly TEXTURE_LINEAR_LINEAR: number;
  71398. /** mag = linear and min = nearest and mip = none */
  71399. static readonly TEXTURE_LINEAR_NEAREST: number;
  71400. /** Explicit coordinates mode */
  71401. static readonly TEXTURE_EXPLICIT_MODE: number;
  71402. /** Spherical coordinates mode */
  71403. static readonly TEXTURE_SPHERICAL_MODE: number;
  71404. /** Planar coordinates mode */
  71405. static readonly TEXTURE_PLANAR_MODE: number;
  71406. /** Cubic coordinates mode */
  71407. static readonly TEXTURE_CUBIC_MODE: number;
  71408. /** Projection coordinates mode */
  71409. static readonly TEXTURE_PROJECTION_MODE: number;
  71410. /** Skybox coordinates mode */
  71411. static readonly TEXTURE_SKYBOX_MODE: number;
  71412. /** Inverse Cubic coordinates mode */
  71413. static readonly TEXTURE_INVCUBIC_MODE: number;
  71414. /** Equirectangular coordinates mode */
  71415. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71416. /** Equirectangular Fixed coordinates mode */
  71417. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71418. /** Equirectangular Fixed Mirrored coordinates mode */
  71419. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71420. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71421. static readonly SCALEMODE_FLOOR: number;
  71422. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71423. static readonly SCALEMODE_NEAREST: number;
  71424. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71425. static readonly SCALEMODE_CEILING: number;
  71426. /**
  71427. * The dirty texture flag value
  71428. */
  71429. static readonly MATERIAL_TextureDirtyFlag: number;
  71430. /**
  71431. * The dirty light flag value
  71432. */
  71433. static readonly MATERIAL_LightDirtyFlag: number;
  71434. /**
  71435. * The dirty fresnel flag value
  71436. */
  71437. static readonly MATERIAL_FresnelDirtyFlag: number;
  71438. /**
  71439. * The dirty attribute flag value
  71440. */
  71441. static readonly MATERIAL_AttributesDirtyFlag: number;
  71442. /**
  71443. * The dirty misc flag value
  71444. */
  71445. static readonly MATERIAL_MiscDirtyFlag: number;
  71446. /**
  71447. * The all dirty flag value
  71448. */
  71449. static readonly MATERIAL_AllDirtyFlag: number;
  71450. /**
  71451. * Returns the triangle fill mode
  71452. */
  71453. static readonly MATERIAL_TriangleFillMode: number;
  71454. /**
  71455. * Returns the wireframe mode
  71456. */
  71457. static readonly MATERIAL_WireFrameFillMode: number;
  71458. /**
  71459. * Returns the point fill mode
  71460. */
  71461. static readonly MATERIAL_PointFillMode: number;
  71462. /**
  71463. * Returns the point list draw mode
  71464. */
  71465. static readonly MATERIAL_PointListDrawMode: number;
  71466. /**
  71467. * Returns the line list draw mode
  71468. */
  71469. static readonly MATERIAL_LineListDrawMode: number;
  71470. /**
  71471. * Returns the line loop draw mode
  71472. */
  71473. static readonly MATERIAL_LineLoopDrawMode: number;
  71474. /**
  71475. * Returns the line strip draw mode
  71476. */
  71477. static readonly MATERIAL_LineStripDrawMode: number;
  71478. /**
  71479. * Returns the triangle strip draw mode
  71480. */
  71481. static readonly MATERIAL_TriangleStripDrawMode: number;
  71482. /**
  71483. * Returns the triangle fan draw mode
  71484. */
  71485. static readonly MATERIAL_TriangleFanDrawMode: number;
  71486. /**
  71487. * Stores the clock-wise side orientation
  71488. */
  71489. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71490. /**
  71491. * Stores the counter clock-wise side orientation
  71492. */
  71493. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71494. /**
  71495. * Nothing
  71496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71497. */
  71498. static readonly ACTION_NothingTrigger: number;
  71499. /**
  71500. * On pick
  71501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71502. */
  71503. static readonly ACTION_OnPickTrigger: number;
  71504. /**
  71505. * On left pick
  71506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71507. */
  71508. static readonly ACTION_OnLeftPickTrigger: number;
  71509. /**
  71510. * On right pick
  71511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71512. */
  71513. static readonly ACTION_OnRightPickTrigger: number;
  71514. /**
  71515. * On center pick
  71516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71517. */
  71518. static readonly ACTION_OnCenterPickTrigger: number;
  71519. /**
  71520. * On pick down
  71521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71522. */
  71523. static readonly ACTION_OnPickDownTrigger: number;
  71524. /**
  71525. * On double pick
  71526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71527. */
  71528. static readonly ACTION_OnDoublePickTrigger: number;
  71529. /**
  71530. * On pick up
  71531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71532. */
  71533. static readonly ACTION_OnPickUpTrigger: number;
  71534. /**
  71535. * On pick out.
  71536. * This trigger will only be raised if you also declared a OnPickDown
  71537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71538. */
  71539. static readonly ACTION_OnPickOutTrigger: number;
  71540. /**
  71541. * On long press
  71542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71543. */
  71544. static readonly ACTION_OnLongPressTrigger: number;
  71545. /**
  71546. * On pointer over
  71547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71548. */
  71549. static readonly ACTION_OnPointerOverTrigger: number;
  71550. /**
  71551. * On pointer out
  71552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71553. */
  71554. static readonly ACTION_OnPointerOutTrigger: number;
  71555. /**
  71556. * On every frame
  71557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71558. */
  71559. static readonly ACTION_OnEveryFrameTrigger: number;
  71560. /**
  71561. * On intersection enter
  71562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71563. */
  71564. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71565. /**
  71566. * On intersection exit
  71567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71568. */
  71569. static readonly ACTION_OnIntersectionExitTrigger: number;
  71570. /**
  71571. * On key down
  71572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71573. */
  71574. static readonly ACTION_OnKeyDownTrigger: number;
  71575. /**
  71576. * On key up
  71577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71578. */
  71579. static readonly ACTION_OnKeyUpTrigger: number;
  71580. /**
  71581. * Billboard mode will only apply to Y axis
  71582. */
  71583. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71584. /**
  71585. * Billboard mode will apply to all axes
  71586. */
  71587. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71588. /**
  71589. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71590. */
  71591. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71592. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71593. * Test order :
  71594. * Is the bounding sphere outside the frustum ?
  71595. * If not, are the bounding box vertices outside the frustum ?
  71596. * It not, then the cullable object is in the frustum.
  71597. */
  71598. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71599. /** Culling strategy : Bounding Sphere Only.
  71600. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71601. * It's also less accurate than the standard because some not visible objects can still be selected.
  71602. * Test : is the bounding sphere outside the frustum ?
  71603. * If not, then the cullable object is in the frustum.
  71604. */
  71605. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71606. /** Culling strategy : Optimistic Inclusion.
  71607. * This in an inclusion test first, then the standard exclusion test.
  71608. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71609. * 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.
  71610. * Anyway, it's as accurate as the standard strategy.
  71611. * Test :
  71612. * Is the cullable object bounding sphere center in the frustum ?
  71613. * If not, apply the default culling strategy.
  71614. */
  71615. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71616. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71617. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71618. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71619. * 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.
  71620. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71621. * Test :
  71622. * Is the cullable object bounding sphere center in the frustum ?
  71623. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71624. */
  71625. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71626. /**
  71627. * No logging while loading
  71628. */
  71629. static readonly SCENELOADER_NO_LOGGING: number;
  71630. /**
  71631. * Minimal logging while loading
  71632. */
  71633. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71634. /**
  71635. * Summary logging while loading
  71636. */
  71637. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71638. /**
  71639. * Detailled logging while loading
  71640. */
  71641. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71642. }
  71643. }
  71644. declare module BABYLON {
  71645. /**
  71646. * This represents the required contract to create a new type of texture loader.
  71647. */
  71648. export interface IInternalTextureLoader {
  71649. /**
  71650. * Defines wether the loader supports cascade loading the different faces.
  71651. */
  71652. supportCascades: boolean;
  71653. /**
  71654. * This returns if the loader support the current file information.
  71655. * @param extension defines the file extension of the file being loaded
  71656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71657. * @param fallback defines the fallback internal texture if any
  71658. * @param isBase64 defines whether the texture is encoded as a base64
  71659. * @param isBuffer defines whether the texture data are stored as a buffer
  71660. * @returns true if the loader can load the specified file
  71661. */
  71662. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71663. /**
  71664. * Transform the url before loading if required.
  71665. * @param rootUrl the url of the texture
  71666. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71667. * @returns the transformed texture
  71668. */
  71669. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71670. /**
  71671. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71672. * @param rootUrl the url of the texture
  71673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71674. * @returns the fallback texture
  71675. */
  71676. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71677. /**
  71678. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71679. * @param data contains the texture data
  71680. * @param texture defines the BabylonJS internal texture
  71681. * @param createPolynomials will be true if polynomials have been requested
  71682. * @param onLoad defines the callback to trigger once the texture is ready
  71683. * @param onError defines the callback to trigger in case of error
  71684. */
  71685. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71686. /**
  71687. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71688. * @param data contains the texture data
  71689. * @param texture defines the BabylonJS internal texture
  71690. * @param callback defines the method to call once ready to upload
  71691. */
  71692. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71693. }
  71694. }
  71695. declare module BABYLON {
  71696. /**
  71697. * Class used to store and describe the pipeline context associated with an effect
  71698. */
  71699. export interface IPipelineContext {
  71700. /**
  71701. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71702. */
  71703. isAsync: boolean;
  71704. /**
  71705. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71706. */
  71707. isReady: boolean;
  71708. /** @hidden */
  71709. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71710. }
  71711. }
  71712. declare module BABYLON {
  71713. /**
  71714. * Class used to store gfx data (like WebGLBuffer)
  71715. */
  71716. export class DataBuffer {
  71717. /**
  71718. * Gets or sets the number of objects referencing this buffer
  71719. */
  71720. references: number;
  71721. /** Gets or sets the size of the underlying buffer */
  71722. capacity: number;
  71723. /**
  71724. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71725. */
  71726. is32Bits: boolean;
  71727. /**
  71728. * Gets the underlying buffer
  71729. */
  71730. get underlyingResource(): any;
  71731. }
  71732. }
  71733. declare module BABYLON {
  71734. /** @hidden */
  71735. export interface IShaderProcessor {
  71736. attributeProcessor?: (attribute: string) => string;
  71737. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71738. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71739. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71740. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71741. lineProcessor?: (line: string, isFragment: boolean) => string;
  71742. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71743. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71744. }
  71745. }
  71746. declare module BABYLON {
  71747. /** @hidden */
  71748. export interface ProcessingOptions {
  71749. defines: string[];
  71750. indexParameters: any;
  71751. isFragment: boolean;
  71752. shouldUseHighPrecisionShader: boolean;
  71753. supportsUniformBuffers: boolean;
  71754. shadersRepository: string;
  71755. includesShadersStore: {
  71756. [key: string]: string;
  71757. };
  71758. processor?: IShaderProcessor;
  71759. version: string;
  71760. platformName: string;
  71761. lookForClosingBracketForUniformBuffer?: boolean;
  71762. }
  71763. }
  71764. declare module BABYLON {
  71765. /** @hidden */
  71766. export class ShaderCodeNode {
  71767. line: string;
  71768. children: ShaderCodeNode[];
  71769. additionalDefineKey?: string;
  71770. additionalDefineValue?: string;
  71771. isValid(preprocessors: {
  71772. [key: string]: string;
  71773. }): boolean;
  71774. process(preprocessors: {
  71775. [key: string]: string;
  71776. }, options: ProcessingOptions): string;
  71777. }
  71778. }
  71779. declare module BABYLON {
  71780. /** @hidden */
  71781. export class ShaderCodeCursor {
  71782. private _lines;
  71783. lineIndex: number;
  71784. get currentLine(): string;
  71785. get canRead(): boolean;
  71786. set lines(value: string[]);
  71787. }
  71788. }
  71789. declare module BABYLON {
  71790. /** @hidden */
  71791. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71792. process(preprocessors: {
  71793. [key: string]: string;
  71794. }, options: ProcessingOptions): string;
  71795. }
  71796. }
  71797. declare module BABYLON {
  71798. /** @hidden */
  71799. export class ShaderDefineExpression {
  71800. isTrue(preprocessors: {
  71801. [key: string]: string;
  71802. }): boolean;
  71803. }
  71804. }
  71805. declare module BABYLON {
  71806. /** @hidden */
  71807. export class ShaderCodeTestNode extends ShaderCodeNode {
  71808. testExpression: ShaderDefineExpression;
  71809. isValid(preprocessors: {
  71810. [key: string]: string;
  71811. }): boolean;
  71812. }
  71813. }
  71814. declare module BABYLON {
  71815. /** @hidden */
  71816. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71817. define: string;
  71818. not: boolean;
  71819. constructor(define: string, not?: boolean);
  71820. isTrue(preprocessors: {
  71821. [key: string]: string;
  71822. }): boolean;
  71823. }
  71824. }
  71825. declare module BABYLON {
  71826. /** @hidden */
  71827. export class ShaderDefineOrOperator 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 ShaderDefineAndOperator extends ShaderDefineExpression {
  71838. leftOperand: ShaderDefineExpression;
  71839. rightOperand: ShaderDefineExpression;
  71840. isTrue(preprocessors: {
  71841. [key: string]: string;
  71842. }): boolean;
  71843. }
  71844. }
  71845. declare module BABYLON {
  71846. /** @hidden */
  71847. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71848. define: string;
  71849. operand: string;
  71850. testValue: string;
  71851. constructor(define: string, operand: string, testValue: string);
  71852. isTrue(preprocessors: {
  71853. [key: string]: string;
  71854. }): boolean;
  71855. }
  71856. }
  71857. declare module BABYLON {
  71858. /**
  71859. * Class used to enable access to offline support
  71860. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71861. */
  71862. export interface IOfflineProvider {
  71863. /**
  71864. * Gets a boolean indicating if scene must be saved in the database
  71865. */
  71866. enableSceneOffline: boolean;
  71867. /**
  71868. * Gets a boolean indicating if textures must be saved in the database
  71869. */
  71870. enableTexturesOffline: boolean;
  71871. /**
  71872. * Open the offline support and make it available
  71873. * @param successCallback defines the callback to call on success
  71874. * @param errorCallback defines the callback to call on error
  71875. */
  71876. open(successCallback: () => void, errorCallback: () => void): void;
  71877. /**
  71878. * Loads an image from the offline support
  71879. * @param url defines the url to load from
  71880. * @param image defines the target DOM image
  71881. */
  71882. loadImage(url: string, image: HTMLImageElement): void;
  71883. /**
  71884. * Loads a file from offline support
  71885. * @param url defines the URL to load from
  71886. * @param sceneLoaded defines a callback to call on success
  71887. * @param progressCallBack defines a callback to call when progress changed
  71888. * @param errorCallback defines a callback to call on error
  71889. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71890. */
  71891. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71892. }
  71893. }
  71894. declare module BABYLON {
  71895. /**
  71896. * Class used to help managing file picking and drag'n'drop
  71897. * File Storage
  71898. */
  71899. export class FilesInputStore {
  71900. /**
  71901. * List of files ready to be loaded
  71902. */
  71903. static FilesToLoad: {
  71904. [key: string]: File;
  71905. };
  71906. }
  71907. }
  71908. declare module BABYLON {
  71909. /**
  71910. * Class used to define a retry strategy when error happens while loading assets
  71911. */
  71912. export class RetryStrategy {
  71913. /**
  71914. * Function used to defines an exponential back off strategy
  71915. * @param maxRetries defines the maximum number of retries (3 by default)
  71916. * @param baseInterval defines the interval between retries
  71917. * @returns the strategy function to use
  71918. */
  71919. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71920. }
  71921. }
  71922. declare module BABYLON {
  71923. /**
  71924. * @ignore
  71925. * Application error to support additional information when loading a file
  71926. */
  71927. export abstract class BaseError extends Error {
  71928. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  71929. }
  71930. }
  71931. declare module BABYLON {
  71932. /** @ignore */
  71933. export class LoadFileError extends BaseError {
  71934. request?: WebRequest;
  71935. file?: File;
  71936. /**
  71937. * Creates a new LoadFileError
  71938. * @param message defines the message of the error
  71939. * @param request defines the optional web request
  71940. * @param file defines the optional file
  71941. */
  71942. constructor(message: string, object?: WebRequest | File);
  71943. }
  71944. /** @ignore */
  71945. export class RequestFileError extends BaseError {
  71946. request: WebRequest;
  71947. /**
  71948. * Creates a new LoadFileError
  71949. * @param message defines the message of the error
  71950. * @param request defines the optional web request
  71951. */
  71952. constructor(message: string, request: WebRequest);
  71953. }
  71954. /** @ignore */
  71955. export class ReadFileError extends BaseError {
  71956. file: File;
  71957. /**
  71958. * Creates a new ReadFileError
  71959. * @param message defines the message of the error
  71960. * @param file defines the optional file
  71961. */
  71962. constructor(message: string, file: File);
  71963. }
  71964. /**
  71965. * @hidden
  71966. */
  71967. export class FileTools {
  71968. /**
  71969. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71970. */
  71971. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71972. /**
  71973. * Gets or sets the base URL to use to load assets
  71974. */
  71975. static BaseUrl: string;
  71976. /**
  71977. * Default behaviour for cors in the application.
  71978. * It can be a string if the expected behavior is identical in the entire app.
  71979. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71980. */
  71981. static CorsBehavior: string | ((url: string | string[]) => string);
  71982. /**
  71983. * Gets or sets a function used to pre-process url before using them to load assets
  71984. */
  71985. static PreprocessUrl: (url: string) => string;
  71986. /**
  71987. * Removes unwanted characters from an url
  71988. * @param url defines the url to clean
  71989. * @returns the cleaned url
  71990. */
  71991. private static _CleanUrl;
  71992. /**
  71993. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71994. * @param url define the url we are trying
  71995. * @param element define the dom element where to configure the cors policy
  71996. */
  71997. static SetCorsBehavior(url: string | string[], element: {
  71998. crossOrigin: string | null;
  71999. }): void;
  72000. /**
  72001. * Loads an image as an HTMLImageElement.
  72002. * @param input url string, ArrayBuffer, or Blob to load
  72003. * @param onLoad callback called when the image successfully loads
  72004. * @param onError callback called when the image fails to load
  72005. * @param offlineProvider offline provider for caching
  72006. * @param mimeType optional mime type
  72007. * @returns the HTMLImageElement of the loaded image
  72008. */
  72009. 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>;
  72010. /**
  72011. * Reads a file from a File object
  72012. * @param file defines the file to load
  72013. * @param onSuccess defines the callback to call when data is loaded
  72014. * @param onProgress defines the callback to call during loading process
  72015. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  72016. * @param onError defines the callback to call when an error occurs
  72017. * @returns a file request object
  72018. */
  72019. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  72020. /**
  72021. * Loads a file from a url
  72022. * @param url url to load
  72023. * @param onSuccess callback called when the file successfully loads
  72024. * @param onProgress callback called while file is loading (if the server supports this mode)
  72025. * @param offlineProvider defines the offline provider for caching
  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. * @returns a file request object
  72029. */
  72030. 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;
  72031. /**
  72032. * Loads a file
  72033. * @param url url to load
  72034. * @param onSuccess callback called when the file successfully loads
  72035. * @param onProgress callback called while file is loading (if the server supports this mode)
  72036. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72037. * @param onError callback called when the file fails to load
  72038. * @param onOpened callback called when the web request is opened
  72039. * @returns a file request object
  72040. */
  72041. 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;
  72042. /**
  72043. * Checks if the loaded document was accessed via `file:`-Protocol.
  72044. * @returns boolean
  72045. */
  72046. static IsFileURL(): boolean;
  72047. }
  72048. }
  72049. declare module BABYLON {
  72050. /** @hidden */
  72051. export class ShaderProcessor {
  72052. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72053. private static _ProcessPrecision;
  72054. private static _ExtractOperation;
  72055. private static _BuildSubExpression;
  72056. private static _BuildExpression;
  72057. private static _MoveCursorWithinIf;
  72058. private static _MoveCursor;
  72059. private static _EvaluatePreProcessors;
  72060. private static _PreparePreProcessors;
  72061. private static _ProcessShaderConversion;
  72062. private static _ProcessIncludes;
  72063. }
  72064. }
  72065. declare module BABYLON {
  72066. /**
  72067. * @hidden
  72068. */
  72069. export interface IColor4Like {
  72070. r: float;
  72071. g: float;
  72072. b: float;
  72073. a: float;
  72074. }
  72075. /**
  72076. * @hidden
  72077. */
  72078. export interface IColor3Like {
  72079. r: float;
  72080. g: float;
  72081. b: float;
  72082. }
  72083. /**
  72084. * @hidden
  72085. */
  72086. export interface IVector4Like {
  72087. x: float;
  72088. y: float;
  72089. z: float;
  72090. w: float;
  72091. }
  72092. /**
  72093. * @hidden
  72094. */
  72095. export interface IVector3Like {
  72096. x: float;
  72097. y: float;
  72098. z: float;
  72099. }
  72100. /**
  72101. * @hidden
  72102. */
  72103. export interface IVector2Like {
  72104. x: float;
  72105. y: float;
  72106. }
  72107. /**
  72108. * @hidden
  72109. */
  72110. export interface IMatrixLike {
  72111. toArray(): DeepImmutable<Float32Array>;
  72112. updateFlag: int;
  72113. }
  72114. /**
  72115. * @hidden
  72116. */
  72117. export interface IViewportLike {
  72118. x: float;
  72119. y: float;
  72120. width: float;
  72121. height: float;
  72122. }
  72123. /**
  72124. * @hidden
  72125. */
  72126. export interface IPlaneLike {
  72127. normal: IVector3Like;
  72128. d: float;
  72129. normalize(): void;
  72130. }
  72131. }
  72132. declare module BABYLON {
  72133. /**
  72134. * Interface used to define common properties for effect fallbacks
  72135. */
  72136. export interface IEffectFallbacks {
  72137. /**
  72138. * Removes the defines that should be removed when falling back.
  72139. * @param currentDefines defines the current define statements for the shader.
  72140. * @param effect defines the current effect we try to compile
  72141. * @returns The resulting defines with defines of the current rank removed.
  72142. */
  72143. reduce(currentDefines: string, effect: Effect): string;
  72144. /**
  72145. * Removes the fallback from the bound mesh.
  72146. */
  72147. unBindMesh(): void;
  72148. /**
  72149. * Checks to see if more fallbacks are still availible.
  72150. */
  72151. hasMoreFallbacks: boolean;
  72152. }
  72153. }
  72154. declare module BABYLON {
  72155. /**
  72156. * Class used to evalaute queries containing `and` and `or` operators
  72157. */
  72158. export class AndOrNotEvaluator {
  72159. /**
  72160. * Evaluate a query
  72161. * @param query defines the query to evaluate
  72162. * @param evaluateCallback defines the callback used to filter result
  72163. * @returns true if the query matches
  72164. */
  72165. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72166. private static _HandleParenthesisContent;
  72167. private static _SimplifyNegation;
  72168. }
  72169. }
  72170. declare module BABYLON {
  72171. /**
  72172. * Class used to store custom tags
  72173. */
  72174. export class Tags {
  72175. /**
  72176. * Adds support for tags on the given object
  72177. * @param obj defines the object to use
  72178. */
  72179. static EnableFor(obj: any): void;
  72180. /**
  72181. * Removes tags support
  72182. * @param obj defines the object to use
  72183. */
  72184. static DisableFor(obj: any): void;
  72185. /**
  72186. * Gets a boolean indicating if the given object has tags
  72187. * @param obj defines the object to use
  72188. * @returns a boolean
  72189. */
  72190. static HasTags(obj: any): boolean;
  72191. /**
  72192. * Gets the tags available on a given object
  72193. * @param obj defines the object to use
  72194. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72195. * @returns the tags
  72196. */
  72197. static GetTags(obj: any, asString?: boolean): any;
  72198. /**
  72199. * Adds tags to an object
  72200. * @param obj defines the object to use
  72201. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72202. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72203. */
  72204. static AddTagsTo(obj: any, tagsString: string): void;
  72205. /**
  72206. * @hidden
  72207. */
  72208. static _AddTagTo(obj: any, tag: string): void;
  72209. /**
  72210. * Removes specific tags from a specific object
  72211. * @param obj defines the object to use
  72212. * @param tagsString defines the tags to remove
  72213. */
  72214. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72215. /**
  72216. * @hidden
  72217. */
  72218. static _RemoveTagFrom(obj: any, tag: string): void;
  72219. /**
  72220. * Defines if tags hosted on an object match a given query
  72221. * @param obj defines the object to use
  72222. * @param tagsQuery defines the tag query
  72223. * @returns a boolean
  72224. */
  72225. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72226. }
  72227. }
  72228. declare module BABYLON {
  72229. /**
  72230. * Scalar computation library
  72231. */
  72232. export class Scalar {
  72233. /**
  72234. * Two pi constants convenient for computation.
  72235. */
  72236. static TwoPi: number;
  72237. /**
  72238. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72239. * @param a number
  72240. * @param b number
  72241. * @param epsilon (default = 1.401298E-45)
  72242. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72243. */
  72244. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  72245. /**
  72246. * Returns a string : the upper case translation of the number i to hexadecimal.
  72247. * @param i number
  72248. * @returns the upper case translation of the number i to hexadecimal.
  72249. */
  72250. static ToHex(i: number): string;
  72251. /**
  72252. * Returns -1 if value is negative and +1 is value is positive.
  72253. * @param value the value
  72254. * @returns the value itself if it's equal to zero.
  72255. */
  72256. static Sign(value: number): number;
  72257. /**
  72258. * Returns the value itself if it's between min and max.
  72259. * Returns min if the value is lower than min.
  72260. * Returns max if the value is greater than max.
  72261. * @param value the value to clmap
  72262. * @param min the min value to clamp to (default: 0)
  72263. * @param max the max value to clamp to (default: 1)
  72264. * @returns the clamped value
  72265. */
  72266. static Clamp(value: number, min?: number, max?: number): number;
  72267. /**
  72268. * the log2 of value.
  72269. * @param value the value to compute log2 of
  72270. * @returns the log2 of value.
  72271. */
  72272. static Log2(value: number): number;
  72273. /**
  72274. * Loops the value, so that it is never larger than length and never smaller than 0.
  72275. *
  72276. * This is similar to the modulo operator but it works with floating point numbers.
  72277. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  72278. * With t = 5 and length = 2.5, the result would be 0.0.
  72279. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  72280. * @param value the value
  72281. * @param length the length
  72282. * @returns the looped value
  72283. */
  72284. static Repeat(value: number, length: number): number;
  72285. /**
  72286. * Normalize the value between 0.0 and 1.0 using min and max values
  72287. * @param value value to normalize
  72288. * @param min max to normalize between
  72289. * @param max min to normalize between
  72290. * @returns the normalized value
  72291. */
  72292. static Normalize(value: number, min: number, max: number): number;
  72293. /**
  72294. * Denormalize the value from 0.0 and 1.0 using min and max values
  72295. * @param normalized value to denormalize
  72296. * @param min max to denormalize between
  72297. * @param max min to denormalize between
  72298. * @returns the denormalized value
  72299. */
  72300. static Denormalize(normalized: number, min: number, max: number): number;
  72301. /**
  72302. * Calculates the shortest difference between two given angles given in degrees.
  72303. * @param current current angle in degrees
  72304. * @param target target angle in degrees
  72305. * @returns the delta
  72306. */
  72307. static DeltaAngle(current: number, target: number): number;
  72308. /**
  72309. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  72310. * @param tx value
  72311. * @param length length
  72312. * @returns The returned value will move back and forth between 0 and length
  72313. */
  72314. static PingPong(tx: number, length: number): number;
  72315. /**
  72316. * Interpolates between min and max with smoothing at the limits.
  72317. *
  72318. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  72319. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  72320. * @param from from
  72321. * @param to to
  72322. * @param tx value
  72323. * @returns the smooth stepped value
  72324. */
  72325. static SmoothStep(from: number, to: number, tx: number): number;
  72326. /**
  72327. * Moves a value current towards target.
  72328. *
  72329. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  72330. * Negative values of maxDelta pushes the value away from target.
  72331. * @param current current value
  72332. * @param target target value
  72333. * @param maxDelta max distance to move
  72334. * @returns resulting value
  72335. */
  72336. static MoveTowards(current: number, target: number, maxDelta: number): number;
  72337. /**
  72338. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72339. *
  72340. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  72341. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  72342. * @param current current value
  72343. * @param target target value
  72344. * @param maxDelta max distance to move
  72345. * @returns resulting angle
  72346. */
  72347. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  72348. /**
  72349. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  72350. * @param start start value
  72351. * @param end target value
  72352. * @param amount amount to lerp between
  72353. * @returns the lerped value
  72354. */
  72355. static Lerp(start: number, end: number, amount: number): number;
  72356. /**
  72357. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72358. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  72359. * @param start start value
  72360. * @param end target value
  72361. * @param amount amount to lerp between
  72362. * @returns the lerped value
  72363. */
  72364. static LerpAngle(start: number, end: number, amount: number): number;
  72365. /**
  72366. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  72367. * @param a start value
  72368. * @param b target value
  72369. * @param value value between a and b
  72370. * @returns the inverseLerp value
  72371. */
  72372. static InverseLerp(a: number, b: number, value: number): number;
  72373. /**
  72374. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  72375. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  72376. * @param value1 spline value
  72377. * @param tangent1 spline value
  72378. * @param value2 spline value
  72379. * @param tangent2 spline value
  72380. * @param amount input value
  72381. * @returns hermite result
  72382. */
  72383. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  72384. /**
  72385. * Returns a random float number between and min and max values
  72386. * @param min min value of random
  72387. * @param max max value of random
  72388. * @returns random value
  72389. */
  72390. static RandomRange(min: number, max: number): number;
  72391. /**
  72392. * This function returns percentage of a number in a given range.
  72393. *
  72394. * RangeToPercent(40,20,60) will return 0.5 (50%)
  72395. * RangeToPercent(34,0,100) will return 0.34 (34%)
  72396. * @param number to convert to percentage
  72397. * @param min min range
  72398. * @param max max range
  72399. * @returns the percentage
  72400. */
  72401. static RangeToPercent(number: number, min: number, max: number): number;
  72402. /**
  72403. * This function returns number that corresponds to the percentage in a given range.
  72404. *
  72405. * PercentToRange(0.34,0,100) will return 34.
  72406. * @param percent to convert to number
  72407. * @param min min range
  72408. * @param max max range
  72409. * @returns the number
  72410. */
  72411. static PercentToRange(percent: number, min: number, max: number): number;
  72412. /**
  72413. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  72414. * @param angle The angle to normalize in radian.
  72415. * @return The converted angle.
  72416. */
  72417. static NormalizeRadians(angle: number): number;
  72418. }
  72419. }
  72420. declare module BABYLON {
  72421. /**
  72422. * Constant used to convert a value to gamma space
  72423. * @ignorenaming
  72424. */
  72425. export const ToGammaSpace: number;
  72426. /**
  72427. * Constant used to convert a value to linear space
  72428. * @ignorenaming
  72429. */
  72430. export const ToLinearSpace = 2.2;
  72431. /**
  72432. * Constant used to define the minimal number value in Babylon.js
  72433. * @ignorenaming
  72434. */
  72435. let Epsilon: number;
  72436. }
  72437. declare module BABYLON {
  72438. /**
  72439. * Class used to represent a viewport on screen
  72440. */
  72441. export class Viewport {
  72442. /** viewport left coordinate */
  72443. x: number;
  72444. /** viewport top coordinate */
  72445. y: number;
  72446. /**viewport width */
  72447. width: number;
  72448. /** viewport height */
  72449. height: number;
  72450. /**
  72451. * Creates a Viewport object located at (x, y) and sized (width, height)
  72452. * @param x defines viewport left coordinate
  72453. * @param y defines viewport top coordinate
  72454. * @param width defines the viewport width
  72455. * @param height defines the viewport height
  72456. */
  72457. constructor(
  72458. /** viewport left coordinate */
  72459. x: number,
  72460. /** viewport top coordinate */
  72461. y: number,
  72462. /**viewport width */
  72463. width: number,
  72464. /** viewport height */
  72465. height: number);
  72466. /**
  72467. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72468. * @param renderWidth defines the rendering width
  72469. * @param renderHeight defines the rendering height
  72470. * @returns a new Viewport
  72471. */
  72472. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  72473. /**
  72474. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72475. * @param renderWidth defines the rendering width
  72476. * @param renderHeight defines the rendering height
  72477. * @param ref defines the target viewport
  72478. * @returns the current viewport
  72479. */
  72480. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  72481. /**
  72482. * Returns a new Viewport copied from the current one
  72483. * @returns a new Viewport
  72484. */
  72485. clone(): Viewport;
  72486. }
  72487. }
  72488. declare module BABYLON {
  72489. /**
  72490. * Class containing a set of static utilities functions for arrays.
  72491. */
  72492. export class ArrayTools {
  72493. /**
  72494. * Returns an array of the given size filled with element built from the given constructor and the paramters
  72495. * @param size the number of element to construct and put in the array
  72496. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  72497. * @returns a new array filled with new objects
  72498. */
  72499. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  72500. }
  72501. }
  72502. declare module BABYLON {
  72503. /**
  72504. * Class representing a vector containing 2 coordinates
  72505. */
  72506. export class Vector2 {
  72507. /** defines the first coordinate */
  72508. x: number;
  72509. /** defines the second coordinate */
  72510. y: number;
  72511. /**
  72512. * Creates a new Vector2 from the given x and y coordinates
  72513. * @param x defines the first coordinate
  72514. * @param y defines the second coordinate
  72515. */
  72516. constructor(
  72517. /** defines the first coordinate */
  72518. x?: number,
  72519. /** defines the second coordinate */
  72520. y?: number);
  72521. /**
  72522. * Gets a string with the Vector2 coordinates
  72523. * @returns a string with the Vector2 coordinates
  72524. */
  72525. toString(): string;
  72526. /**
  72527. * Gets class name
  72528. * @returns the string "Vector2"
  72529. */
  72530. getClassName(): string;
  72531. /**
  72532. * Gets current vector hash code
  72533. * @returns the Vector2 hash code as a number
  72534. */
  72535. getHashCode(): number;
  72536. /**
  72537. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  72538. * @param array defines the source array
  72539. * @param index defines the offset in source array
  72540. * @returns the current Vector2
  72541. */
  72542. toArray(array: FloatArray, index?: number): Vector2;
  72543. /**
  72544. * Copy the current vector to an array
  72545. * @returns a new array with 2 elements: the Vector2 coordinates.
  72546. */
  72547. asArray(): number[];
  72548. /**
  72549. * Sets the Vector2 coordinates with the given Vector2 coordinates
  72550. * @param source defines the source Vector2
  72551. * @returns the current updated Vector2
  72552. */
  72553. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  72554. /**
  72555. * Sets the Vector2 coordinates with the given floats
  72556. * @param x defines the first coordinate
  72557. * @param y defines the second coordinate
  72558. * @returns the current updated Vector2
  72559. */
  72560. copyFromFloats(x: number, y: number): Vector2;
  72561. /**
  72562. * Sets the Vector2 coordinates with the given floats
  72563. * @param x defines the first coordinate
  72564. * @param y defines the second coordinate
  72565. * @returns the current updated Vector2
  72566. */
  72567. set(x: number, y: number): Vector2;
  72568. /**
  72569. * Add another vector with the current one
  72570. * @param otherVector defines the other vector
  72571. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72572. */
  72573. add(otherVector: DeepImmutable<Vector2>): Vector2;
  72574. /**
  72575. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72576. * @param otherVector defines the other vector
  72577. * @param result defines the target vector
  72578. * @returns the unmodified current Vector2
  72579. */
  72580. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72581. /**
  72582. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72583. * @param otherVector defines the other vector
  72584. * @returns the current updated Vector2
  72585. */
  72586. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72587. /**
  72588. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72589. * @param otherVector defines the other vector
  72590. * @returns a new Vector2
  72591. */
  72592. addVector3(otherVector: Vector3): Vector2;
  72593. /**
  72594. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72595. * @param otherVector defines the other vector
  72596. * @returns a new Vector2
  72597. */
  72598. subtract(otherVector: Vector2): Vector2;
  72599. /**
  72600. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72601. * @param otherVector defines the other vector
  72602. * @param result defines the target vector
  72603. * @returns the unmodified current Vector2
  72604. */
  72605. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72606. /**
  72607. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72608. * @param otherVector defines the other vector
  72609. * @returns the current updated Vector2
  72610. */
  72611. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72612. /**
  72613. * Multiplies in place the current Vector2 coordinates by the given ones
  72614. * @param otherVector defines the other vector
  72615. * @returns the current updated Vector2
  72616. */
  72617. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72618. /**
  72619. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72620. * @param otherVector defines the other vector
  72621. * @returns a new Vector2
  72622. */
  72623. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  72624. /**
  72625. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72626. * @param otherVector defines the other vector
  72627. * @param result defines the target vector
  72628. * @returns the unmodified current Vector2
  72629. */
  72630. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72631. /**
  72632. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72633. * @param x defines the first coordinate
  72634. * @param y defines the second coordinate
  72635. * @returns a new Vector2
  72636. */
  72637. multiplyByFloats(x: number, y: number): Vector2;
  72638. /**
  72639. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72640. * @param otherVector defines the other vector
  72641. * @returns a new Vector2
  72642. */
  72643. divide(otherVector: Vector2): Vector2;
  72644. /**
  72645. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72646. * @param otherVector defines the other vector
  72647. * @param result defines the target vector
  72648. * @returns the unmodified current Vector2
  72649. */
  72650. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72651. /**
  72652. * Divides the current Vector2 coordinates by the given ones
  72653. * @param otherVector defines the other vector
  72654. * @returns the current updated Vector2
  72655. */
  72656. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72657. /**
  72658. * Gets a new Vector2 with current Vector2 negated coordinates
  72659. * @returns a new Vector2
  72660. */
  72661. negate(): Vector2;
  72662. /**
  72663. * Multiply the Vector2 coordinates by scale
  72664. * @param scale defines the scaling factor
  72665. * @returns the current updated Vector2
  72666. */
  72667. scaleInPlace(scale: number): Vector2;
  72668. /**
  72669. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72670. * @param scale defines the scaling factor
  72671. * @returns a new Vector2
  72672. */
  72673. scale(scale: number): Vector2;
  72674. /**
  72675. * Scale the current Vector2 values by a factor to a given Vector2
  72676. * @param scale defines the scale factor
  72677. * @param result defines the Vector2 object where to store the result
  72678. * @returns the unmodified current Vector2
  72679. */
  72680. scaleToRef(scale: number, result: Vector2): Vector2;
  72681. /**
  72682. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72683. * @param scale defines the scale factor
  72684. * @param result defines the Vector2 object where to store the result
  72685. * @returns the unmodified current Vector2
  72686. */
  72687. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  72688. /**
  72689. * Gets a boolean if two vectors are equals
  72690. * @param otherVector defines the other vector
  72691. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72692. */
  72693. equals(otherVector: DeepImmutable<Vector2>): boolean;
  72694. /**
  72695. * Gets a boolean if two vectors are equals (using an epsilon value)
  72696. * @param otherVector defines the other vector
  72697. * @param epsilon defines the minimal distance to consider equality
  72698. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72699. */
  72700. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  72701. /**
  72702. * Gets a new Vector2 from current Vector2 floored values
  72703. * @returns a new Vector2
  72704. */
  72705. floor(): Vector2;
  72706. /**
  72707. * Gets a new Vector2 from current Vector2 floored values
  72708. * @returns a new Vector2
  72709. */
  72710. fract(): Vector2;
  72711. /**
  72712. * Gets the length of the vector
  72713. * @returns the vector length (float)
  72714. */
  72715. length(): number;
  72716. /**
  72717. * Gets the vector squared length
  72718. * @returns the vector squared length (float)
  72719. */
  72720. lengthSquared(): number;
  72721. /**
  72722. * Normalize the vector
  72723. * @returns the current updated Vector2
  72724. */
  72725. normalize(): Vector2;
  72726. /**
  72727. * Gets a new Vector2 copied from the Vector2
  72728. * @returns a new Vector2
  72729. */
  72730. clone(): Vector2;
  72731. /**
  72732. * Gets a new Vector2(0, 0)
  72733. * @returns a new Vector2
  72734. */
  72735. static Zero(): Vector2;
  72736. /**
  72737. * Gets a new Vector2(1, 1)
  72738. * @returns a new Vector2
  72739. */
  72740. static One(): Vector2;
  72741. /**
  72742. * Gets a new Vector2 set from the given index element of the given array
  72743. * @param array defines the data source
  72744. * @param offset defines the offset in the data source
  72745. * @returns a new Vector2
  72746. */
  72747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  72748. /**
  72749. * Sets "result" from the given index element of the given array
  72750. * @param array defines the data source
  72751. * @param offset defines the offset in the data source
  72752. * @param result defines the target vector
  72753. */
  72754. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  72755. /**
  72756. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72757. * @param value1 defines 1st point of control
  72758. * @param value2 defines 2nd point of control
  72759. * @param value3 defines 3rd point of control
  72760. * @param value4 defines 4th point of control
  72761. * @param amount defines the interpolation factor
  72762. * @returns a new Vector2
  72763. */
  72764. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  72765. /**
  72766. * 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".
  72767. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72768. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72769. * @param value defines the value to clamp
  72770. * @param min defines the lower limit
  72771. * @param max defines the upper limit
  72772. * @returns a new Vector2
  72773. */
  72774. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  72775. /**
  72776. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72777. * @param value1 defines the 1st control point
  72778. * @param tangent1 defines the outgoing tangent
  72779. * @param value2 defines the 2nd control point
  72780. * @param tangent2 defines the incoming tangent
  72781. * @param amount defines the interpolation factor
  72782. * @returns a new Vector2
  72783. */
  72784. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  72785. /**
  72786. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72787. * @param start defines the start vector
  72788. * @param end defines the end vector
  72789. * @param amount defines the interpolation factor
  72790. * @returns a new Vector2
  72791. */
  72792. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  72793. /**
  72794. * Gets the dot product of the vector "left" and the vector "right"
  72795. * @param left defines first vector
  72796. * @param right defines second vector
  72797. * @returns the dot product (float)
  72798. */
  72799. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  72800. /**
  72801. * Returns a new Vector2 equal to the normalized given vector
  72802. * @param vector defines the vector to normalize
  72803. * @returns a new Vector2
  72804. */
  72805. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  72806. /**
  72807. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72808. * @param left defines 1st vector
  72809. * @param right defines 2nd vector
  72810. * @returns a new Vector2
  72811. */
  72812. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72813. /**
  72814. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72815. * @param left defines 1st vector
  72816. * @param right defines 2nd vector
  72817. * @returns a new Vector2
  72818. */
  72819. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72820. /**
  72821. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72822. * @param vector defines the vector to transform
  72823. * @param transformation defines the matrix to apply
  72824. * @returns a new Vector2
  72825. */
  72826. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  72827. /**
  72828. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72829. * @param vector defines the vector to transform
  72830. * @param transformation defines the matrix to apply
  72831. * @param result defines the target vector
  72832. */
  72833. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  72834. /**
  72835. * Determines if a given vector is included in a triangle
  72836. * @param p defines the vector to test
  72837. * @param p0 defines 1st triangle point
  72838. * @param p1 defines 2nd triangle point
  72839. * @param p2 defines 3rd triangle point
  72840. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72841. */
  72842. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  72843. /**
  72844. * Gets the distance between the vectors "value1" and "value2"
  72845. * @param value1 defines first vector
  72846. * @param value2 defines second vector
  72847. * @returns the distance between vectors
  72848. */
  72849. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72850. /**
  72851. * Returns the squared distance between the vectors "value1" and "value2"
  72852. * @param value1 defines first vector
  72853. * @param value2 defines second vector
  72854. * @returns the squared distance between vectors
  72855. */
  72856. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72857. /**
  72858. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72859. * @param value1 defines first vector
  72860. * @param value2 defines second vector
  72861. * @returns a new Vector2
  72862. */
  72863. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  72864. /**
  72865. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72866. * @param p defines the middle point
  72867. * @param segA defines one point of the segment
  72868. * @param segB defines the other point of the segment
  72869. * @returns the shortest distance
  72870. */
  72871. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  72872. }
  72873. /**
  72874. * Class used to store (x,y,z) vector representation
  72875. * A Vector3 is the main object used in 3D geometry
  72876. * It can represent etiher the coordinates of a point the space, either a direction
  72877. * Reminder: js uses a left handed forward facing system
  72878. */
  72879. export class Vector3 {
  72880. /**
  72881. * Defines the first coordinates (on X axis)
  72882. */
  72883. x: number;
  72884. /**
  72885. * Defines the second coordinates (on Y axis)
  72886. */
  72887. y: number;
  72888. /**
  72889. * Defines the third coordinates (on Z axis)
  72890. */
  72891. z: number;
  72892. private static _UpReadOnly;
  72893. private static _ZeroReadOnly;
  72894. /**
  72895. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72896. * @param x defines the first coordinates (on X axis)
  72897. * @param y defines the second coordinates (on Y axis)
  72898. * @param z defines the third coordinates (on Z axis)
  72899. */
  72900. constructor(
  72901. /**
  72902. * Defines the first coordinates (on X axis)
  72903. */
  72904. x?: number,
  72905. /**
  72906. * Defines the second coordinates (on Y axis)
  72907. */
  72908. y?: number,
  72909. /**
  72910. * Defines the third coordinates (on Z axis)
  72911. */
  72912. z?: number);
  72913. /**
  72914. * Creates a string representation of the Vector3
  72915. * @returns a string with the Vector3 coordinates.
  72916. */
  72917. toString(): string;
  72918. /**
  72919. * Gets the class name
  72920. * @returns the string "Vector3"
  72921. */
  72922. getClassName(): string;
  72923. /**
  72924. * Creates the Vector3 hash code
  72925. * @returns a number which tends to be unique between Vector3 instances
  72926. */
  72927. getHashCode(): number;
  72928. /**
  72929. * Creates an array containing three elements : the coordinates of the Vector3
  72930. * @returns a new array of numbers
  72931. */
  72932. asArray(): number[];
  72933. /**
  72934. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  72935. * @param array defines the destination array
  72936. * @param index defines the offset in the destination array
  72937. * @returns the current Vector3
  72938. */
  72939. toArray(array: FloatArray, index?: number): Vector3;
  72940. /**
  72941. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  72942. * @returns a new Quaternion object, computed from the Vector3 coordinates
  72943. */
  72944. toQuaternion(): Quaternion;
  72945. /**
  72946. * Adds the given vector to the current Vector3
  72947. * @param otherVector defines the second operand
  72948. * @returns the current updated Vector3
  72949. */
  72950. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72951. /**
  72952. * Adds the given coordinates to the current Vector3
  72953. * @param x defines the x coordinate of the operand
  72954. * @param y defines the y coordinate of the operand
  72955. * @param z defines the z coordinate of the operand
  72956. * @returns the current updated Vector3
  72957. */
  72958. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  72959. /**
  72960. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  72961. * @param otherVector defines the second operand
  72962. * @returns the resulting Vector3
  72963. */
  72964. add(otherVector: DeepImmutable<Vector3>): Vector3;
  72965. /**
  72966. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  72967. * @param otherVector defines the second operand
  72968. * @param result defines the Vector3 object where to store the result
  72969. * @returns the current Vector3
  72970. */
  72971. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72972. /**
  72973. * Subtract the given vector from the current Vector3
  72974. * @param otherVector defines the second operand
  72975. * @returns the current updated Vector3
  72976. */
  72977. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72978. /**
  72979. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  72980. * @param otherVector defines the second operand
  72981. * @returns the resulting Vector3
  72982. */
  72983. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  72984. /**
  72985. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  72986. * @param otherVector defines the second operand
  72987. * @param result defines the Vector3 object where to store the result
  72988. * @returns the current Vector3
  72989. */
  72990. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72991. /**
  72992. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  72993. * @param x defines the x coordinate of the operand
  72994. * @param y defines the y coordinate of the operand
  72995. * @param z defines the z coordinate of the operand
  72996. * @returns the resulting Vector3
  72997. */
  72998. subtractFromFloats(x: number, y: number, z: number): Vector3;
  72999. /**
  73000. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  73001. * @param x defines the x coordinate of the operand
  73002. * @param y defines the y coordinate of the operand
  73003. * @param z defines the z coordinate of the operand
  73004. * @param result defines the Vector3 object where to store the result
  73005. * @returns the current Vector3
  73006. */
  73007. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  73008. /**
  73009. * Gets a new Vector3 set with the current Vector3 negated coordinates
  73010. * @returns a new Vector3
  73011. */
  73012. negate(): Vector3;
  73013. /**
  73014. * Multiplies the Vector3 coordinates by the float "scale"
  73015. * @param scale defines the multiplier factor
  73016. * @returns the current updated Vector3
  73017. */
  73018. scaleInPlace(scale: number): Vector3;
  73019. /**
  73020. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  73021. * @param scale defines the multiplier factor
  73022. * @returns a new Vector3
  73023. */
  73024. scale(scale: number): Vector3;
  73025. /**
  73026. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73027. * @param scale defines the multiplier factor
  73028. * @param result defines the Vector3 object where to store the result
  73029. * @returns the current Vector3
  73030. */
  73031. scaleToRef(scale: number, result: Vector3): Vector3;
  73032. /**
  73033. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73034. * @param scale defines the scale factor
  73035. * @param result defines the Vector3 object where to store the result
  73036. * @returns the unmodified current Vector3
  73037. */
  73038. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73039. /**
  73040. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73041. * @param otherVector defines the second operand
  73042. * @returns true if both vectors are equals
  73043. */
  73044. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73045. /**
  73046. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73047. * @param otherVector defines the second operand
  73048. * @param epsilon defines the minimal distance to define values as equals
  73049. * @returns true if both vectors are distant less than epsilon
  73050. */
  73051. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73052. /**
  73053. * Returns true if the current Vector3 coordinates equals the given floats
  73054. * @param x defines the x coordinate of the operand
  73055. * @param y defines the y coordinate of the operand
  73056. * @param z defines the z coordinate of the operand
  73057. * @returns true if both vectors are equals
  73058. */
  73059. equalsToFloats(x: number, y: number, z: number): boolean;
  73060. /**
  73061. * Multiplies the current Vector3 coordinates by the given ones
  73062. * @param otherVector defines the second operand
  73063. * @returns the current updated Vector3
  73064. */
  73065. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73066. /**
  73067. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73068. * @param otherVector defines the second operand
  73069. * @returns the new Vector3
  73070. */
  73071. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73072. /**
  73073. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73074. * @param otherVector defines the second operand
  73075. * @param result defines the Vector3 object where to store the result
  73076. * @returns the current Vector3
  73077. */
  73078. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73079. /**
  73080. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73081. * @param x defines the x coordinate of the operand
  73082. * @param y defines the y coordinate of the operand
  73083. * @param z defines the z coordinate of the operand
  73084. * @returns the new Vector3
  73085. */
  73086. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73087. /**
  73088. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73089. * @param otherVector defines the second operand
  73090. * @returns the new Vector3
  73091. */
  73092. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73093. /**
  73094. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73095. * @param otherVector defines the second operand
  73096. * @param result defines the Vector3 object where to store the result
  73097. * @returns the current Vector3
  73098. */
  73099. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73100. /**
  73101. * Divides the current Vector3 coordinates by the given ones.
  73102. * @param otherVector defines the second operand
  73103. * @returns the current updated Vector3
  73104. */
  73105. divideInPlace(otherVector: Vector3): Vector3;
  73106. /**
  73107. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73108. * @param other defines the second operand
  73109. * @returns the current updated Vector3
  73110. */
  73111. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73112. /**
  73113. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73114. * @param other defines the second operand
  73115. * @returns the current updated Vector3
  73116. */
  73117. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73118. /**
  73119. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73120. * @param x defines the x coordinate of the operand
  73121. * @param y defines the y coordinate of the operand
  73122. * @param z defines the z coordinate of the operand
  73123. * @returns the current updated Vector3
  73124. */
  73125. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73126. /**
  73127. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73128. * @param x defines the x coordinate of the operand
  73129. * @param y defines the y coordinate of the operand
  73130. * @param z defines the z coordinate of the operand
  73131. * @returns the current updated Vector3
  73132. */
  73133. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73134. /**
  73135. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73136. * Check if is non uniform within a certain amount of decimal places to account for this
  73137. * @param epsilon the amount the values can differ
  73138. * @returns if the the vector is non uniform to a certain number of decimal places
  73139. */
  73140. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73141. /**
  73142. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73143. */
  73144. get isNonUniform(): boolean;
  73145. /**
  73146. * Gets a new Vector3 from current Vector3 floored values
  73147. * @returns a new Vector3
  73148. */
  73149. floor(): Vector3;
  73150. /**
  73151. * Gets a new Vector3 from current Vector3 floored values
  73152. * @returns a new Vector3
  73153. */
  73154. fract(): Vector3;
  73155. /**
  73156. * Gets the length of the Vector3
  73157. * @returns the length of the Vector3
  73158. */
  73159. length(): number;
  73160. /**
  73161. * Gets the squared length of the Vector3
  73162. * @returns squared length of the Vector3
  73163. */
  73164. lengthSquared(): number;
  73165. /**
  73166. * Normalize the current Vector3.
  73167. * Please note that this is an in place operation.
  73168. * @returns the current updated Vector3
  73169. */
  73170. normalize(): Vector3;
  73171. /**
  73172. * Reorders the x y z properties of the vector in place
  73173. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73174. * @returns the current updated vector
  73175. */
  73176. reorderInPlace(order: string): this;
  73177. /**
  73178. * Rotates the vector around 0,0,0 by a quaternion
  73179. * @param quaternion the rotation quaternion
  73180. * @param result vector to store the result
  73181. * @returns the resulting vector
  73182. */
  73183. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  73184. /**
  73185. * Rotates a vector around a given point
  73186. * @param quaternion the rotation quaternion
  73187. * @param point the point to rotate around
  73188. * @param result vector to store the result
  73189. * @returns the resulting vector
  73190. */
  73191. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  73192. /**
  73193. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  73194. * The cross product is then orthogonal to both current and "other"
  73195. * @param other defines the right operand
  73196. * @returns the cross product
  73197. */
  73198. cross(other: Vector3): Vector3;
  73199. /**
  73200. * Normalize the current Vector3 with the given input length.
  73201. * Please note that this is an in place operation.
  73202. * @param len the length of the vector
  73203. * @returns the current updated Vector3
  73204. */
  73205. normalizeFromLength(len: number): Vector3;
  73206. /**
  73207. * Normalize the current Vector3 to a new vector
  73208. * @returns the new Vector3
  73209. */
  73210. normalizeToNew(): Vector3;
  73211. /**
  73212. * Normalize the current Vector3 to the reference
  73213. * @param reference define the Vector3 to update
  73214. * @returns the updated Vector3
  73215. */
  73216. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  73217. /**
  73218. * Creates a new Vector3 copied from the current Vector3
  73219. * @returns the new Vector3
  73220. */
  73221. clone(): Vector3;
  73222. /**
  73223. * Copies the given vector coordinates to the current Vector3 ones
  73224. * @param source defines the source Vector3
  73225. * @returns the current updated Vector3
  73226. */
  73227. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  73228. /**
  73229. * Copies the given floats to the current Vector3 coordinates
  73230. * @param x defines the x coordinate of the operand
  73231. * @param y defines the y coordinate of the operand
  73232. * @param z defines the z coordinate of the operand
  73233. * @returns the current updated Vector3
  73234. */
  73235. copyFromFloats(x: number, y: number, z: number): Vector3;
  73236. /**
  73237. * Copies the given floats to the current Vector3 coordinates
  73238. * @param x defines the x coordinate of the operand
  73239. * @param y defines the y coordinate of the operand
  73240. * @param z defines the z coordinate of the operand
  73241. * @returns the current updated Vector3
  73242. */
  73243. set(x: number, y: number, z: number): Vector3;
  73244. /**
  73245. * Copies the given float to the current Vector3 coordinates
  73246. * @param v defines the x, y and z coordinates of the operand
  73247. * @returns the current updated Vector3
  73248. */
  73249. setAll(v: number): Vector3;
  73250. /**
  73251. * Get the clip factor between two vectors
  73252. * @param vector0 defines the first operand
  73253. * @param vector1 defines the second operand
  73254. * @param axis defines the axis to use
  73255. * @param size defines the size along the axis
  73256. * @returns the clip factor
  73257. */
  73258. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  73259. /**
  73260. * Get angle between two vectors
  73261. * @param vector0 angle between vector0 and vector1
  73262. * @param vector1 angle between vector0 and vector1
  73263. * @param normal direction of the normal
  73264. * @return the angle between vector0 and vector1
  73265. */
  73266. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  73267. /**
  73268. * Returns a new Vector3 set from the index "offset" of the given array
  73269. * @param array defines the source array
  73270. * @param offset defines the offset in the source array
  73271. * @returns the new Vector3
  73272. */
  73273. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  73274. /**
  73275. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73276. * @param array defines the source array
  73277. * @param offset defines the offset in the source array
  73278. * @returns the new Vector3
  73279. * @deprecated Please use FromArray instead.
  73280. */
  73281. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  73282. /**
  73283. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73284. * @param array defines the source array
  73285. * @param offset defines the offset in the source array
  73286. * @param result defines the Vector3 where to store the result
  73287. */
  73288. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  73289. /**
  73290. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73291. * @param array defines the source array
  73292. * @param offset defines the offset in the source array
  73293. * @param result defines the Vector3 where to store the result
  73294. * @deprecated Please use FromArrayToRef instead.
  73295. */
  73296. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  73297. /**
  73298. * Sets the given vector "result" with the given floats.
  73299. * @param x defines the x coordinate of the source
  73300. * @param y defines the y coordinate of the source
  73301. * @param z defines the z coordinate of the source
  73302. * @param result defines the Vector3 where to store the result
  73303. */
  73304. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  73305. /**
  73306. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73307. * @returns a new empty Vector3
  73308. */
  73309. static Zero(): Vector3;
  73310. /**
  73311. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73312. * @returns a new unit Vector3
  73313. */
  73314. static One(): Vector3;
  73315. /**
  73316. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73317. * @returns a new up Vector3
  73318. */
  73319. static Up(): Vector3;
  73320. /**
  73321. * Gets a up Vector3 that must not be updated
  73322. */
  73323. static get UpReadOnly(): DeepImmutable<Vector3>;
  73324. /**
  73325. * Gets a zero Vector3 that must not be updated
  73326. */
  73327. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  73328. /**
  73329. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73330. * @returns a new down Vector3
  73331. */
  73332. static Down(): Vector3;
  73333. /**
  73334. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73335. * @returns a new forward Vector3
  73336. */
  73337. static Forward(): Vector3;
  73338. /**
  73339. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73340. * @returns a new forward Vector3
  73341. */
  73342. static Backward(): Vector3;
  73343. /**
  73344. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73345. * @returns a new right Vector3
  73346. */
  73347. static Right(): Vector3;
  73348. /**
  73349. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73350. * @returns a new left Vector3
  73351. */
  73352. static Left(): Vector3;
  73353. /**
  73354. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73355. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73356. * @param vector defines the Vector3 to transform
  73357. * @param transformation defines the transformation matrix
  73358. * @returns the transformed Vector3
  73359. */
  73360. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73361. /**
  73362. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73363. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73364. * @param vector defines the Vector3 to transform
  73365. * @param transformation defines the transformation matrix
  73366. * @param result defines the Vector3 where to store the result
  73367. */
  73368. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73369. /**
  73370. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73371. * This method computes tranformed coordinates only, not transformed direction vectors
  73372. * @param x define the x coordinate of the source vector
  73373. * @param y define the y coordinate of the source vector
  73374. * @param z define the z coordinate of the source vector
  73375. * @param transformation defines the transformation matrix
  73376. * @param result defines the Vector3 where to store the result
  73377. */
  73378. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73379. /**
  73380. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73381. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73382. * @param vector defines the Vector3 to transform
  73383. * @param transformation defines the transformation matrix
  73384. * @returns the new Vector3
  73385. */
  73386. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73387. /**
  73388. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73389. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73390. * @param vector defines the Vector3 to transform
  73391. * @param transformation defines the transformation matrix
  73392. * @param result defines the Vector3 where to store the result
  73393. */
  73394. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73395. /**
  73396. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73397. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73398. * @param x define the x coordinate of the source vector
  73399. * @param y define the y coordinate of the source vector
  73400. * @param z define the z coordinate of the source vector
  73401. * @param transformation defines the transformation matrix
  73402. * @param result defines the Vector3 where to store the result
  73403. */
  73404. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73405. /**
  73406. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73407. * @param value1 defines the first control point
  73408. * @param value2 defines the second control point
  73409. * @param value3 defines the third control point
  73410. * @param value4 defines the fourth control point
  73411. * @param amount defines the amount on the spline to use
  73412. * @returns the new Vector3
  73413. */
  73414. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  73415. /**
  73416. * 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"
  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. * @returns the new Vector3
  73423. */
  73424. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  73425. /**
  73426. * 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"
  73427. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73428. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73429. * @param value defines the current value
  73430. * @param min defines the lower range value
  73431. * @param max defines the upper range value
  73432. * @param result defines the Vector3 where to store the result
  73433. */
  73434. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  73435. /**
  73436. * Checks if a given vector is inside a specific range
  73437. * @param v defines the vector to test
  73438. * @param min defines the minimum range
  73439. * @param max defines the maximum range
  73440. */
  73441. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  73442. /**
  73443. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73444. * @param value1 defines the first control point
  73445. * @param tangent1 defines the first tangent vector
  73446. * @param value2 defines the second control point
  73447. * @param tangent2 defines the second tangent vector
  73448. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73449. * @returns the new Vector3
  73450. */
  73451. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  73452. /**
  73453. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73454. * @param start defines the start value
  73455. * @param end defines the end value
  73456. * @param amount max defines amount between both (between 0 and 1)
  73457. * @returns the new Vector3
  73458. */
  73459. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  73460. /**
  73461. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73462. * @param start defines the start value
  73463. * @param end defines the end value
  73464. * @param amount max defines amount between both (between 0 and 1)
  73465. * @param result defines the Vector3 where to store the result
  73466. */
  73467. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  73468. /**
  73469. * Returns the dot product (float) between the vectors "left" and "right"
  73470. * @param left defines the left operand
  73471. * @param right defines the right operand
  73472. * @returns the dot product
  73473. */
  73474. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  73475. /**
  73476. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73477. * The cross product is then orthogonal to both "left" and "right"
  73478. * @param left defines the left operand
  73479. * @param right defines the right operand
  73480. * @returns the cross product
  73481. */
  73482. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73483. /**
  73484. * Sets the given vector "result" with the cross product of "left" and "right"
  73485. * The cross product is then orthogonal to both "left" and "right"
  73486. * @param left defines the left operand
  73487. * @param right defines the right operand
  73488. * @param result defines the Vector3 where to store the result
  73489. */
  73490. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  73491. /**
  73492. * Returns a new Vector3 as the normalization of the given vector
  73493. * @param vector defines the Vector3 to normalize
  73494. * @returns the new Vector3
  73495. */
  73496. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  73497. /**
  73498. * Sets the given vector "result" with the normalization of the given first vector
  73499. * @param vector defines the Vector3 to normalize
  73500. * @param result defines the Vector3 where to store the result
  73501. */
  73502. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  73503. /**
  73504. * Project a Vector3 onto screen space
  73505. * @param vector defines the Vector3 to project
  73506. * @param world defines the world matrix to use
  73507. * @param transform defines the transform (view x projection) matrix to use
  73508. * @param viewport defines the screen viewport to use
  73509. * @returns the new Vector3
  73510. */
  73511. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  73512. /** @hidden */
  73513. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  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 transform defines the transform (view x projection) matrix to use
  73521. * @returns the new Vector3
  73522. */
  73523. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  73524. /**
  73525. * Unproject from screen space to object space
  73526. * @param source defines the screen space Vector3 to use
  73527. * @param viewportWidth defines the current width of the viewport
  73528. * @param viewportHeight defines the current height of the viewport
  73529. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73530. * @param view defines the view matrix to use
  73531. * @param projection defines the projection matrix to use
  73532. * @returns the new Vector3
  73533. */
  73534. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  73535. /**
  73536. * Unproject from screen space to object space
  73537. * @param source defines the screen space Vector3 to use
  73538. * @param viewportWidth defines the current width of the viewport
  73539. * @param viewportHeight defines the current height of the viewport
  73540. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73541. * @param view defines the view matrix to use
  73542. * @param projection defines the projection matrix to use
  73543. * @param result defines the Vector3 where to store the result
  73544. */
  73545. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73546. /**
  73547. * Unproject from screen space to object space
  73548. * @param sourceX defines the screen space x coordinate to use
  73549. * @param sourceY defines the screen space y coordinate to use
  73550. * @param sourceZ defines the screen space z coordinate to use
  73551. * @param viewportWidth defines the current width of the viewport
  73552. * @param viewportHeight defines the current height of the viewport
  73553. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73554. * @param view defines the view matrix to use
  73555. * @param projection defines the projection matrix to use
  73556. * @param result defines the Vector3 where to store the result
  73557. */
  73558. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73559. /**
  73560. * Gets the minimal coordinate values between two Vector3
  73561. * @param left defines the first operand
  73562. * @param right defines the second operand
  73563. * @returns the new Vector3
  73564. */
  73565. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73566. /**
  73567. * Gets the maximal coordinate values between two Vector3
  73568. * @param left defines the first operand
  73569. * @param right defines the second operand
  73570. * @returns the new Vector3
  73571. */
  73572. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73573. /**
  73574. * Returns the distance between the vectors "value1" and "value2"
  73575. * @param value1 defines the first operand
  73576. * @param value2 defines the second operand
  73577. * @returns the distance
  73578. */
  73579. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73580. /**
  73581. * Returns the squared distance between the vectors "value1" and "value2"
  73582. * @param value1 defines the first operand
  73583. * @param value2 defines the second operand
  73584. * @returns the squared distance
  73585. */
  73586. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73587. /**
  73588. * Returns a new Vector3 located at the center between "value1" and "value2"
  73589. * @param value1 defines the first operand
  73590. * @param value2 defines the second operand
  73591. * @returns the new Vector3
  73592. */
  73593. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  73594. /**
  73595. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73596. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73597. * to something in order to rotate it from its local system to the given target system
  73598. * Note: axis1, axis2 and axis3 are normalized during this operation
  73599. * @param axis1 defines the first axis
  73600. * @param axis2 defines the second axis
  73601. * @param axis3 defines the third axis
  73602. * @returns a new Vector3
  73603. */
  73604. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  73605. /**
  73606. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73607. * @param axis1 defines the first axis
  73608. * @param axis2 defines the second axis
  73609. * @param axis3 defines the third axis
  73610. * @param ref defines the Vector3 where to store the result
  73611. */
  73612. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  73613. }
  73614. /**
  73615. * Vector4 class created for EulerAngle class conversion to Quaternion
  73616. */
  73617. export class Vector4 {
  73618. /** x value of the vector */
  73619. x: number;
  73620. /** y value of the vector */
  73621. y: number;
  73622. /** z value of the vector */
  73623. z: number;
  73624. /** w value of the vector */
  73625. w: number;
  73626. /**
  73627. * Creates a Vector4 object from the given floats.
  73628. * @param x x value of the vector
  73629. * @param y y value of the vector
  73630. * @param z z value of the vector
  73631. * @param w w value of the vector
  73632. */
  73633. constructor(
  73634. /** x value of the vector */
  73635. x: number,
  73636. /** y value of the vector */
  73637. y: number,
  73638. /** z value of the vector */
  73639. z: number,
  73640. /** w value of the vector */
  73641. w: number);
  73642. /**
  73643. * Returns the string with the Vector4 coordinates.
  73644. * @returns a string containing all the vector values
  73645. */
  73646. toString(): string;
  73647. /**
  73648. * Returns the string "Vector4".
  73649. * @returns "Vector4"
  73650. */
  73651. getClassName(): string;
  73652. /**
  73653. * Returns the Vector4 hash code.
  73654. * @returns a unique hash code
  73655. */
  73656. getHashCode(): number;
  73657. /**
  73658. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73659. * @returns the resulting array
  73660. */
  73661. asArray(): number[];
  73662. /**
  73663. * Populates the given array from the given index with the Vector4 coordinates.
  73664. * @param array array to populate
  73665. * @param index index of the array to start at (default: 0)
  73666. * @returns the Vector4.
  73667. */
  73668. toArray(array: FloatArray, index?: number): Vector4;
  73669. /**
  73670. * Adds the given vector to the current Vector4.
  73671. * @param otherVector the vector to add
  73672. * @returns the updated Vector4.
  73673. */
  73674. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73675. /**
  73676. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73677. * @param otherVector the vector to add
  73678. * @returns the resulting vector
  73679. */
  73680. add(otherVector: DeepImmutable<Vector4>): Vector4;
  73681. /**
  73682. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73683. * @param otherVector the vector to add
  73684. * @param result the vector to store the result
  73685. * @returns the current Vector4.
  73686. */
  73687. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73688. /**
  73689. * Subtract in place the given vector from the current Vector4.
  73690. * @param otherVector the vector to subtract
  73691. * @returns the updated Vector4.
  73692. */
  73693. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73694. /**
  73695. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73696. * @param otherVector the vector to add
  73697. * @returns the new vector with the result
  73698. */
  73699. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  73700. /**
  73701. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73702. * @param otherVector the vector to subtract
  73703. * @param result the vector to store the result
  73704. * @returns the current Vector4.
  73705. */
  73706. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73707. /**
  73708. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73709. */
  73710. /**
  73711. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73712. * @param x value to subtract
  73713. * @param y value to subtract
  73714. * @param z value to subtract
  73715. * @param w value to subtract
  73716. * @returns new vector containing the result
  73717. */
  73718. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73719. /**
  73720. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73721. * @param x value to subtract
  73722. * @param y value to subtract
  73723. * @param z value to subtract
  73724. * @param w value to subtract
  73725. * @param result the vector to store the result in
  73726. * @returns the current Vector4.
  73727. */
  73728. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  73729. /**
  73730. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73731. * @returns a new vector with the negated values
  73732. */
  73733. negate(): Vector4;
  73734. /**
  73735. * Multiplies the current Vector4 coordinates by scale (float).
  73736. * @param scale the number to scale with
  73737. * @returns the updated Vector4.
  73738. */
  73739. scaleInPlace(scale: number): Vector4;
  73740. /**
  73741. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73742. * @param scale the number to scale with
  73743. * @returns a new vector with the result
  73744. */
  73745. scale(scale: number): Vector4;
  73746. /**
  73747. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73748. * @param scale the number to scale with
  73749. * @param result a vector to store the result in
  73750. * @returns the current Vector4.
  73751. */
  73752. scaleToRef(scale: number, result: Vector4): Vector4;
  73753. /**
  73754. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73755. * @param scale defines the scale factor
  73756. * @param result defines the Vector4 object where to store the result
  73757. * @returns the unmodified current Vector4
  73758. */
  73759. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  73760. /**
  73761. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73762. * @param otherVector the vector to compare against
  73763. * @returns true if they are equal
  73764. */
  73765. equals(otherVector: DeepImmutable<Vector4>): boolean;
  73766. /**
  73767. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73768. * @param otherVector vector to compare against
  73769. * @param epsilon (Default: very small number)
  73770. * @returns true if they are equal
  73771. */
  73772. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  73773. /**
  73774. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73775. * @param x x value to compare against
  73776. * @param y y value to compare against
  73777. * @param z z value to compare against
  73778. * @param w w value to compare against
  73779. * @returns true if equal
  73780. */
  73781. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  73782. /**
  73783. * Multiplies in place the current Vector4 by the given one.
  73784. * @param otherVector vector to multiple with
  73785. * @returns the updated Vector4.
  73786. */
  73787. multiplyInPlace(otherVector: Vector4): Vector4;
  73788. /**
  73789. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73790. * @param otherVector vector to multiple with
  73791. * @returns resulting new vector
  73792. */
  73793. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  73794. /**
  73795. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73796. * @param otherVector vector to multiple with
  73797. * @param result vector to store the result
  73798. * @returns the current Vector4.
  73799. */
  73800. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73801. /**
  73802. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73803. * @param x x value multiply with
  73804. * @param y y value multiply with
  73805. * @param z z value multiply with
  73806. * @param w w value multiply with
  73807. * @returns resulting new vector
  73808. */
  73809. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  73810. /**
  73811. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73812. * @param otherVector vector to devide with
  73813. * @returns resulting new vector
  73814. */
  73815. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  73816. /**
  73817. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73818. * @param otherVector vector to devide with
  73819. * @param result vector to store the result
  73820. * @returns the current Vector4.
  73821. */
  73822. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73823. /**
  73824. * Divides the current Vector3 coordinates by the given ones.
  73825. * @param otherVector vector to devide with
  73826. * @returns the updated Vector3.
  73827. */
  73828. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73829. /**
  73830. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73831. * @param other defines the second operand
  73832. * @returns the current updated Vector4
  73833. */
  73834. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73835. /**
  73836. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73837. * @param other defines the second operand
  73838. * @returns the current updated Vector4
  73839. */
  73840. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73841. /**
  73842. * Gets a new Vector4 from current Vector4 floored values
  73843. * @returns a new Vector4
  73844. */
  73845. floor(): Vector4;
  73846. /**
  73847. * Gets a new Vector4 from current Vector3 floored values
  73848. * @returns a new Vector4
  73849. */
  73850. fract(): Vector4;
  73851. /**
  73852. * Returns the Vector4 length (float).
  73853. * @returns the length
  73854. */
  73855. length(): number;
  73856. /**
  73857. * Returns the Vector4 squared length (float).
  73858. * @returns the length squared
  73859. */
  73860. lengthSquared(): number;
  73861. /**
  73862. * Normalizes in place the Vector4.
  73863. * @returns the updated Vector4.
  73864. */
  73865. normalize(): Vector4;
  73866. /**
  73867. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73868. * @returns this converted to a new vector3
  73869. */
  73870. toVector3(): Vector3;
  73871. /**
  73872. * Returns a new Vector4 copied from the current one.
  73873. * @returns the new cloned vector
  73874. */
  73875. clone(): Vector4;
  73876. /**
  73877. * Updates the current Vector4 with the given one coordinates.
  73878. * @param source the source vector to copy from
  73879. * @returns the updated Vector4.
  73880. */
  73881. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  73882. /**
  73883. * Updates the current Vector4 coordinates with the given floats.
  73884. * @param x float to copy from
  73885. * @param y float to copy from
  73886. * @param z float to copy from
  73887. * @param w float to copy from
  73888. * @returns the updated Vector4.
  73889. */
  73890. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73891. /**
  73892. * Updates the current Vector4 coordinates with the given floats.
  73893. * @param x float to set from
  73894. * @param y float to set from
  73895. * @param z float to set from
  73896. * @param w float to set from
  73897. * @returns the updated Vector4.
  73898. */
  73899. set(x: number, y: number, z: number, w: number): Vector4;
  73900. /**
  73901. * Copies the given float to the current Vector3 coordinates
  73902. * @param v defines the x, y, z and w coordinates of the operand
  73903. * @returns the current updated Vector3
  73904. */
  73905. setAll(v: number): Vector4;
  73906. /**
  73907. * Returns a new Vector4 set from the starting index of the given array.
  73908. * @param array the array to pull values from
  73909. * @param offset the offset into the array to start at
  73910. * @returns the new vector
  73911. */
  73912. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  73913. /**
  73914. * Updates the given vector "result" from the starting index of the given array.
  73915. * @param array the array to pull values from
  73916. * @param offset the offset into the array to start at
  73917. * @param result the vector to store the result in
  73918. */
  73919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  73920. /**
  73921. * Updates the given vector "result" from the starting index of the given Float32Array.
  73922. * @param array the array to pull values from
  73923. * @param offset the offset into the array to start at
  73924. * @param result the vector to store the result in
  73925. */
  73926. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  73927. /**
  73928. * Updates the given vector "result" coordinates from the given floats.
  73929. * @param x float to set from
  73930. * @param y float to set from
  73931. * @param z float to set from
  73932. * @param w float to set from
  73933. * @param result the vector to the floats in
  73934. */
  73935. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  73936. /**
  73937. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  73938. * @returns the new vector
  73939. */
  73940. static Zero(): Vector4;
  73941. /**
  73942. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  73943. * @returns the new vector
  73944. */
  73945. static One(): Vector4;
  73946. /**
  73947. * Returns a new normalized Vector4 from the given one.
  73948. * @param vector the vector to normalize
  73949. * @returns the vector
  73950. */
  73951. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  73952. /**
  73953. * Updates the given vector "result" from the normalization of the given one.
  73954. * @param vector the vector to normalize
  73955. * @param result the vector to store the result in
  73956. */
  73957. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  73958. /**
  73959. * Returns a vector with the minimum values from the left and right vectors
  73960. * @param left left vector to minimize
  73961. * @param right right vector to minimize
  73962. * @returns a new vector with the minimum of the left and right vector values
  73963. */
  73964. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73965. /**
  73966. * Returns a vector with the maximum values from the left and right vectors
  73967. * @param left left vector to maximize
  73968. * @param right right vector to maximize
  73969. * @returns a new vector with the maximum of the left and right vector values
  73970. */
  73971. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73972. /**
  73973. * Returns the distance (float) between the vectors "value1" and "value2".
  73974. * @param value1 value to calulate the distance between
  73975. * @param value2 value to calulate the distance between
  73976. * @return the distance between the two vectors
  73977. */
  73978. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73979. /**
  73980. * Returns the squared distance (float) between the vectors "value1" and "value2".
  73981. * @param value1 value to calulate the distance between
  73982. * @param value2 value to calulate the distance between
  73983. * @return the distance between the two vectors squared
  73984. */
  73985. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73986. /**
  73987. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  73988. * @param value1 value to calulate the center between
  73989. * @param value2 value to calulate the center between
  73990. * @return the center between the two vectors
  73991. */
  73992. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  73993. /**
  73994. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  73995. * This methods computes transformed normalized direction vectors only.
  73996. * @param vector the vector to transform
  73997. * @param transformation the transformation matrix to apply
  73998. * @returns the new vector
  73999. */
  74000. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  74001. /**
  74002. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74003. * This methods computes transformed normalized direction vectors only.
  74004. * @param vector the vector to transform
  74005. * @param transformation the transformation matrix to apply
  74006. * @param result the vector to store the result in
  74007. */
  74008. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74009. /**
  74010. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74011. * This methods computes transformed normalized direction vectors only.
  74012. * @param x value to transform
  74013. * @param y value to transform
  74014. * @param z value to transform
  74015. * @param w value to transform
  74016. * @param transformation the transformation matrix to apply
  74017. * @param result the vector to store the results in
  74018. */
  74019. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74020. /**
  74021. * Creates a new Vector4 from a Vector3
  74022. * @param source defines the source data
  74023. * @param w defines the 4th component (default is 0)
  74024. * @returns a new Vector4
  74025. */
  74026. static FromVector3(source: Vector3, w?: number): Vector4;
  74027. }
  74028. /**
  74029. * Class used to store quaternion data
  74030. * @see https://en.wikipedia.org/wiki/Quaternion
  74031. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74032. */
  74033. export class Quaternion {
  74034. /** defines the first component (0 by default) */
  74035. x: number;
  74036. /** defines the second component (0 by default) */
  74037. y: number;
  74038. /** defines the third component (0 by default) */
  74039. z: number;
  74040. /** defines the fourth component (1.0 by default) */
  74041. w: number;
  74042. /**
  74043. * Creates a new Quaternion from the given floats
  74044. * @param x defines the first component (0 by default)
  74045. * @param y defines the second component (0 by default)
  74046. * @param z defines the third component (0 by default)
  74047. * @param w defines the fourth component (1.0 by default)
  74048. */
  74049. constructor(
  74050. /** defines the first component (0 by default) */
  74051. x?: number,
  74052. /** defines the second component (0 by default) */
  74053. y?: number,
  74054. /** defines the third component (0 by default) */
  74055. z?: number,
  74056. /** defines the fourth component (1.0 by default) */
  74057. w?: number);
  74058. /**
  74059. * Gets a string representation for the current quaternion
  74060. * @returns a string with the Quaternion coordinates
  74061. */
  74062. toString(): string;
  74063. /**
  74064. * Gets the class name of the quaternion
  74065. * @returns the string "Quaternion"
  74066. */
  74067. getClassName(): string;
  74068. /**
  74069. * Gets a hash code for this quaternion
  74070. * @returns the quaternion hash code
  74071. */
  74072. getHashCode(): number;
  74073. /**
  74074. * Copy the quaternion to an array
  74075. * @returns a new array populated with 4 elements from the quaternion coordinates
  74076. */
  74077. asArray(): number[];
  74078. /**
  74079. * Check if two quaternions are equals
  74080. * @param otherQuaternion defines the second operand
  74081. * @return true if the current quaternion and the given one coordinates are strictly equals
  74082. */
  74083. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74084. /**
  74085. * Clone the current quaternion
  74086. * @returns a new quaternion copied from the current one
  74087. */
  74088. clone(): Quaternion;
  74089. /**
  74090. * Copy a quaternion to the current one
  74091. * @param other defines the other quaternion
  74092. * @returns the updated current quaternion
  74093. */
  74094. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74095. /**
  74096. * Updates the current quaternion with the given float coordinates
  74097. * @param x defines the x coordinate
  74098. * @param y defines the y coordinate
  74099. * @param z defines the z coordinate
  74100. * @param w defines the w coordinate
  74101. * @returns the updated current quaternion
  74102. */
  74103. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74104. /**
  74105. * Updates the current quaternion from the given float coordinates
  74106. * @param x defines the x coordinate
  74107. * @param y defines the y coordinate
  74108. * @param z defines the z coordinate
  74109. * @param w defines the w coordinate
  74110. * @returns the updated current quaternion
  74111. */
  74112. set(x: number, y: number, z: number, w: number): Quaternion;
  74113. /**
  74114. * Adds two quaternions
  74115. * @param other defines the second operand
  74116. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74117. */
  74118. add(other: DeepImmutable<Quaternion>): Quaternion;
  74119. /**
  74120. * Add a quaternion to the current one
  74121. * @param other defines the quaternion to add
  74122. * @returns the current quaternion
  74123. */
  74124. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74125. /**
  74126. * Subtract two quaternions
  74127. * @param other defines the second operand
  74128. * @returns a new quaternion as the subtraction result of the given one from the current one
  74129. */
  74130. subtract(other: Quaternion): Quaternion;
  74131. /**
  74132. * Multiplies the current quaternion by a scale factor
  74133. * @param value defines the scale factor
  74134. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74135. */
  74136. scale(value: number): Quaternion;
  74137. /**
  74138. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74139. * @param scale defines the scale factor
  74140. * @param result defines the Quaternion object where to store the result
  74141. * @returns the unmodified current quaternion
  74142. */
  74143. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74144. /**
  74145. * Multiplies in place the current quaternion by a scale factor
  74146. * @param value defines the scale factor
  74147. * @returns the current modified quaternion
  74148. */
  74149. scaleInPlace(value: number): Quaternion;
  74150. /**
  74151. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74152. * @param scale defines the scale factor
  74153. * @param result defines the Quaternion object where to store the result
  74154. * @returns the unmodified current quaternion
  74155. */
  74156. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74157. /**
  74158. * Multiplies two quaternions
  74159. * @param q1 defines the second operand
  74160. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74161. */
  74162. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74163. /**
  74164. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74165. * @param q1 defines the second operand
  74166. * @param result defines the target quaternion
  74167. * @returns the current quaternion
  74168. */
  74169. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74170. /**
  74171. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74172. * @param q1 defines the second operand
  74173. * @returns the currentupdated quaternion
  74174. */
  74175. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  74176. /**
  74177. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74178. * @param ref defines the target quaternion
  74179. * @returns the current quaternion
  74180. */
  74181. conjugateToRef(ref: Quaternion): Quaternion;
  74182. /**
  74183. * Conjugates in place (1-q) the current quaternion
  74184. * @returns the current updated quaternion
  74185. */
  74186. conjugateInPlace(): Quaternion;
  74187. /**
  74188. * Conjugates in place (1-q) the current quaternion
  74189. * @returns a new quaternion
  74190. */
  74191. conjugate(): Quaternion;
  74192. /**
  74193. * Gets length of current quaternion
  74194. * @returns the quaternion length (float)
  74195. */
  74196. length(): number;
  74197. /**
  74198. * Normalize in place the current quaternion
  74199. * @returns the current updated quaternion
  74200. */
  74201. normalize(): Quaternion;
  74202. /**
  74203. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74204. * @param order is a reserved parameter and is ignore for now
  74205. * @returns a new Vector3 containing the Euler angles
  74206. */
  74207. toEulerAngles(order?: string): Vector3;
  74208. /**
  74209. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74210. * @param result defines the vector which will be filled with the Euler angles
  74211. * @param order is a reserved parameter and is ignore for now
  74212. * @returns the current unchanged quaternion
  74213. */
  74214. toEulerAnglesToRef(result: Vector3): Quaternion;
  74215. /**
  74216. * Updates the given rotation matrix with the current quaternion values
  74217. * @param result defines the target matrix
  74218. * @returns the current unchanged quaternion
  74219. */
  74220. toRotationMatrix(result: Matrix): Quaternion;
  74221. /**
  74222. * Updates the current quaternion from the given rotation matrix values
  74223. * @param matrix defines the source matrix
  74224. * @returns the current updated quaternion
  74225. */
  74226. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74227. /**
  74228. * Creates a new quaternion from a rotation matrix
  74229. * @param matrix defines the source matrix
  74230. * @returns a new quaternion created from the given rotation matrix values
  74231. */
  74232. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74233. /**
  74234. * Updates the given quaternion with the given rotation matrix values
  74235. * @param matrix defines the source matrix
  74236. * @param result defines the target quaternion
  74237. */
  74238. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  74239. /**
  74240. * Returns the dot product (float) between the quaternions "left" and "right"
  74241. * @param left defines the left operand
  74242. * @param right defines the right operand
  74243. * @returns the dot product
  74244. */
  74245. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  74246. /**
  74247. * Checks if the two quaternions are close to each other
  74248. * @param quat0 defines the first quaternion to check
  74249. * @param quat1 defines the second quaternion to check
  74250. * @returns true if the two quaternions are close to each other
  74251. */
  74252. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  74253. /**
  74254. * Creates an empty quaternion
  74255. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74256. */
  74257. static Zero(): Quaternion;
  74258. /**
  74259. * Inverse a given quaternion
  74260. * @param q defines the source quaternion
  74261. * @returns a new quaternion as the inverted current quaternion
  74262. */
  74263. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  74264. /**
  74265. * Inverse a given quaternion
  74266. * @param q defines the source quaternion
  74267. * @param result the quaternion the result will be stored in
  74268. * @returns the result quaternion
  74269. */
  74270. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  74271. /**
  74272. * Creates an identity quaternion
  74273. * @returns the identity quaternion
  74274. */
  74275. static Identity(): Quaternion;
  74276. /**
  74277. * Gets a boolean indicating if the given quaternion is identity
  74278. * @param quaternion defines the quaternion to check
  74279. * @returns true if the quaternion is identity
  74280. */
  74281. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  74282. /**
  74283. * Creates a quaternion from a rotation around an axis
  74284. * @param axis defines the axis to use
  74285. * @param angle defines the angle to use
  74286. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74287. */
  74288. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  74289. /**
  74290. * Creates a rotation around an axis and stores it into the given quaternion
  74291. * @param axis defines the axis to use
  74292. * @param angle defines the angle to use
  74293. * @param result defines the target quaternion
  74294. * @returns the target quaternion
  74295. */
  74296. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  74297. /**
  74298. * Creates a new quaternion from data stored into an array
  74299. * @param array defines the data source
  74300. * @param offset defines the offset in the source array where the data starts
  74301. * @returns a new quaternion
  74302. */
  74303. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  74304. /**
  74305. * Create a quaternion from Euler rotation angles
  74306. * @param x Pitch
  74307. * @param y Yaw
  74308. * @param z Roll
  74309. * @returns the new Quaternion
  74310. */
  74311. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  74312. /**
  74313. * Updates a quaternion from Euler rotation angles
  74314. * @param x Pitch
  74315. * @param y Yaw
  74316. * @param z Roll
  74317. * @param result the quaternion to store the result
  74318. * @returns the updated quaternion
  74319. */
  74320. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  74321. /**
  74322. * Create a quaternion from Euler rotation vector
  74323. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74324. * @returns the new Quaternion
  74325. */
  74326. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  74327. /**
  74328. * Updates a quaternion from Euler rotation vector
  74329. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74330. * @param result the quaternion to store the result
  74331. * @returns the updated quaternion
  74332. */
  74333. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  74334. /**
  74335. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74336. * @param yaw defines the rotation around Y axis
  74337. * @param pitch defines the rotation around X axis
  74338. * @param roll defines the rotation around Z axis
  74339. * @returns the new quaternion
  74340. */
  74341. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  74342. /**
  74343. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74344. * @param yaw defines the rotation around Y axis
  74345. * @param pitch defines the rotation around X axis
  74346. * @param roll defines the rotation around Z axis
  74347. * @param result defines the target quaternion
  74348. */
  74349. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  74350. /**
  74351. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74352. * @param alpha defines the rotation around first axis
  74353. * @param beta defines the rotation around second axis
  74354. * @param gamma defines the rotation around third axis
  74355. * @returns the new quaternion
  74356. */
  74357. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  74358. /**
  74359. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74360. * @param alpha defines the rotation around first axis
  74361. * @param beta defines the rotation around second axis
  74362. * @param gamma defines the rotation around third axis
  74363. * @param result defines the target quaternion
  74364. */
  74365. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  74366. /**
  74367. * 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)
  74368. * @param axis1 defines the first axis
  74369. * @param axis2 defines the second axis
  74370. * @param axis3 defines the third axis
  74371. * @returns the new quaternion
  74372. */
  74373. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  74374. /**
  74375. * 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
  74376. * @param axis1 defines the first axis
  74377. * @param axis2 defines the second axis
  74378. * @param axis3 defines the third axis
  74379. * @param ref defines the target quaternion
  74380. */
  74381. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  74382. /**
  74383. * Interpolates between two quaternions
  74384. * @param left defines first quaternion
  74385. * @param right defines second quaternion
  74386. * @param amount defines the gradient to use
  74387. * @returns the new interpolated quaternion
  74388. */
  74389. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74390. /**
  74391. * Interpolates between two quaternions and stores it into a target quaternion
  74392. * @param left defines first quaternion
  74393. * @param right defines second quaternion
  74394. * @param amount defines the gradient to use
  74395. * @param result defines the target quaternion
  74396. */
  74397. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  74398. /**
  74399. * Interpolate between two quaternions using Hermite interpolation
  74400. * @param value1 defines first quaternion
  74401. * @param tangent1 defines the incoming tangent
  74402. * @param value2 defines second quaternion
  74403. * @param tangent2 defines the outgoing tangent
  74404. * @param amount defines the target quaternion
  74405. * @returns the new interpolated quaternion
  74406. */
  74407. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74408. }
  74409. /**
  74410. * Class used to store matrix data (4x4)
  74411. */
  74412. export class Matrix {
  74413. private static _updateFlagSeed;
  74414. private static _identityReadOnly;
  74415. private _isIdentity;
  74416. private _isIdentityDirty;
  74417. private _isIdentity3x2;
  74418. private _isIdentity3x2Dirty;
  74419. /**
  74420. * Gets the update flag of the matrix which is an unique number for the matrix.
  74421. * It will be incremented every time the matrix data change.
  74422. * You can use it to speed the comparison between two versions of the same matrix.
  74423. */
  74424. updateFlag: number;
  74425. private readonly _m;
  74426. /**
  74427. * Gets the internal data of the matrix
  74428. */
  74429. get m(): DeepImmutable<Float32Array>;
  74430. /** @hidden */
  74431. _markAsUpdated(): void;
  74432. /** @hidden */
  74433. private _updateIdentityStatus;
  74434. /**
  74435. * Creates an empty matrix (filled with zeros)
  74436. */
  74437. constructor();
  74438. /**
  74439. * Check if the current matrix is identity
  74440. * @returns true is the matrix is the identity matrix
  74441. */
  74442. isIdentity(): boolean;
  74443. /**
  74444. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74445. * @returns true is the matrix is the identity matrix
  74446. */
  74447. isIdentityAs3x2(): boolean;
  74448. /**
  74449. * Gets the determinant of the matrix
  74450. * @returns the matrix determinant
  74451. */
  74452. determinant(): number;
  74453. /**
  74454. * Returns the matrix as a Float32Array
  74455. * @returns the matrix underlying array
  74456. */
  74457. toArray(): DeepImmutable<Float32Array>;
  74458. /**
  74459. * Returns the matrix as a Float32Array
  74460. * @returns the matrix underlying array.
  74461. */
  74462. asArray(): DeepImmutable<Float32Array>;
  74463. /**
  74464. * Inverts the current matrix in place
  74465. * @returns the current inverted matrix
  74466. */
  74467. invert(): Matrix;
  74468. /**
  74469. * Sets all the matrix elements to zero
  74470. * @returns the current matrix
  74471. */
  74472. reset(): Matrix;
  74473. /**
  74474. * Adds the current matrix with a second one
  74475. * @param other defines the matrix to add
  74476. * @returns a new matrix as the addition of the current matrix and the given one
  74477. */
  74478. add(other: DeepImmutable<Matrix>): Matrix;
  74479. /**
  74480. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74481. * @param other defines the matrix to add
  74482. * @param result defines the target matrix
  74483. * @returns the current matrix
  74484. */
  74485. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74486. /**
  74487. * Adds in place the given matrix to the current matrix
  74488. * @param other defines the second operand
  74489. * @returns the current updated matrix
  74490. */
  74491. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  74492. /**
  74493. * Sets the given matrix to the current inverted Matrix
  74494. * @param other defines the target matrix
  74495. * @returns the unmodified current matrix
  74496. */
  74497. invertToRef(other: Matrix): Matrix;
  74498. /**
  74499. * add a value at the specified position in the current Matrix
  74500. * @param index the index of the value within the matrix. between 0 and 15.
  74501. * @param value the value to be added
  74502. * @returns the current updated matrix
  74503. */
  74504. addAtIndex(index: number, value: number): Matrix;
  74505. /**
  74506. * mutiply the specified position in the current Matrix by a value
  74507. * @param index the index of the value within the matrix. between 0 and 15.
  74508. * @param value the value to be added
  74509. * @returns the current updated matrix
  74510. */
  74511. multiplyAtIndex(index: number, value: number): Matrix;
  74512. /**
  74513. * Inserts the translation vector (using 3 floats) in the current matrix
  74514. * @param x defines the 1st component of the translation
  74515. * @param y defines the 2nd component of the translation
  74516. * @param z defines the 3rd component of the translation
  74517. * @returns the current updated matrix
  74518. */
  74519. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74520. /**
  74521. * Adds the translation vector (using 3 floats) in the current matrix
  74522. * @param x defines the 1st component of the translation
  74523. * @param y defines the 2nd component of the translation
  74524. * @param z defines the 3rd component of the translation
  74525. * @returns the current updated matrix
  74526. */
  74527. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74528. /**
  74529. * Inserts the translation vector in the current matrix
  74530. * @param vector3 defines the translation to insert
  74531. * @returns the current updated matrix
  74532. */
  74533. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  74534. /**
  74535. * Gets the translation value of the current matrix
  74536. * @returns a new Vector3 as the extracted translation from the matrix
  74537. */
  74538. getTranslation(): Vector3;
  74539. /**
  74540. * Fill a Vector3 with the extracted translation from the matrix
  74541. * @param result defines the Vector3 where to store the translation
  74542. * @returns the current matrix
  74543. */
  74544. getTranslationToRef(result: Vector3): Matrix;
  74545. /**
  74546. * Remove rotation and scaling part from the matrix
  74547. * @returns the updated matrix
  74548. */
  74549. removeRotationAndScaling(): Matrix;
  74550. /**
  74551. * Multiply two matrices
  74552. * @param other defines the second operand
  74553. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74554. */
  74555. multiply(other: DeepImmutable<Matrix>): Matrix;
  74556. /**
  74557. * Copy the current matrix from the given one
  74558. * @param other defines the source matrix
  74559. * @returns the current updated matrix
  74560. */
  74561. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  74562. /**
  74563. * Populates the given array from the starting index with the current matrix values
  74564. * @param array defines the target array
  74565. * @param offset defines the offset in the target array where to start storing values
  74566. * @returns the current matrix
  74567. */
  74568. copyToArray(array: Float32Array, offset?: number): Matrix;
  74569. /**
  74570. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74571. * @param other defines the second operand
  74572. * @param result defines the matrix where to store the multiplication
  74573. * @returns the current matrix
  74574. */
  74575. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74576. /**
  74577. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74578. * @param other defines the second operand
  74579. * @param result defines the array where to store the multiplication
  74580. * @param offset defines the offset in the target array where to start storing values
  74581. * @returns the current matrix
  74582. */
  74583. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  74584. /**
  74585. * Check equality between this matrix and a second one
  74586. * @param value defines the second matrix to compare
  74587. * @returns true is the current matrix and the given one values are strictly equal
  74588. */
  74589. equals(value: DeepImmutable<Matrix>): boolean;
  74590. /**
  74591. * Clone the current matrix
  74592. * @returns a new matrix from the current matrix
  74593. */
  74594. clone(): Matrix;
  74595. /**
  74596. * Returns the name of the current matrix class
  74597. * @returns the string "Matrix"
  74598. */
  74599. getClassName(): string;
  74600. /**
  74601. * Gets the hash code of the current matrix
  74602. * @returns the hash code
  74603. */
  74604. getHashCode(): number;
  74605. /**
  74606. * Decomposes the current Matrix into a translation, rotation and scaling components
  74607. * @param scale defines the scale vector3 given as a reference to update
  74608. * @param rotation defines the rotation quaternion given as a reference to update
  74609. * @param translation defines the translation vector3 given as a reference to update
  74610. * @returns true if operation was successful
  74611. */
  74612. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  74613. /**
  74614. * Gets specific row of the matrix
  74615. * @param index defines the number of the row to get
  74616. * @returns the index-th row of the current matrix as a new Vector4
  74617. */
  74618. getRow(index: number): Nullable<Vector4>;
  74619. /**
  74620. * Sets the index-th row of the current matrix to the vector4 values
  74621. * @param index defines the number of the row to set
  74622. * @param row defines the target vector4
  74623. * @returns the updated current matrix
  74624. */
  74625. setRow(index: number, row: Vector4): Matrix;
  74626. /**
  74627. * Compute the transpose of the matrix
  74628. * @returns the new transposed matrix
  74629. */
  74630. transpose(): Matrix;
  74631. /**
  74632. * Compute the transpose of the matrix and store it in a given matrix
  74633. * @param result defines the target matrix
  74634. * @returns the current matrix
  74635. */
  74636. transposeToRef(result: Matrix): Matrix;
  74637. /**
  74638. * Sets the index-th row of the current matrix with the given 4 x float values
  74639. * @param index defines the row index
  74640. * @param x defines the x component to set
  74641. * @param y defines the y component to set
  74642. * @param z defines the z component to set
  74643. * @param w defines the w component to set
  74644. * @returns the updated current matrix
  74645. */
  74646. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  74647. /**
  74648. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74649. * @param scale defines the scale factor
  74650. * @returns a new matrix
  74651. */
  74652. scale(scale: number): Matrix;
  74653. /**
  74654. * Scale the current matrix values by a factor to a given result matrix
  74655. * @param scale defines the scale factor
  74656. * @param result defines the matrix to store the result
  74657. * @returns the current matrix
  74658. */
  74659. scaleToRef(scale: number, result: Matrix): Matrix;
  74660. /**
  74661. * Scale the current matrix values by a factor and add the result to a given matrix
  74662. * @param scale defines the scale factor
  74663. * @param result defines the Matrix to store the result
  74664. * @returns the current matrix
  74665. */
  74666. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  74667. /**
  74668. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74669. * @param ref matrix to store the result
  74670. */
  74671. toNormalMatrix(ref: Matrix): void;
  74672. /**
  74673. * Gets only rotation part of the current matrix
  74674. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74675. */
  74676. getRotationMatrix(): Matrix;
  74677. /**
  74678. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74679. * @param result defines the target matrix to store data to
  74680. * @returns the current matrix
  74681. */
  74682. getRotationMatrixToRef(result: Matrix): Matrix;
  74683. /**
  74684. * Toggles model matrix from being right handed to left handed in place and vice versa
  74685. */
  74686. toggleModelMatrixHandInPlace(): void;
  74687. /**
  74688. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74689. */
  74690. toggleProjectionMatrixHandInPlace(): void;
  74691. /**
  74692. * Creates a matrix from an array
  74693. * @param array defines the source array
  74694. * @param offset defines an offset in the source array
  74695. * @returns a new Matrix set from the starting index of the given array
  74696. */
  74697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  74698. /**
  74699. * Copy the content of an array into a given matrix
  74700. * @param array defines the source array
  74701. * @param offset defines an offset in the source array
  74702. * @param result defines the target matrix
  74703. */
  74704. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  74705. /**
  74706. * Stores an array into a matrix after having multiplied each component by a given factor
  74707. * @param array defines the source array
  74708. * @param offset defines the offset in the source array
  74709. * @param scale defines the scaling factor
  74710. * @param result defines the target matrix
  74711. */
  74712. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  74713. /**
  74714. * Gets an identity matrix that must not be updated
  74715. */
  74716. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  74717. /**
  74718. * Stores a list of values (16) inside a given matrix
  74719. * @param initialM11 defines 1st value of 1st row
  74720. * @param initialM12 defines 2nd value of 1st row
  74721. * @param initialM13 defines 3rd value of 1st row
  74722. * @param initialM14 defines 4th value of 1st row
  74723. * @param initialM21 defines 1st value of 2nd row
  74724. * @param initialM22 defines 2nd value of 2nd row
  74725. * @param initialM23 defines 3rd value of 2nd row
  74726. * @param initialM24 defines 4th value of 2nd row
  74727. * @param initialM31 defines 1st value of 3rd row
  74728. * @param initialM32 defines 2nd value of 3rd row
  74729. * @param initialM33 defines 3rd value of 3rd row
  74730. * @param initialM34 defines 4th value of 3rd row
  74731. * @param initialM41 defines 1st value of 4th row
  74732. * @param initialM42 defines 2nd value of 4th row
  74733. * @param initialM43 defines 3rd value of 4th row
  74734. * @param initialM44 defines 4th value of 4th row
  74735. * @param result defines the target matrix
  74736. */
  74737. 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;
  74738. /**
  74739. * Creates new matrix from a list of values (16)
  74740. * @param initialM11 defines 1st value of 1st row
  74741. * @param initialM12 defines 2nd value of 1st row
  74742. * @param initialM13 defines 3rd value of 1st row
  74743. * @param initialM14 defines 4th value of 1st row
  74744. * @param initialM21 defines 1st value of 2nd row
  74745. * @param initialM22 defines 2nd value of 2nd row
  74746. * @param initialM23 defines 3rd value of 2nd row
  74747. * @param initialM24 defines 4th value of 2nd row
  74748. * @param initialM31 defines 1st value of 3rd row
  74749. * @param initialM32 defines 2nd value of 3rd row
  74750. * @param initialM33 defines 3rd value of 3rd row
  74751. * @param initialM34 defines 4th value of 3rd row
  74752. * @param initialM41 defines 1st value of 4th row
  74753. * @param initialM42 defines 2nd value of 4th row
  74754. * @param initialM43 defines 3rd value of 4th row
  74755. * @param initialM44 defines 4th value of 4th row
  74756. * @returns the new matrix
  74757. */
  74758. 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;
  74759. /**
  74760. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74761. * @param scale defines the scale vector3
  74762. * @param rotation defines the rotation quaternion
  74763. * @param translation defines the translation vector3
  74764. * @returns a new matrix
  74765. */
  74766. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  74767. /**
  74768. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74769. * @param scale defines the scale vector3
  74770. * @param rotation defines the rotation quaternion
  74771. * @param translation defines the translation vector3
  74772. * @param result defines the target matrix
  74773. */
  74774. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  74775. /**
  74776. * Creates a new identity matrix
  74777. * @returns a new identity matrix
  74778. */
  74779. static Identity(): Matrix;
  74780. /**
  74781. * Creates a new identity matrix and stores the result in a given matrix
  74782. * @param result defines the target matrix
  74783. */
  74784. static IdentityToRef(result: Matrix): void;
  74785. /**
  74786. * Creates a new zero matrix
  74787. * @returns a new zero matrix
  74788. */
  74789. static Zero(): Matrix;
  74790. /**
  74791. * Creates a new rotation matrix for "angle" radians around the X axis
  74792. * @param angle defines the angle (in radians) to use
  74793. * @return the new matrix
  74794. */
  74795. static RotationX(angle: number): Matrix;
  74796. /**
  74797. * Creates a new matrix as the invert of a given matrix
  74798. * @param source defines the source matrix
  74799. * @returns the new matrix
  74800. */
  74801. static Invert(source: DeepImmutable<Matrix>): Matrix;
  74802. /**
  74803. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74804. * @param angle defines the angle (in radians) to use
  74805. * @param result defines the target matrix
  74806. */
  74807. static RotationXToRef(angle: number, result: Matrix): void;
  74808. /**
  74809. * Creates a new rotation matrix for "angle" radians around the Y axis
  74810. * @param angle defines the angle (in radians) to use
  74811. * @return the new matrix
  74812. */
  74813. static RotationY(angle: number): Matrix;
  74814. /**
  74815. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74816. * @param angle defines the angle (in radians) to use
  74817. * @param result defines the target matrix
  74818. */
  74819. static RotationYToRef(angle: number, result: Matrix): void;
  74820. /**
  74821. * Creates a new rotation matrix for "angle" radians around the Z axis
  74822. * @param angle defines the angle (in radians) to use
  74823. * @return the new matrix
  74824. */
  74825. static RotationZ(angle: number): Matrix;
  74826. /**
  74827. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74828. * @param angle defines the angle (in radians) to use
  74829. * @param result defines the target matrix
  74830. */
  74831. static RotationZToRef(angle: number, result: Matrix): void;
  74832. /**
  74833. * Creates a new rotation matrix for "angle" radians around the given axis
  74834. * @param axis defines the axis to use
  74835. * @param angle defines the angle (in radians) to use
  74836. * @return the new matrix
  74837. */
  74838. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  74839. /**
  74840. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74841. * @param axis defines the axis to use
  74842. * @param angle defines the angle (in radians) to use
  74843. * @param result defines the target matrix
  74844. */
  74845. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  74846. /**
  74847. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  74848. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  74849. * @param from defines the vector to align
  74850. * @param to defines the vector to align to
  74851. * @param result defines the target matrix
  74852. */
  74853. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  74854. /**
  74855. * Creates a rotation matrix
  74856. * @param yaw defines the yaw angle in radians (Y axis)
  74857. * @param pitch defines the pitch angle in radians (X axis)
  74858. * @param roll defines the roll angle in radians (X axis)
  74859. * @returns the new rotation matrix
  74860. */
  74861. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  74862. /**
  74863. * Creates a rotation matrix and stores it in a given matrix
  74864. * @param yaw defines the yaw angle in radians (Y axis)
  74865. * @param pitch defines the pitch angle in radians (X axis)
  74866. * @param roll defines the roll angle in radians (X axis)
  74867. * @param result defines the target matrix
  74868. */
  74869. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  74870. /**
  74871. * Creates a scaling matrix
  74872. * @param x defines the scale factor on X axis
  74873. * @param y defines the scale factor on Y axis
  74874. * @param z defines the scale factor on Z axis
  74875. * @returns the new matrix
  74876. */
  74877. static Scaling(x: number, y: number, z: number): Matrix;
  74878. /**
  74879. * Creates a scaling matrix and stores it in a given matrix
  74880. * @param x defines the scale factor on X axis
  74881. * @param y defines the scale factor on Y axis
  74882. * @param z defines the scale factor on Z axis
  74883. * @param result defines the target matrix
  74884. */
  74885. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  74886. /**
  74887. * Creates a translation matrix
  74888. * @param x defines the translation on X axis
  74889. * @param y defines the translation on Y axis
  74890. * @param z defines the translationon Z axis
  74891. * @returns the new matrix
  74892. */
  74893. static Translation(x: number, y: number, z: number): Matrix;
  74894. /**
  74895. * Creates a translation matrix and stores it in a given matrix
  74896. * @param x defines the translation on X axis
  74897. * @param y defines the translation on Y axis
  74898. * @param z defines the translationon Z axis
  74899. * @param result defines the target matrix
  74900. */
  74901. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  74902. /**
  74903. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74904. * @param startValue defines the start value
  74905. * @param endValue defines the end value
  74906. * @param gradient defines the gradient factor
  74907. * @returns the new matrix
  74908. */
  74909. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74910. /**
  74911. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74912. * @param startValue defines the start value
  74913. * @param endValue defines the end value
  74914. * @param gradient defines the gradient factor
  74915. * @param result defines the Matrix object where to store data
  74916. */
  74917. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74918. /**
  74919. * Builds a new matrix whose values are computed by:
  74920. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74921. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74922. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74923. * @param startValue defines the first matrix
  74924. * @param endValue defines the second matrix
  74925. * @param gradient defines the gradient between the two matrices
  74926. * @returns the new matrix
  74927. */
  74928. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74929. /**
  74930. * Update a matrix to values which are computed by:
  74931. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74932. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74933. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74934. * @param startValue defines the first matrix
  74935. * @param endValue defines the second matrix
  74936. * @param gradient defines the gradient between the two matrices
  74937. * @param result defines the target matrix
  74938. */
  74939. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74940. /**
  74941. * 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"
  74942. * This function works in left handed mode
  74943. * @param eye defines the final position of the entity
  74944. * @param target defines where the entity should look at
  74945. * @param up defines the up vector for the entity
  74946. * @returns the new matrix
  74947. */
  74948. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74949. /**
  74950. * 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".
  74951. * This function works in left handed mode
  74952. * @param eye defines the final position of the entity
  74953. * @param target defines where the entity should look at
  74954. * @param up defines the up vector for the entity
  74955. * @param result defines the target matrix
  74956. */
  74957. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74958. /**
  74959. * 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"
  74960. * This function works in right handed mode
  74961. * @param eye defines the final position of the entity
  74962. * @param target defines where the entity should look at
  74963. * @param up defines the up vector for the entity
  74964. * @returns the new matrix
  74965. */
  74966. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74967. /**
  74968. * 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".
  74969. * This function works in right handed mode
  74970. * @param eye defines the final position of the entity
  74971. * @param target defines where the entity should look at
  74972. * @param up defines the up vector for the entity
  74973. * @param result defines the target matrix
  74974. */
  74975. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74976. /**
  74977. * Create a left-handed orthographic projection matrix
  74978. * @param width defines the viewport width
  74979. * @param height defines the viewport height
  74980. * @param znear defines the near clip plane
  74981. * @param zfar defines the far clip plane
  74982. * @returns a new matrix as a left-handed orthographic projection matrix
  74983. */
  74984. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  74985. /**
  74986. * Store a left-handed orthographic projection to a given matrix
  74987. * @param width defines the viewport width
  74988. * @param height defines the viewport height
  74989. * @param znear defines the near clip plane
  74990. * @param zfar defines the far clip plane
  74991. * @param result defines the target matrix
  74992. */
  74993. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  74994. /**
  74995. * Create a left-handed orthographic projection matrix
  74996. * @param left defines the viewport left coordinate
  74997. * @param right defines the viewport right coordinate
  74998. * @param bottom defines the viewport bottom coordinate
  74999. * @param top defines the viewport top coordinate
  75000. * @param znear defines the near clip plane
  75001. * @param zfar defines the far clip plane
  75002. * @returns a new matrix as a left-handed orthographic projection matrix
  75003. */
  75004. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75005. /**
  75006. * Stores a left-handed orthographic projection into a given matrix
  75007. * @param left defines the viewport left coordinate
  75008. * @param right defines the viewport right coordinate
  75009. * @param bottom defines the viewport bottom coordinate
  75010. * @param top defines the viewport top coordinate
  75011. * @param znear defines the near clip plane
  75012. * @param zfar defines the far clip plane
  75013. * @param result defines the target matrix
  75014. */
  75015. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75016. /**
  75017. * Creates a right-handed orthographic projection matrix
  75018. * @param left defines the viewport left coordinate
  75019. * @param right defines the viewport right coordinate
  75020. * @param bottom defines the viewport bottom coordinate
  75021. * @param top defines the viewport top coordinate
  75022. * @param znear defines the near clip plane
  75023. * @param zfar defines the far clip plane
  75024. * @returns a new matrix as a right-handed orthographic projection matrix
  75025. */
  75026. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75027. /**
  75028. * Stores a right-handed orthographic projection into a given matrix
  75029. * @param left defines the viewport left coordinate
  75030. * @param right defines the viewport right coordinate
  75031. * @param bottom defines the viewport bottom coordinate
  75032. * @param top defines the viewport top coordinate
  75033. * @param znear defines the near clip plane
  75034. * @param zfar defines the far clip plane
  75035. * @param result defines the target matrix
  75036. */
  75037. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75038. /**
  75039. * Creates a left-handed perspective projection matrix
  75040. * @param width defines the viewport width
  75041. * @param height defines the viewport height
  75042. * @param znear defines the near clip plane
  75043. * @param zfar defines the far clip plane
  75044. * @returns a new matrix as a left-handed perspective projection matrix
  75045. */
  75046. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75047. /**
  75048. * Creates a left-handed perspective projection matrix
  75049. * @param fov defines the horizontal field of view
  75050. * @param aspect defines the aspect ratio
  75051. * @param znear defines the near clip plane
  75052. * @param zfar defines the far clip plane
  75053. * @returns a new matrix as a left-handed perspective projection matrix
  75054. */
  75055. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75056. /**
  75057. * Stores a left-handed perspective projection into a given matrix
  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 defines the far clip plane
  75062. * @param result defines the target matrix
  75063. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75064. */
  75065. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75066. /**
  75067. * Stores a left-handed perspective projection into a given matrix with depth reversed
  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 not used as infinity is used as far clip
  75072. * @param result defines the target matrix
  75073. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75074. */
  75075. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75076. /**
  75077. * Creates a right-handed perspective projection matrix
  75078. * @param fov defines the horizontal field of view
  75079. * @param aspect defines the aspect ratio
  75080. * @param znear defines the near clip plane
  75081. * @param zfar defines the far clip plane
  75082. * @returns a new matrix as a right-handed perspective projection matrix
  75083. */
  75084. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  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 defines the far clip plane
  75091. * @param result defines the target matrix
  75092. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75093. */
  75094. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75095. /**
  75096. * Stores a right-handed perspective projection into a given matrix
  75097. * @param fov defines the horizontal field of view
  75098. * @param aspect defines the aspect ratio
  75099. * @param znear defines the near clip plane
  75100. * @param zfar not used as infinity is used as far clip
  75101. * @param result defines the target matrix
  75102. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75103. */
  75104. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75105. /**
  75106. * Stores a perspective projection for WebVR info a given matrix
  75107. * @param fov defines the field of view
  75108. * @param znear defines the near clip plane
  75109. * @param zfar defines the far clip plane
  75110. * @param result defines the target matrix
  75111. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75112. */
  75113. static PerspectiveFovWebVRToRef(fov: {
  75114. upDegrees: number;
  75115. downDegrees: number;
  75116. leftDegrees: number;
  75117. rightDegrees: number;
  75118. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75119. /**
  75120. * Computes a complete transformation matrix
  75121. * @param viewport defines the viewport to use
  75122. * @param world defines the world matrix
  75123. * @param view defines the view matrix
  75124. * @param projection defines the projection matrix
  75125. * @param zmin defines the near clip plane
  75126. * @param zmax defines the far clip plane
  75127. * @returns the transformation matrix
  75128. */
  75129. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75130. /**
  75131. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75132. * @param matrix defines the matrix to use
  75133. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75134. */
  75135. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75136. /**
  75137. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75138. * @param matrix defines the matrix to use
  75139. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75140. */
  75141. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75142. /**
  75143. * Compute the transpose of a given matrix
  75144. * @param matrix defines the matrix to transpose
  75145. * @returns the new matrix
  75146. */
  75147. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75148. /**
  75149. * Compute the transpose of a matrix and store it in a target matrix
  75150. * @param matrix defines the matrix to transpose
  75151. * @param result defines the target matrix
  75152. */
  75153. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75154. /**
  75155. * Computes a reflection matrix from a plane
  75156. * @param plane defines the reflection plane
  75157. * @returns a new matrix
  75158. */
  75159. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75160. /**
  75161. * Computes a reflection matrix from a plane
  75162. * @param plane defines the reflection plane
  75163. * @param result defines the target matrix
  75164. */
  75165. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75166. /**
  75167. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75168. * @param xaxis defines the value of the 1st axis
  75169. * @param yaxis defines the value of the 2nd axis
  75170. * @param zaxis defines the value of the 3rd axis
  75171. * @param result defines the target matrix
  75172. */
  75173. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  75174. /**
  75175. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75176. * @param quat defines the quaternion to use
  75177. * @param result defines the target matrix
  75178. */
  75179. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  75180. }
  75181. /**
  75182. * @hidden
  75183. */
  75184. export class TmpVectors {
  75185. static Vector2: Vector2[];
  75186. static Vector3: Vector3[];
  75187. static Vector4: Vector4[];
  75188. static Quaternion: Quaternion[];
  75189. static Matrix: Matrix[];
  75190. }
  75191. }
  75192. declare module BABYLON {
  75193. /**
  75194. * Defines potential orientation for back face culling
  75195. */
  75196. export enum Orientation {
  75197. /**
  75198. * Clockwise
  75199. */
  75200. CW = 0,
  75201. /** Counter clockwise */
  75202. CCW = 1
  75203. }
  75204. /** Class used to represent a Bezier curve */
  75205. export class BezierCurve {
  75206. /**
  75207. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75208. * @param t defines the time
  75209. * @param x1 defines the left coordinate on X axis
  75210. * @param y1 defines the left coordinate on Y axis
  75211. * @param x2 defines the right coordinate on X axis
  75212. * @param y2 defines the right coordinate on Y axis
  75213. * @returns the interpolated value
  75214. */
  75215. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  75216. }
  75217. /**
  75218. * Defines angle representation
  75219. */
  75220. export class Angle {
  75221. private _radians;
  75222. /**
  75223. * Creates an Angle object of "radians" radians (float).
  75224. * @param radians the angle in radians
  75225. */
  75226. constructor(radians: number);
  75227. /**
  75228. * Get value in degrees
  75229. * @returns the Angle value in degrees (float)
  75230. */
  75231. degrees(): number;
  75232. /**
  75233. * Get value in radians
  75234. * @returns the Angle value in radians (float)
  75235. */
  75236. radians(): number;
  75237. /**
  75238. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75239. * @param a defines first vector
  75240. * @param b defines second vector
  75241. * @returns a new Angle
  75242. */
  75243. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  75244. /**
  75245. * Gets a new Angle object from the given float in radians
  75246. * @param radians defines the angle value in radians
  75247. * @returns a new Angle
  75248. */
  75249. static FromRadians(radians: number): Angle;
  75250. /**
  75251. * Gets a new Angle object from the given float in degrees
  75252. * @param degrees defines the angle value in degrees
  75253. * @returns a new Angle
  75254. */
  75255. static FromDegrees(degrees: number): Angle;
  75256. }
  75257. /**
  75258. * This represents an arc in a 2d space.
  75259. */
  75260. export class Arc2 {
  75261. /** Defines the start point of the arc */
  75262. startPoint: Vector2;
  75263. /** Defines the mid point of the arc */
  75264. midPoint: Vector2;
  75265. /** Defines the end point of the arc */
  75266. endPoint: Vector2;
  75267. /**
  75268. * Defines the center point of the arc.
  75269. */
  75270. centerPoint: Vector2;
  75271. /**
  75272. * Defines the radius of the arc.
  75273. */
  75274. radius: number;
  75275. /**
  75276. * Defines the angle of the arc (from mid point to end point).
  75277. */
  75278. angle: Angle;
  75279. /**
  75280. * Defines the start angle of the arc (from start point to middle point).
  75281. */
  75282. startAngle: Angle;
  75283. /**
  75284. * Defines the orientation of the arc (clock wise/counter clock wise).
  75285. */
  75286. orientation: Orientation;
  75287. /**
  75288. * Creates an Arc object from the three given points : start, middle and end.
  75289. * @param startPoint Defines the start point of the arc
  75290. * @param midPoint Defines the midlle point of the arc
  75291. * @param endPoint Defines the end point of the arc
  75292. */
  75293. constructor(
  75294. /** Defines the start point of the arc */
  75295. startPoint: Vector2,
  75296. /** Defines the mid point of the arc */
  75297. midPoint: Vector2,
  75298. /** Defines the end point of the arc */
  75299. endPoint: Vector2);
  75300. }
  75301. /**
  75302. * Represents a 2D path made up of multiple 2D points
  75303. */
  75304. export class Path2 {
  75305. private _points;
  75306. private _length;
  75307. /**
  75308. * If the path start and end point are the same
  75309. */
  75310. closed: boolean;
  75311. /**
  75312. * Creates a Path2 object from the starting 2D coordinates x and y.
  75313. * @param x the starting points x value
  75314. * @param y the starting points y value
  75315. */
  75316. constructor(x: number, y: number);
  75317. /**
  75318. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75319. * @param x the added points x value
  75320. * @param y the added points y value
  75321. * @returns the updated Path2.
  75322. */
  75323. addLineTo(x: number, y: number): Path2;
  75324. /**
  75325. * 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.
  75326. * @param midX middle point x value
  75327. * @param midY middle point y value
  75328. * @param endX end point x value
  75329. * @param endY end point y value
  75330. * @param numberOfSegments (default: 36)
  75331. * @returns the updated Path2.
  75332. */
  75333. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  75334. /**
  75335. * Closes the Path2.
  75336. * @returns the Path2.
  75337. */
  75338. close(): Path2;
  75339. /**
  75340. * Gets the sum of the distance between each sequential point in the path
  75341. * @returns the Path2 total length (float).
  75342. */
  75343. length(): number;
  75344. /**
  75345. * Gets the points which construct the path
  75346. * @returns the Path2 internal array of points.
  75347. */
  75348. getPoints(): Vector2[];
  75349. /**
  75350. * Retreives the point at the distance aways from the starting point
  75351. * @param normalizedLengthPosition the length along the path to retreive the point from
  75352. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75353. */
  75354. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  75355. /**
  75356. * Creates a new path starting from an x and y position
  75357. * @param x starting x value
  75358. * @param y starting y value
  75359. * @returns a new Path2 starting at the coordinates (x, y).
  75360. */
  75361. static StartingAt(x: number, y: number): Path2;
  75362. }
  75363. /**
  75364. * Represents a 3D path made up of multiple 3D points
  75365. */
  75366. export class Path3D {
  75367. /**
  75368. * an array of Vector3, the curve axis of the Path3D
  75369. */
  75370. path: Vector3[];
  75371. private _curve;
  75372. private _distances;
  75373. private _tangents;
  75374. private _normals;
  75375. private _binormals;
  75376. private _raw;
  75377. private _alignTangentsWithPath;
  75378. private readonly _pointAtData;
  75379. /**
  75380. * new Path3D(path, normal, raw)
  75381. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75382. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75383. * @param path an array of Vector3, the curve axis of the Path3D
  75384. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75385. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75386. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  75387. */
  75388. constructor(
  75389. /**
  75390. * an array of Vector3, the curve axis of the Path3D
  75391. */
  75392. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  75393. /**
  75394. * Returns the Path3D array of successive Vector3 designing its curve.
  75395. * @returns the Path3D array of successive Vector3 designing its curve.
  75396. */
  75397. getCurve(): Vector3[];
  75398. /**
  75399. * Returns the Path3D array of successive Vector3 designing its curve.
  75400. * @returns the Path3D array of successive Vector3 designing its curve.
  75401. */
  75402. getPoints(): Vector3[];
  75403. /**
  75404. * @returns the computed length (float) of the path.
  75405. */
  75406. length(): number;
  75407. /**
  75408. * Returns an array populated with tangent vectors on each Path3D curve point.
  75409. * @returns an array populated with tangent vectors on each Path3D curve point.
  75410. */
  75411. getTangents(): Vector3[];
  75412. /**
  75413. * Returns an array populated with normal vectors on each Path3D curve point.
  75414. * @returns an array populated with normal vectors on each Path3D curve point.
  75415. */
  75416. getNormals(): Vector3[];
  75417. /**
  75418. * Returns an array populated with binormal vectors on each Path3D curve point.
  75419. * @returns an array populated with binormal vectors on each Path3D curve point.
  75420. */
  75421. getBinormals(): Vector3[];
  75422. /**
  75423. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75424. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75425. */
  75426. getDistances(): number[];
  75427. /**
  75428. * Returns an interpolated point along this path
  75429. * @param position the position of the point along this path, from 0.0 to 1.0
  75430. * @returns a new Vector3 as the point
  75431. */
  75432. getPointAt(position: number): Vector3;
  75433. /**
  75434. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75435. * @param position the position of the point along this path, from 0.0 to 1.0
  75436. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  75437. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  75438. */
  75439. getTangentAt(position: number, interpolated?: boolean): Vector3;
  75440. /**
  75441. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75442. * @param position the position of the point along this path, from 0.0 to 1.0
  75443. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  75444. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  75445. */
  75446. getNormalAt(position: number, interpolated?: boolean): Vector3;
  75447. /**
  75448. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  75449. * @param position the position of the point along this path, from 0.0 to 1.0
  75450. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  75451. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  75452. */
  75453. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  75454. /**
  75455. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  75456. * @param position the position of the point along this path, from 0.0 to 1.0
  75457. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  75458. */
  75459. getDistanceAt(position: number): number;
  75460. /**
  75461. * Returns the array index of the previous point of an interpolated point along this path
  75462. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75463. * @returns the array index
  75464. */
  75465. getPreviousPointIndexAt(position: number): number;
  75466. /**
  75467. * 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)
  75468. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75469. * @returns the sub position
  75470. */
  75471. getSubPositionAt(position: number): number;
  75472. /**
  75473. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  75474. * @param target the vector of which to get the closest position to
  75475. * @returns the position of the closest virtual point on this path to the target vector
  75476. */
  75477. getClosestPositionTo(target: Vector3): number;
  75478. /**
  75479. * Returns a sub path (slice) of this path
  75480. * @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
  75481. * @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
  75482. * @returns a sub path (slice) of this path
  75483. */
  75484. slice(start?: number, end?: number): Path3D;
  75485. /**
  75486. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75487. * @param path path which all values are copied into the curves points
  75488. * @param firstNormal which should be projected onto the curve
  75489. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  75490. * @returns the same object updated.
  75491. */
  75492. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  75493. private _compute;
  75494. private _getFirstNonNullVector;
  75495. private _getLastNonNullVector;
  75496. private _normalVector;
  75497. /**
  75498. * Updates the point at data for an interpolated point along this curve
  75499. * @param position the position of the point along this curve, from 0.0 to 1.0
  75500. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  75501. * @returns the (updated) point at data
  75502. */
  75503. private _updatePointAtData;
  75504. /**
  75505. * Updates the point at data from the specified parameters
  75506. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  75507. * @param point the interpolated point
  75508. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  75509. */
  75510. private _setPointAtData;
  75511. /**
  75512. * Updates the point at interpolation matrix for the tangents, normals and binormals
  75513. */
  75514. private _updateInterpolationMatrix;
  75515. }
  75516. /**
  75517. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75518. * A Curve3 is designed from a series of successive Vector3.
  75519. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  75520. */
  75521. export class Curve3 {
  75522. private _points;
  75523. private _length;
  75524. /**
  75525. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  75526. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  75527. * @param v1 (Vector3) the control point
  75528. * @param v2 (Vector3) the end point of the Quadratic Bezier
  75529. * @param nbPoints (integer) the wanted number of points in the curve
  75530. * @returns the created Curve3
  75531. */
  75532. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75533. /**
  75534. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  75535. * @param v0 (Vector3) the origin point of the Cubic Bezier
  75536. * @param v1 (Vector3) the first control point
  75537. * @param v2 (Vector3) the second control point
  75538. * @param v3 (Vector3) the end point of the Cubic Bezier
  75539. * @param nbPoints (integer) the wanted number of points in the curve
  75540. * @returns the created Curve3
  75541. */
  75542. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75543. /**
  75544. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  75545. * @param p1 (Vector3) the origin point of the Hermite Spline
  75546. * @param t1 (Vector3) the tangent vector at the origin point
  75547. * @param p2 (Vector3) the end point of the Hermite Spline
  75548. * @param t2 (Vector3) the tangent vector at the end point
  75549. * @param nbPoints (integer) the wanted number of points in the curve
  75550. * @returns the created Curve3
  75551. */
  75552. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75553. /**
  75554. * Returns a Curve3 object along a CatmullRom Spline curve :
  75555. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  75556. * @param nbPoints (integer) the wanted number of points between each curve control points
  75557. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  75558. * @returns the created Curve3
  75559. */
  75560. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  75561. /**
  75562. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75563. * A Curve3 is designed from a series of successive Vector3.
  75564. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  75565. * @param points points which make up the curve
  75566. */
  75567. constructor(points: Vector3[]);
  75568. /**
  75569. * @returns the Curve3 stored array of successive Vector3
  75570. */
  75571. getPoints(): Vector3[];
  75572. /**
  75573. * @returns the computed length (float) of the curve.
  75574. */
  75575. length(): number;
  75576. /**
  75577. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  75578. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  75579. * curveA and curveB keep unchanged.
  75580. * @param curve the curve to continue from this curve
  75581. * @returns the newly constructed curve
  75582. */
  75583. continue(curve: DeepImmutable<Curve3>): Curve3;
  75584. private _computeLength;
  75585. }
  75586. }
  75587. declare module BABYLON {
  75588. /**
  75589. * This represents the main contract an easing function should follow.
  75590. * Easing functions are used throughout the animation system.
  75591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75592. */
  75593. export interface IEasingFunction {
  75594. /**
  75595. * Given an input gradient between 0 and 1, this returns the corrseponding value
  75596. * of the easing function.
  75597. * The link below provides some of the most common examples of easing functions.
  75598. * @see https://easings.net/
  75599. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75600. * @returns the corresponding value on the curve defined by the easing function
  75601. */
  75602. ease(gradient: number): number;
  75603. }
  75604. /**
  75605. * Base class used for every default easing function.
  75606. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75607. */
  75608. export class EasingFunction implements IEasingFunction {
  75609. /**
  75610. * Interpolation follows the mathematical formula associated with the easing function.
  75611. */
  75612. static readonly EASINGMODE_EASEIN: number;
  75613. /**
  75614. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  75615. */
  75616. static readonly EASINGMODE_EASEOUT: number;
  75617. /**
  75618. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  75619. */
  75620. static readonly EASINGMODE_EASEINOUT: number;
  75621. private _easingMode;
  75622. /**
  75623. * Sets the easing mode of the current function.
  75624. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  75625. */
  75626. setEasingMode(easingMode: number): void;
  75627. /**
  75628. * Gets the current easing mode.
  75629. * @returns the easing mode
  75630. */
  75631. getEasingMode(): number;
  75632. /**
  75633. * @hidden
  75634. */
  75635. easeInCore(gradient: number): number;
  75636. /**
  75637. * Given an input gradient between 0 and 1, this returns the corresponding value
  75638. * of the easing function.
  75639. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75640. * @returns the corresponding value on the curve defined by the easing function
  75641. */
  75642. ease(gradient: number): number;
  75643. }
  75644. /**
  75645. * Easing function with a circle shape (see link below).
  75646. * @see https://easings.net/#easeInCirc
  75647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75648. */
  75649. export class CircleEase extends EasingFunction implements IEasingFunction {
  75650. /** @hidden */
  75651. easeInCore(gradient: number): number;
  75652. }
  75653. /**
  75654. * Easing function with a ease back shape (see link below).
  75655. * @see https://easings.net/#easeInBack
  75656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75657. */
  75658. export class BackEase extends EasingFunction implements IEasingFunction {
  75659. /** Defines the amplitude of the function */
  75660. amplitude: number;
  75661. /**
  75662. * Instantiates a back ease easing
  75663. * @see https://easings.net/#easeInBack
  75664. * @param amplitude Defines the amplitude of the function
  75665. */
  75666. constructor(
  75667. /** Defines the amplitude of the function */
  75668. amplitude?: number);
  75669. /** @hidden */
  75670. easeInCore(gradient: number): number;
  75671. }
  75672. /**
  75673. * Easing function with a bouncing shape (see link below).
  75674. * @see https://easings.net/#easeInBounce
  75675. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75676. */
  75677. export class BounceEase extends EasingFunction implements IEasingFunction {
  75678. /** Defines the number of bounces */
  75679. bounces: number;
  75680. /** Defines the amplitude of the bounce */
  75681. bounciness: number;
  75682. /**
  75683. * Instantiates a bounce easing
  75684. * @see https://easings.net/#easeInBounce
  75685. * @param bounces Defines the number of bounces
  75686. * @param bounciness Defines the amplitude of the bounce
  75687. */
  75688. constructor(
  75689. /** Defines the number of bounces */
  75690. bounces?: number,
  75691. /** Defines the amplitude of the bounce */
  75692. bounciness?: number);
  75693. /** @hidden */
  75694. easeInCore(gradient: number): number;
  75695. }
  75696. /**
  75697. * Easing function with a power of 3 shape (see link below).
  75698. * @see https://easings.net/#easeInCubic
  75699. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75700. */
  75701. export class CubicEase extends EasingFunction implements IEasingFunction {
  75702. /** @hidden */
  75703. easeInCore(gradient: number): number;
  75704. }
  75705. /**
  75706. * Easing function with an elastic shape (see link below).
  75707. * @see https://easings.net/#easeInElastic
  75708. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75709. */
  75710. export class ElasticEase extends EasingFunction implements IEasingFunction {
  75711. /** Defines the number of oscillations*/
  75712. oscillations: number;
  75713. /** Defines the amplitude of the oscillations*/
  75714. springiness: number;
  75715. /**
  75716. * Instantiates an elastic easing function
  75717. * @see https://easings.net/#easeInElastic
  75718. * @param oscillations Defines the number of oscillations
  75719. * @param springiness Defines the amplitude of the oscillations
  75720. */
  75721. constructor(
  75722. /** Defines the number of oscillations*/
  75723. oscillations?: number,
  75724. /** Defines the amplitude of the oscillations*/
  75725. springiness?: number);
  75726. /** @hidden */
  75727. easeInCore(gradient: number): number;
  75728. }
  75729. /**
  75730. * Easing function with an exponential shape (see link below).
  75731. * @see https://easings.net/#easeInExpo
  75732. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75733. */
  75734. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  75735. /** Defines the exponent of the function */
  75736. exponent: number;
  75737. /**
  75738. * Instantiates an exponential easing function
  75739. * @see https://easings.net/#easeInExpo
  75740. * @param exponent Defines the exponent of the function
  75741. */
  75742. constructor(
  75743. /** Defines the exponent of the function */
  75744. exponent?: number);
  75745. /** @hidden */
  75746. easeInCore(gradient: number): number;
  75747. }
  75748. /**
  75749. * Easing function with a power shape (see link below).
  75750. * @see https://easings.net/#easeInQuad
  75751. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75752. */
  75753. export class PowerEase extends EasingFunction implements IEasingFunction {
  75754. /** Defines the power of the function */
  75755. power: number;
  75756. /**
  75757. * Instantiates an power base easing function
  75758. * @see https://easings.net/#easeInQuad
  75759. * @param power Defines the power of the function
  75760. */
  75761. constructor(
  75762. /** Defines the power of the function */
  75763. power?: number);
  75764. /** @hidden */
  75765. easeInCore(gradient: number): number;
  75766. }
  75767. /**
  75768. * Easing function with a power of 2 shape (see link below).
  75769. * @see https://easings.net/#easeInQuad
  75770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75771. */
  75772. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  75773. /** @hidden */
  75774. easeInCore(gradient: number): number;
  75775. }
  75776. /**
  75777. * Easing function with a power of 4 shape (see link below).
  75778. * @see https://easings.net/#easeInQuart
  75779. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75780. */
  75781. export class QuarticEase extends EasingFunction implements IEasingFunction {
  75782. /** @hidden */
  75783. easeInCore(gradient: number): number;
  75784. }
  75785. /**
  75786. * Easing function with a power of 5 shape (see link below).
  75787. * @see https://easings.net/#easeInQuint
  75788. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75789. */
  75790. export class QuinticEase extends EasingFunction implements IEasingFunction {
  75791. /** @hidden */
  75792. easeInCore(gradient: number): number;
  75793. }
  75794. /**
  75795. * Easing function with a sin shape (see link below).
  75796. * @see https://easings.net/#easeInSine
  75797. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75798. */
  75799. export class SineEase extends EasingFunction implements IEasingFunction {
  75800. /** @hidden */
  75801. easeInCore(gradient: number): number;
  75802. }
  75803. /**
  75804. * Easing function with a bezier shape (see link below).
  75805. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75806. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75807. */
  75808. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  75809. /** Defines the x component of the start tangent in the bezier curve */
  75810. x1: number;
  75811. /** Defines the y component of the start tangent in the bezier curve */
  75812. y1: number;
  75813. /** Defines the x component of the end tangent in the bezier curve */
  75814. x2: number;
  75815. /** Defines the y component of the end tangent in the bezier curve */
  75816. y2: number;
  75817. /**
  75818. * Instantiates a bezier function
  75819. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75820. * @param x1 Defines the x component of the start tangent in the bezier curve
  75821. * @param y1 Defines the y component of the start tangent in the bezier curve
  75822. * @param x2 Defines the x component of the end tangent in the bezier curve
  75823. * @param y2 Defines the y component of the end tangent in the bezier curve
  75824. */
  75825. constructor(
  75826. /** Defines the x component of the start tangent in the bezier curve */
  75827. x1?: number,
  75828. /** Defines the y component of the start tangent in the bezier curve */
  75829. y1?: number,
  75830. /** Defines the x component of the end tangent in the bezier curve */
  75831. x2?: number,
  75832. /** Defines the y component of the end tangent in the bezier curve */
  75833. y2?: number);
  75834. /** @hidden */
  75835. easeInCore(gradient: number): number;
  75836. }
  75837. }
  75838. declare module BABYLON {
  75839. /**
  75840. * Class used to hold a RBG color
  75841. */
  75842. export class Color3 {
  75843. /**
  75844. * Defines the red component (between 0 and 1, default is 0)
  75845. */
  75846. r: number;
  75847. /**
  75848. * Defines the green component (between 0 and 1, default is 0)
  75849. */
  75850. g: number;
  75851. /**
  75852. * Defines the blue component (between 0 and 1, default is 0)
  75853. */
  75854. b: number;
  75855. /**
  75856. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  75857. * @param r defines the red component (between 0 and 1, default is 0)
  75858. * @param g defines the green component (between 0 and 1, default is 0)
  75859. * @param b defines the blue component (between 0 and 1, default is 0)
  75860. */
  75861. constructor(
  75862. /**
  75863. * Defines the red component (between 0 and 1, default is 0)
  75864. */
  75865. r?: number,
  75866. /**
  75867. * Defines the green component (between 0 and 1, default is 0)
  75868. */
  75869. g?: number,
  75870. /**
  75871. * Defines the blue component (between 0 and 1, default is 0)
  75872. */
  75873. b?: number);
  75874. /**
  75875. * Creates a string with the Color3 current values
  75876. * @returns the string representation of the Color3 object
  75877. */
  75878. toString(): string;
  75879. /**
  75880. * Returns the string "Color3"
  75881. * @returns "Color3"
  75882. */
  75883. getClassName(): string;
  75884. /**
  75885. * Compute the Color3 hash code
  75886. * @returns an unique number that can be used to hash Color3 objects
  75887. */
  75888. getHashCode(): number;
  75889. /**
  75890. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  75891. * @param array defines the array where to store the r,g,b components
  75892. * @param index defines an optional index in the target array to define where to start storing values
  75893. * @returns the current Color3 object
  75894. */
  75895. toArray(array: FloatArray, index?: number): Color3;
  75896. /**
  75897. * Returns a new Color4 object from the current Color3 and the given alpha
  75898. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  75899. * @returns a new Color4 object
  75900. */
  75901. toColor4(alpha?: number): Color4;
  75902. /**
  75903. * Returns a new array populated with 3 numeric elements : red, green and blue values
  75904. * @returns the new array
  75905. */
  75906. asArray(): number[];
  75907. /**
  75908. * Returns the luminance value
  75909. * @returns a float value
  75910. */
  75911. toLuminance(): number;
  75912. /**
  75913. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  75914. * @param otherColor defines the second operand
  75915. * @returns the new Color3 object
  75916. */
  75917. multiply(otherColor: DeepImmutable<Color3>): Color3;
  75918. /**
  75919. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  75920. * @param otherColor defines the second operand
  75921. * @param result defines the Color3 object where to store the result
  75922. * @returns the current Color3
  75923. */
  75924. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75925. /**
  75926. * Determines equality between Color3 objects
  75927. * @param otherColor defines the second operand
  75928. * @returns true if the rgb values are equal to the given ones
  75929. */
  75930. equals(otherColor: DeepImmutable<Color3>): boolean;
  75931. /**
  75932. * Determines equality between the current Color3 object and a set of r,b,g values
  75933. * @param r defines the red component to check
  75934. * @param g defines the green component to check
  75935. * @param b defines the blue component to check
  75936. * @returns true if the rgb values are equal to the given ones
  75937. */
  75938. equalsFloats(r: number, g: number, b: number): boolean;
  75939. /**
  75940. * Multiplies in place each rgb value by scale
  75941. * @param scale defines the scaling factor
  75942. * @returns the updated Color3
  75943. */
  75944. scale(scale: number): Color3;
  75945. /**
  75946. * Multiplies the rgb values by scale and stores the result into "result"
  75947. * @param scale defines the scaling factor
  75948. * @param result defines the Color3 object where to store the result
  75949. * @returns the unmodified current Color3
  75950. */
  75951. scaleToRef(scale: number, result: Color3): Color3;
  75952. /**
  75953. * Scale the current Color3 values by a factor and add the result to a given Color3
  75954. * @param scale defines the scale factor
  75955. * @param result defines color to store the result into
  75956. * @returns the unmodified current Color3
  75957. */
  75958. scaleAndAddToRef(scale: number, result: Color3): Color3;
  75959. /**
  75960. * Clamps the rgb values by the min and max values and stores the result into "result"
  75961. * @param min defines minimum clamping value (default is 0)
  75962. * @param max defines maximum clamping value (default is 1)
  75963. * @param result defines color to store the result into
  75964. * @returns the original Color3
  75965. */
  75966. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  75967. /**
  75968. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  75969. * @param otherColor defines the second operand
  75970. * @returns the new Color3
  75971. */
  75972. add(otherColor: DeepImmutable<Color3>): Color3;
  75973. /**
  75974. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  75975. * @param otherColor defines the second operand
  75976. * @param result defines Color3 object to store the result into
  75977. * @returns the unmodified current Color3
  75978. */
  75979. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75980. /**
  75981. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  75982. * @param otherColor defines the second operand
  75983. * @returns the new Color3
  75984. */
  75985. subtract(otherColor: DeepImmutable<Color3>): Color3;
  75986. /**
  75987. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  75988. * @param otherColor defines the second operand
  75989. * @param result defines Color3 object to store the result into
  75990. * @returns the unmodified current Color3
  75991. */
  75992. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75993. /**
  75994. * Copy the current object
  75995. * @returns a new Color3 copied the current one
  75996. */
  75997. clone(): Color3;
  75998. /**
  75999. * Copies the rgb values from the source in the current Color3
  76000. * @param source defines the source Color3 object
  76001. * @returns the updated Color3 object
  76002. */
  76003. copyFrom(source: DeepImmutable<Color3>): Color3;
  76004. /**
  76005. * Updates the Color3 rgb values from the given floats
  76006. * @param r defines the red component to read from
  76007. * @param g defines the green component to read from
  76008. * @param b defines the blue component to read from
  76009. * @returns the current Color3 object
  76010. */
  76011. copyFromFloats(r: number, g: number, b: number): Color3;
  76012. /**
  76013. * Updates the Color3 rgb values from the given floats
  76014. * @param r defines the red component to read from
  76015. * @param g defines the green component to read from
  76016. * @param b defines the blue component to read from
  76017. * @returns the current Color3 object
  76018. */
  76019. set(r: number, g: number, b: number): Color3;
  76020. /**
  76021. * Compute the Color3 hexadecimal code as a string
  76022. * @returns a string containing the hexadecimal representation of the Color3 object
  76023. */
  76024. toHexString(): string;
  76025. /**
  76026. * Computes a new Color3 converted from the current one to linear space
  76027. * @returns a new Color3 object
  76028. */
  76029. toLinearSpace(): Color3;
  76030. /**
  76031. * Converts current color in rgb space to HSV values
  76032. * @returns a new color3 representing the HSV values
  76033. */
  76034. toHSV(): Color3;
  76035. /**
  76036. * Converts current color in rgb space to HSV values
  76037. * @param result defines the Color3 where to store the HSV values
  76038. */
  76039. toHSVToRef(result: Color3): void;
  76040. /**
  76041. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76042. * @param convertedColor defines the Color3 object where to store the linear space version
  76043. * @returns the unmodified Color3
  76044. */
  76045. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76046. /**
  76047. * Computes a new Color3 converted from the current one to gamma space
  76048. * @returns a new Color3 object
  76049. */
  76050. toGammaSpace(): Color3;
  76051. /**
  76052. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76053. * @param convertedColor defines the Color3 object where to store the gamma space version
  76054. * @returns the unmodified Color3
  76055. */
  76056. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76057. private static _BlackReadOnly;
  76058. /**
  76059. * Convert Hue, saturation and value to a Color3 (RGB)
  76060. * @param hue defines the hue
  76061. * @param saturation defines the saturation
  76062. * @param value defines the value
  76063. * @param result defines the Color3 where to store the RGB values
  76064. */
  76065. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76066. /**
  76067. * Creates a new Color3 from the string containing valid hexadecimal values
  76068. * @param hex defines a string containing valid hexadecimal values
  76069. * @returns a new Color3 object
  76070. */
  76071. static FromHexString(hex: string): Color3;
  76072. /**
  76073. * Creates a new Color3 from the starting index of the given array
  76074. * @param array defines the source array
  76075. * @param offset defines an offset in the source array
  76076. * @returns a new Color3 object
  76077. */
  76078. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76079. /**
  76080. * Creates a new Color3 from integer values (< 256)
  76081. * @param r defines the red component to read from (value between 0 and 255)
  76082. * @param g defines the green component to read from (value between 0 and 255)
  76083. * @param b defines the blue component to read from (value between 0 and 255)
  76084. * @returns a new Color3 object
  76085. */
  76086. static FromInts(r: number, g: number, b: number): Color3;
  76087. /**
  76088. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76089. * @param start defines the start Color3 value
  76090. * @param end defines the end Color3 value
  76091. * @param amount defines the gradient value between start and end
  76092. * @returns a new Color3 object
  76093. */
  76094. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76095. /**
  76096. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76097. * @param left defines the start value
  76098. * @param right defines the end value
  76099. * @param amount defines the gradient factor
  76100. * @param result defines the Color3 object where to store the result
  76101. */
  76102. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76103. /**
  76104. * Returns a Color3 value containing a red color
  76105. * @returns a new Color3 object
  76106. */
  76107. static Red(): Color3;
  76108. /**
  76109. * Returns a Color3 value containing a green color
  76110. * @returns a new Color3 object
  76111. */
  76112. static Green(): Color3;
  76113. /**
  76114. * Returns a Color3 value containing a blue color
  76115. * @returns a new Color3 object
  76116. */
  76117. static Blue(): Color3;
  76118. /**
  76119. * Returns a Color3 value containing a black color
  76120. * @returns a new Color3 object
  76121. */
  76122. static Black(): Color3;
  76123. /**
  76124. * Gets a Color3 value containing a black color that must not be updated
  76125. */
  76126. static get BlackReadOnly(): DeepImmutable<Color3>;
  76127. /**
  76128. * Returns a Color3 value containing a white color
  76129. * @returns a new Color3 object
  76130. */
  76131. static White(): Color3;
  76132. /**
  76133. * Returns a Color3 value containing a purple color
  76134. * @returns a new Color3 object
  76135. */
  76136. static Purple(): Color3;
  76137. /**
  76138. * Returns a Color3 value containing a magenta color
  76139. * @returns a new Color3 object
  76140. */
  76141. static Magenta(): Color3;
  76142. /**
  76143. * Returns a Color3 value containing a yellow color
  76144. * @returns a new Color3 object
  76145. */
  76146. static Yellow(): Color3;
  76147. /**
  76148. * Returns a Color3 value containing a gray color
  76149. * @returns a new Color3 object
  76150. */
  76151. static Gray(): Color3;
  76152. /**
  76153. * Returns a Color3 value containing a teal color
  76154. * @returns a new Color3 object
  76155. */
  76156. static Teal(): Color3;
  76157. /**
  76158. * Returns a Color3 value containing a random color
  76159. * @returns a new Color3 object
  76160. */
  76161. static Random(): Color3;
  76162. }
  76163. /**
  76164. * Class used to hold a RBGA color
  76165. */
  76166. export class Color4 {
  76167. /**
  76168. * Defines the red component (between 0 and 1, default is 0)
  76169. */
  76170. r: number;
  76171. /**
  76172. * Defines the green component (between 0 and 1, default is 0)
  76173. */
  76174. g: number;
  76175. /**
  76176. * Defines the blue component (between 0 and 1, default is 0)
  76177. */
  76178. b: number;
  76179. /**
  76180. * Defines the alpha component (between 0 and 1, default is 1)
  76181. */
  76182. a: number;
  76183. /**
  76184. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  76185. * @param r defines the red component (between 0 and 1, default is 0)
  76186. * @param g defines the green component (between 0 and 1, default is 0)
  76187. * @param b defines the blue component (between 0 and 1, default is 0)
  76188. * @param a defines the alpha component (between 0 and 1, default is 1)
  76189. */
  76190. constructor(
  76191. /**
  76192. * Defines the red component (between 0 and 1, default is 0)
  76193. */
  76194. r?: number,
  76195. /**
  76196. * Defines the green component (between 0 and 1, default is 0)
  76197. */
  76198. g?: number,
  76199. /**
  76200. * Defines the blue component (between 0 and 1, default is 0)
  76201. */
  76202. b?: number,
  76203. /**
  76204. * Defines the alpha component (between 0 and 1, default is 1)
  76205. */
  76206. a?: number);
  76207. /**
  76208. * Adds in place the given Color4 values to the current Color4 object
  76209. * @param right defines the second operand
  76210. * @returns the current updated Color4 object
  76211. */
  76212. addInPlace(right: DeepImmutable<Color4>): Color4;
  76213. /**
  76214. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  76215. * @returns the new array
  76216. */
  76217. asArray(): number[];
  76218. /**
  76219. * Stores from the starting index in the given array the Color4 successive values
  76220. * @param array defines the array where to store the r,g,b components
  76221. * @param index defines an optional index in the target array to define where to start storing values
  76222. * @returns the current Color4 object
  76223. */
  76224. toArray(array: number[], index?: number): Color4;
  76225. /**
  76226. * Determines equality between Color4 objects
  76227. * @param otherColor defines the second operand
  76228. * @returns true if the rgba values are equal to the given ones
  76229. */
  76230. equals(otherColor: DeepImmutable<Color4>): boolean;
  76231. /**
  76232. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  76233. * @param right defines the second operand
  76234. * @returns a new Color4 object
  76235. */
  76236. add(right: DeepImmutable<Color4>): Color4;
  76237. /**
  76238. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  76239. * @param right defines the second operand
  76240. * @returns a new Color4 object
  76241. */
  76242. subtract(right: DeepImmutable<Color4>): Color4;
  76243. /**
  76244. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  76245. * @param right defines the second operand
  76246. * @param result defines the Color4 object where to store the result
  76247. * @returns the current Color4 object
  76248. */
  76249. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  76250. /**
  76251. * Creates a new Color4 with the current Color4 values multiplied by scale
  76252. * @param scale defines the scaling factor to apply
  76253. * @returns a new Color4 object
  76254. */
  76255. scale(scale: number): Color4;
  76256. /**
  76257. * Multiplies the current Color4 values by scale and stores the result in "result"
  76258. * @param scale defines the scaling factor to apply
  76259. * @param result defines the Color4 object where to store the result
  76260. * @returns the current unmodified Color4
  76261. */
  76262. scaleToRef(scale: number, result: Color4): Color4;
  76263. /**
  76264. * Scale the current Color4 values by a factor and add the result to a given Color4
  76265. * @param scale defines the scale factor
  76266. * @param result defines the Color4 object where to store the result
  76267. * @returns the unmodified current Color4
  76268. */
  76269. scaleAndAddToRef(scale: number, result: Color4): Color4;
  76270. /**
  76271. * Clamps the rgb values by the min and max values and stores the result into "result"
  76272. * @param min defines minimum clamping value (default is 0)
  76273. * @param max defines maximum clamping value (default is 1)
  76274. * @param result defines color to store the result into.
  76275. * @returns the cuurent Color4
  76276. */
  76277. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  76278. /**
  76279. * Multipy an Color4 value by another and return a new Color4 object
  76280. * @param color defines the Color4 value to multiply by
  76281. * @returns a new Color4 object
  76282. */
  76283. multiply(color: Color4): Color4;
  76284. /**
  76285. * Multipy a Color4 value by another and push the result in a reference value
  76286. * @param color defines the Color4 value to multiply by
  76287. * @param result defines the Color4 to fill the result in
  76288. * @returns the result Color4
  76289. */
  76290. multiplyToRef(color: Color4, result: Color4): Color4;
  76291. /**
  76292. * Creates a string with the Color4 current values
  76293. * @returns the string representation of the Color4 object
  76294. */
  76295. toString(): string;
  76296. /**
  76297. * Returns the string "Color4"
  76298. * @returns "Color4"
  76299. */
  76300. getClassName(): string;
  76301. /**
  76302. * Compute the Color4 hash code
  76303. * @returns an unique number that can be used to hash Color4 objects
  76304. */
  76305. getHashCode(): number;
  76306. /**
  76307. * Creates a new Color4 copied from the current one
  76308. * @returns a new Color4 object
  76309. */
  76310. clone(): Color4;
  76311. /**
  76312. * Copies the given Color4 values into the current one
  76313. * @param source defines the source Color4 object
  76314. * @returns the current updated Color4 object
  76315. */
  76316. copyFrom(source: Color4): Color4;
  76317. /**
  76318. * Copies the given float values into the current one
  76319. * @param r defines the red component to read from
  76320. * @param g defines the green component to read from
  76321. * @param b defines the blue component to read from
  76322. * @param a defines the alpha component to read from
  76323. * @returns the current updated Color4 object
  76324. */
  76325. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  76326. /**
  76327. * Copies the given float values into the current one
  76328. * @param r defines the red component to read from
  76329. * @param g defines the green component to read from
  76330. * @param b defines the blue component to read from
  76331. * @param a defines the alpha component to read from
  76332. * @returns the current updated Color4 object
  76333. */
  76334. set(r: number, g: number, b: number, a: number): Color4;
  76335. /**
  76336. * Compute the Color4 hexadecimal code as a string
  76337. * @returns a string containing the hexadecimal representation of the Color4 object
  76338. */
  76339. toHexString(): string;
  76340. /**
  76341. * Computes a new Color4 converted from the current one to linear space
  76342. * @returns a new Color4 object
  76343. */
  76344. toLinearSpace(): Color4;
  76345. /**
  76346. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  76347. * @param convertedColor defines the Color4 object where to store the linear space version
  76348. * @returns the unmodified Color4
  76349. */
  76350. toLinearSpaceToRef(convertedColor: Color4): Color4;
  76351. /**
  76352. * Computes a new Color4 converted from the current one to gamma space
  76353. * @returns a new Color4 object
  76354. */
  76355. toGammaSpace(): Color4;
  76356. /**
  76357. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  76358. * @param convertedColor defines the Color4 object where to store the gamma space version
  76359. * @returns the unmodified Color4
  76360. */
  76361. toGammaSpaceToRef(convertedColor: Color4): Color4;
  76362. /**
  76363. * Creates a new Color4 from the string containing valid hexadecimal values
  76364. * @param hex defines a string containing valid hexadecimal values
  76365. * @returns a new Color4 object
  76366. */
  76367. static FromHexString(hex: string): Color4;
  76368. /**
  76369. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76370. * @param left defines the start value
  76371. * @param right defines the end value
  76372. * @param amount defines the gradient factor
  76373. * @returns a new Color4 object
  76374. */
  76375. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  76376. /**
  76377. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76378. * @param left defines the start value
  76379. * @param right defines the end value
  76380. * @param amount defines the gradient factor
  76381. * @param result defines the Color4 object where to store data
  76382. */
  76383. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  76384. /**
  76385. * Creates a new Color4 from a Color3 and an alpha value
  76386. * @param color3 defines the source Color3 to read from
  76387. * @param alpha defines the alpha component (1.0 by default)
  76388. * @returns a new Color4 object
  76389. */
  76390. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  76391. /**
  76392. * Creates a new Color4 from the starting index element of the given array
  76393. * @param array defines the source array to read from
  76394. * @param offset defines the offset in the source array
  76395. * @returns a new Color4 object
  76396. */
  76397. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  76398. /**
  76399. * Creates a new Color3 from integer values (< 256)
  76400. * @param r defines the red component to read from (value between 0 and 255)
  76401. * @param g defines the green component to read from (value between 0 and 255)
  76402. * @param b defines the blue component to read from (value between 0 and 255)
  76403. * @param a defines the alpha component to read from (value between 0 and 255)
  76404. * @returns a new Color3 object
  76405. */
  76406. static FromInts(r: number, g: number, b: number, a: number): Color4;
  76407. /**
  76408. * Check the content of a given array and convert it to an array containing RGBA data
  76409. * If the original array was already containing count * 4 values then it is returned directly
  76410. * @param colors defines the array to check
  76411. * @param count defines the number of RGBA data to expect
  76412. * @returns an array containing count * 4 values (RGBA)
  76413. */
  76414. static CheckColors4(colors: number[], count: number): number[];
  76415. }
  76416. /**
  76417. * @hidden
  76418. */
  76419. export class TmpColors {
  76420. static Color3: Color3[];
  76421. static Color4: Color4[];
  76422. }
  76423. }
  76424. declare module BABYLON {
  76425. /**
  76426. * Defines an interface which represents an animation key frame
  76427. */
  76428. export interface IAnimationKey {
  76429. /**
  76430. * Frame of the key frame
  76431. */
  76432. frame: number;
  76433. /**
  76434. * Value at the specifies key frame
  76435. */
  76436. value: any;
  76437. /**
  76438. * The input tangent for the cubic hermite spline
  76439. */
  76440. inTangent?: any;
  76441. /**
  76442. * The output tangent for the cubic hermite spline
  76443. */
  76444. outTangent?: any;
  76445. /**
  76446. * The animation interpolation type
  76447. */
  76448. interpolation?: AnimationKeyInterpolation;
  76449. }
  76450. /**
  76451. * Enum for the animation key frame interpolation type
  76452. */
  76453. export enum AnimationKeyInterpolation {
  76454. /**
  76455. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  76456. */
  76457. STEP = 1
  76458. }
  76459. }
  76460. declare module BABYLON {
  76461. /**
  76462. * Represents the range of an animation
  76463. */
  76464. export class AnimationRange {
  76465. /**The name of the animation range**/
  76466. name: string;
  76467. /**The starting frame of the animation */
  76468. from: number;
  76469. /**The ending frame of the animation*/
  76470. to: number;
  76471. /**
  76472. * Initializes the range of an animation
  76473. * @param name The name of the animation range
  76474. * @param from The starting frame of the animation
  76475. * @param to The ending frame of the animation
  76476. */
  76477. constructor(
  76478. /**The name of the animation range**/
  76479. name: string,
  76480. /**The starting frame of the animation */
  76481. from: number,
  76482. /**The ending frame of the animation*/
  76483. to: number);
  76484. /**
  76485. * Makes a copy of the animation range
  76486. * @returns A copy of the animation range
  76487. */
  76488. clone(): AnimationRange;
  76489. }
  76490. }
  76491. declare module BABYLON {
  76492. /**
  76493. * Composed of a frame, and an action function
  76494. */
  76495. export class AnimationEvent {
  76496. /** The frame for which the event is triggered **/
  76497. frame: number;
  76498. /** The event to perform when triggered **/
  76499. action: (currentFrame: number) => void;
  76500. /** Specifies if the event should be triggered only once**/
  76501. onlyOnce?: boolean | undefined;
  76502. /**
  76503. * Specifies if the animation event is done
  76504. */
  76505. isDone: boolean;
  76506. /**
  76507. * Initializes the animation event
  76508. * @param frame The frame for which the event is triggered
  76509. * @param action The event to perform when triggered
  76510. * @param onlyOnce Specifies if the event should be triggered only once
  76511. */
  76512. constructor(
  76513. /** The frame for which the event is triggered **/
  76514. frame: number,
  76515. /** The event to perform when triggered **/
  76516. action: (currentFrame: number) => void,
  76517. /** Specifies if the event should be triggered only once**/
  76518. onlyOnce?: boolean | undefined);
  76519. /** @hidden */
  76520. _clone(): AnimationEvent;
  76521. }
  76522. }
  76523. declare module BABYLON {
  76524. /**
  76525. * Interface used to define a behavior
  76526. */
  76527. export interface Behavior<T> {
  76528. /** gets or sets behavior's name */
  76529. name: string;
  76530. /**
  76531. * Function called when the behavior needs to be initialized (after attaching it to a target)
  76532. */
  76533. init(): void;
  76534. /**
  76535. * Called when the behavior is attached to a target
  76536. * @param target defines the target where the behavior is attached to
  76537. */
  76538. attach(target: T): void;
  76539. /**
  76540. * Called when the behavior is detached from its target
  76541. */
  76542. detach(): void;
  76543. }
  76544. /**
  76545. * Interface implemented by classes supporting behaviors
  76546. */
  76547. export interface IBehaviorAware<T> {
  76548. /**
  76549. * Attach a behavior
  76550. * @param behavior defines the behavior to attach
  76551. * @returns the current host
  76552. */
  76553. addBehavior(behavior: Behavior<T>): T;
  76554. /**
  76555. * Remove a behavior from the current object
  76556. * @param behavior defines the behavior to detach
  76557. * @returns the current host
  76558. */
  76559. removeBehavior(behavior: Behavior<T>): T;
  76560. /**
  76561. * Gets a behavior using its name to search
  76562. * @param name defines the name to search
  76563. * @returns the behavior or null if not found
  76564. */
  76565. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  76566. }
  76567. }
  76568. declare module BABYLON {
  76569. /**
  76570. * Defines an array and its length.
  76571. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  76572. */
  76573. export interface ISmartArrayLike<T> {
  76574. /**
  76575. * The data of the array.
  76576. */
  76577. data: Array<T>;
  76578. /**
  76579. * The active length of the array.
  76580. */
  76581. length: number;
  76582. }
  76583. /**
  76584. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76585. */
  76586. export class SmartArray<T> implements ISmartArrayLike<T> {
  76587. /**
  76588. * The full set of data from the array.
  76589. */
  76590. data: Array<T>;
  76591. /**
  76592. * The active length of the array.
  76593. */
  76594. length: number;
  76595. protected _id: number;
  76596. /**
  76597. * Instantiates a Smart Array.
  76598. * @param capacity defines the default capacity of the array.
  76599. */
  76600. constructor(capacity: number);
  76601. /**
  76602. * Pushes a value at the end of the active data.
  76603. * @param value defines the object to push in the array.
  76604. */
  76605. push(value: T): void;
  76606. /**
  76607. * Iterates over the active data and apply the lambda to them.
  76608. * @param func defines the action to apply on each value.
  76609. */
  76610. forEach(func: (content: T) => void): void;
  76611. /**
  76612. * Sorts the full sets of data.
  76613. * @param compareFn defines the comparison function to apply.
  76614. */
  76615. sort(compareFn: (a: T, b: T) => number): void;
  76616. /**
  76617. * Resets the active data to an empty array.
  76618. */
  76619. reset(): void;
  76620. /**
  76621. * Releases all the data from the array as well as the array.
  76622. */
  76623. dispose(): void;
  76624. /**
  76625. * Concats the active data with a given array.
  76626. * @param array defines the data to concatenate with.
  76627. */
  76628. concat(array: any): void;
  76629. /**
  76630. * Returns the position of a value in the active data.
  76631. * @param value defines the value to find the index for
  76632. * @returns the index if found in the active data otherwise -1
  76633. */
  76634. indexOf(value: T): number;
  76635. /**
  76636. * Returns whether an element is part of the active data.
  76637. * @param value defines the value to look for
  76638. * @returns true if found in the active data otherwise false
  76639. */
  76640. contains(value: T): boolean;
  76641. private static _GlobalId;
  76642. }
  76643. /**
  76644. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76645. * The data in this array can only be present once
  76646. */
  76647. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  76648. private _duplicateId;
  76649. /**
  76650. * Pushes a value at the end of the active data.
  76651. * THIS DOES NOT PREVENT DUPPLICATE DATA
  76652. * @param value defines the object to push in the array.
  76653. */
  76654. push(value: T): void;
  76655. /**
  76656. * Pushes a value at the end of the active data.
  76657. * If the data is already present, it won t be added again
  76658. * @param value defines the object to push in the array.
  76659. * @returns true if added false if it was already present
  76660. */
  76661. pushNoDuplicate(value: T): boolean;
  76662. /**
  76663. * Resets the active data to an empty array.
  76664. */
  76665. reset(): void;
  76666. /**
  76667. * Concats the active data with a given array.
  76668. * This ensures no dupplicate will be present in the result.
  76669. * @param array defines the data to concatenate with.
  76670. */
  76671. concatWithNoDuplicate(array: any): void;
  76672. }
  76673. }
  76674. declare module BABYLON {
  76675. /**
  76676. * @ignore
  76677. * This is a list of all the different input types that are available in the application.
  76678. * Fo instance: ArcRotateCameraGamepadInput...
  76679. */
  76680. export var CameraInputTypes: {};
  76681. /**
  76682. * This is the contract to implement in order to create a new input class.
  76683. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  76684. */
  76685. export interface ICameraInput<TCamera extends Camera> {
  76686. /**
  76687. * Defines the camera the input is attached to.
  76688. */
  76689. camera: Nullable<TCamera>;
  76690. /**
  76691. * Gets the class name of the current intput.
  76692. * @returns the class name
  76693. */
  76694. getClassName(): string;
  76695. /**
  76696. * Get the friendly name associated with the input class.
  76697. * @returns the input friendly name
  76698. */
  76699. getSimpleName(): string;
  76700. /**
  76701. * Attach the input controls to a specific dom element to get the input from.
  76702. * @param element Defines the element the controls should be listened from
  76703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76704. */
  76705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76706. /**
  76707. * Detach the current controls from the specified dom element.
  76708. * @param element Defines the element to stop listening the inputs from
  76709. */
  76710. detachControl(element: Nullable<HTMLElement>): void;
  76711. /**
  76712. * Update the current camera state depending on the inputs that have been used this frame.
  76713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76714. */
  76715. checkInputs?: () => void;
  76716. }
  76717. /**
  76718. * Represents a map of input types to input instance or input index to input instance.
  76719. */
  76720. export interface CameraInputsMap<TCamera extends Camera> {
  76721. /**
  76722. * Accessor to the input by input type.
  76723. */
  76724. [name: string]: ICameraInput<TCamera>;
  76725. /**
  76726. * Accessor to the input by input index.
  76727. */
  76728. [idx: number]: ICameraInput<TCamera>;
  76729. }
  76730. /**
  76731. * This represents the input manager used within a camera.
  76732. * It helps dealing with all the different kind of input attached to a camera.
  76733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76734. */
  76735. export class CameraInputsManager<TCamera extends Camera> {
  76736. /**
  76737. * Defines the list of inputs attahed to the camera.
  76738. */
  76739. attached: CameraInputsMap<TCamera>;
  76740. /**
  76741. * Defines the dom element the camera is collecting inputs from.
  76742. * This is null if the controls have not been attached.
  76743. */
  76744. attachedElement: Nullable<HTMLElement>;
  76745. /**
  76746. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76747. */
  76748. noPreventDefault: boolean;
  76749. /**
  76750. * Defined the camera the input manager belongs to.
  76751. */
  76752. camera: TCamera;
  76753. /**
  76754. * Update the current camera state depending on the inputs that have been used this frame.
  76755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76756. */
  76757. checkInputs: () => void;
  76758. /**
  76759. * Instantiate a new Camera Input Manager.
  76760. * @param camera Defines the camera the input manager blongs to
  76761. */
  76762. constructor(camera: TCamera);
  76763. /**
  76764. * Add an input method to a camera
  76765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76766. * @param input camera input method
  76767. */
  76768. add(input: ICameraInput<TCamera>): void;
  76769. /**
  76770. * Remove a specific input method from a camera
  76771. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  76772. * @param inputToRemove camera input method
  76773. */
  76774. remove(inputToRemove: ICameraInput<TCamera>): void;
  76775. /**
  76776. * Remove a specific input type from a camera
  76777. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  76778. * @param inputType the type of the input to remove
  76779. */
  76780. removeByType(inputType: string): void;
  76781. private _addCheckInputs;
  76782. /**
  76783. * Attach the input controls to the currently attached dom element to listen the events from.
  76784. * @param input Defines the input to attach
  76785. */
  76786. attachInput(input: ICameraInput<TCamera>): void;
  76787. /**
  76788. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  76789. * @param element Defines the dom element to collect the events from
  76790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76791. */
  76792. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  76793. /**
  76794. * Detach the current manager inputs controls from a specific dom element.
  76795. * @param element Defines the dom element to collect the events from
  76796. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  76797. */
  76798. detachElement(element: HTMLElement, disconnect?: boolean): void;
  76799. /**
  76800. * Rebuild the dynamic inputCheck function from the current list of
  76801. * defined inputs in the manager.
  76802. */
  76803. rebuildInputCheck(): void;
  76804. /**
  76805. * Remove all attached input methods from a camera
  76806. */
  76807. clear(): void;
  76808. /**
  76809. * Serialize the current input manager attached to a camera.
  76810. * This ensures than once parsed,
  76811. * the input associated to the camera will be identical to the current ones
  76812. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  76813. */
  76814. serialize(serializedCamera: any): void;
  76815. /**
  76816. * Parses an input manager serialized JSON to restore the previous list of inputs
  76817. * and states associated to a camera.
  76818. * @param parsedCamera Defines the JSON to parse
  76819. */
  76820. parse(parsedCamera: any): void;
  76821. }
  76822. }
  76823. declare module BABYLON {
  76824. /**
  76825. * Class used to store data that will be store in GPU memory
  76826. */
  76827. export class Buffer {
  76828. private _engine;
  76829. private _buffer;
  76830. /** @hidden */
  76831. _data: Nullable<DataArray>;
  76832. private _updatable;
  76833. private _instanced;
  76834. private _divisor;
  76835. /**
  76836. * Gets the byte stride.
  76837. */
  76838. readonly byteStride: number;
  76839. /**
  76840. * Constructor
  76841. * @param engine the engine
  76842. * @param data the data to use for this buffer
  76843. * @param updatable whether the data is updatable
  76844. * @param stride the stride (optional)
  76845. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76846. * @param instanced whether the buffer is instanced (optional)
  76847. * @param useBytes set to true if the stride in in bytes (optional)
  76848. * @param divisor sets an optional divisor for instances (1 by default)
  76849. */
  76850. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  76851. /**
  76852. * Create a new VertexBuffer based on the current buffer
  76853. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76854. * @param offset defines offset in the buffer (0 by default)
  76855. * @param size defines the size in floats of attributes (position is 3 for instance)
  76856. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76857. * @param instanced defines if the vertex buffer contains indexed data
  76858. * @param useBytes defines if the offset and stride are in bytes *
  76859. * @param divisor sets an optional divisor for instances (1 by default)
  76860. * @returns the new vertex buffer
  76861. */
  76862. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  76863. /**
  76864. * Gets a boolean indicating if the Buffer is updatable?
  76865. * @returns true if the buffer is updatable
  76866. */
  76867. isUpdatable(): boolean;
  76868. /**
  76869. * Gets current buffer's data
  76870. * @returns a DataArray or null
  76871. */
  76872. getData(): Nullable<DataArray>;
  76873. /**
  76874. * Gets underlying native buffer
  76875. * @returns underlying native buffer
  76876. */
  76877. getBuffer(): Nullable<DataBuffer>;
  76878. /**
  76879. * Gets the stride in float32 units (i.e. byte stride / 4).
  76880. * May not be an integer if the byte stride is not divisible by 4.
  76881. * @returns the stride in float32 units
  76882. * @deprecated Please use byteStride instead.
  76883. */
  76884. getStrideSize(): number;
  76885. /**
  76886. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76887. * @param data defines the data to store
  76888. */
  76889. create(data?: Nullable<DataArray>): void;
  76890. /** @hidden */
  76891. _rebuild(): void;
  76892. /**
  76893. * Update current buffer data
  76894. * @param data defines the data to store
  76895. */
  76896. update(data: DataArray): void;
  76897. /**
  76898. * Updates the data directly.
  76899. * @param data the new data
  76900. * @param offset the new offset
  76901. * @param vertexCount the vertex count (optional)
  76902. * @param useBytes set to true if the offset is in bytes
  76903. */
  76904. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  76905. /**
  76906. * Release all resources
  76907. */
  76908. dispose(): void;
  76909. }
  76910. /**
  76911. * Specialized buffer used to store vertex data
  76912. */
  76913. export class VertexBuffer {
  76914. /** @hidden */
  76915. _buffer: Buffer;
  76916. private _kind;
  76917. private _size;
  76918. private _ownsBuffer;
  76919. private _instanced;
  76920. private _instanceDivisor;
  76921. /**
  76922. * The byte type.
  76923. */
  76924. static readonly BYTE: number;
  76925. /**
  76926. * The unsigned byte type.
  76927. */
  76928. static readonly UNSIGNED_BYTE: number;
  76929. /**
  76930. * The short type.
  76931. */
  76932. static readonly SHORT: number;
  76933. /**
  76934. * The unsigned short type.
  76935. */
  76936. static readonly UNSIGNED_SHORT: number;
  76937. /**
  76938. * The integer type.
  76939. */
  76940. static readonly INT: number;
  76941. /**
  76942. * The unsigned integer type.
  76943. */
  76944. static readonly UNSIGNED_INT: number;
  76945. /**
  76946. * The float type.
  76947. */
  76948. static readonly FLOAT: number;
  76949. /**
  76950. * Gets or sets the instance divisor when in instanced mode
  76951. */
  76952. get instanceDivisor(): number;
  76953. set instanceDivisor(value: number);
  76954. /**
  76955. * Gets the byte stride.
  76956. */
  76957. readonly byteStride: number;
  76958. /**
  76959. * Gets the byte offset.
  76960. */
  76961. readonly byteOffset: number;
  76962. /**
  76963. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  76964. */
  76965. readonly normalized: boolean;
  76966. /**
  76967. * Gets the data type of each component in the array.
  76968. */
  76969. readonly type: number;
  76970. /**
  76971. * Constructor
  76972. * @param engine the engine
  76973. * @param data the data to use for this vertex buffer
  76974. * @param kind the vertex buffer kind
  76975. * @param updatable whether the data is updatable
  76976. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76977. * @param stride the stride (optional)
  76978. * @param instanced whether the buffer is instanced (optional)
  76979. * @param offset the offset of the data (optional)
  76980. * @param size the number of components (optional)
  76981. * @param type the type of the component (optional)
  76982. * @param normalized whether the data contains normalized data (optional)
  76983. * @param useBytes set to true if stride and offset are in bytes (optional)
  76984. * @param divisor defines the instance divisor to use (1 by default)
  76985. */
  76986. 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);
  76987. /** @hidden */
  76988. _rebuild(): void;
  76989. /**
  76990. * Returns the kind of the VertexBuffer (string)
  76991. * @returns a string
  76992. */
  76993. getKind(): string;
  76994. /**
  76995. * Gets a boolean indicating if the VertexBuffer is updatable?
  76996. * @returns true if the buffer is updatable
  76997. */
  76998. isUpdatable(): boolean;
  76999. /**
  77000. * Gets current buffer's data
  77001. * @returns a DataArray or null
  77002. */
  77003. getData(): Nullable<DataArray>;
  77004. /**
  77005. * Gets underlying native buffer
  77006. * @returns underlying native buffer
  77007. */
  77008. getBuffer(): Nullable<DataBuffer>;
  77009. /**
  77010. * Gets the stride in float32 units (i.e. byte stride / 4).
  77011. * May not be an integer if the byte stride is not divisible by 4.
  77012. * @returns the stride in float32 units
  77013. * @deprecated Please use byteStride instead.
  77014. */
  77015. getStrideSize(): number;
  77016. /**
  77017. * Returns the offset as a multiple of the type byte length.
  77018. * @returns the offset in bytes
  77019. * @deprecated Please use byteOffset instead.
  77020. */
  77021. getOffset(): number;
  77022. /**
  77023. * Returns the number of components per vertex attribute (integer)
  77024. * @returns the size in float
  77025. */
  77026. getSize(): number;
  77027. /**
  77028. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77029. * @returns true if this buffer is instanced
  77030. */
  77031. getIsInstanced(): boolean;
  77032. /**
  77033. * Returns the instancing divisor, zero for non-instanced (integer).
  77034. * @returns a number
  77035. */
  77036. getInstanceDivisor(): number;
  77037. /**
  77038. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77039. * @param data defines the data to store
  77040. */
  77041. create(data?: DataArray): void;
  77042. /**
  77043. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77044. * This function will create a new buffer if the current one is not updatable
  77045. * @param data defines the data to store
  77046. */
  77047. update(data: DataArray): void;
  77048. /**
  77049. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77050. * Returns the directly updated WebGLBuffer.
  77051. * @param data the new data
  77052. * @param offset the new offset
  77053. * @param useBytes set to true if the offset is in bytes
  77054. */
  77055. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77056. /**
  77057. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77058. */
  77059. dispose(): void;
  77060. /**
  77061. * Enumerates each value of this vertex buffer as numbers.
  77062. * @param count the number of values to enumerate
  77063. * @param callback the callback function called for each value
  77064. */
  77065. forEach(count: number, callback: (value: number, index: number) => void): void;
  77066. /**
  77067. * Positions
  77068. */
  77069. static readonly PositionKind: string;
  77070. /**
  77071. * Normals
  77072. */
  77073. static readonly NormalKind: string;
  77074. /**
  77075. * Tangents
  77076. */
  77077. static readonly TangentKind: string;
  77078. /**
  77079. * Texture coordinates
  77080. */
  77081. static readonly UVKind: string;
  77082. /**
  77083. * Texture coordinates 2
  77084. */
  77085. static readonly UV2Kind: string;
  77086. /**
  77087. * Texture coordinates 3
  77088. */
  77089. static readonly UV3Kind: string;
  77090. /**
  77091. * Texture coordinates 4
  77092. */
  77093. static readonly UV4Kind: string;
  77094. /**
  77095. * Texture coordinates 5
  77096. */
  77097. static readonly UV5Kind: string;
  77098. /**
  77099. * Texture coordinates 6
  77100. */
  77101. static readonly UV6Kind: string;
  77102. /**
  77103. * Colors
  77104. */
  77105. static readonly ColorKind: string;
  77106. /**
  77107. * Matrix indices (for bones)
  77108. */
  77109. static readonly MatricesIndicesKind: string;
  77110. /**
  77111. * Matrix weights (for bones)
  77112. */
  77113. static readonly MatricesWeightsKind: string;
  77114. /**
  77115. * Additional matrix indices (for bones)
  77116. */
  77117. static readonly MatricesIndicesExtraKind: string;
  77118. /**
  77119. * Additional matrix weights (for bones)
  77120. */
  77121. static readonly MatricesWeightsExtraKind: string;
  77122. /**
  77123. * Deduces the stride given a kind.
  77124. * @param kind The kind string to deduce
  77125. * @returns The deduced stride
  77126. */
  77127. static DeduceStride(kind: string): number;
  77128. /**
  77129. * Gets the byte length of the given type.
  77130. * @param type the type
  77131. * @returns the number of bytes
  77132. */
  77133. static GetTypeByteLength(type: number): number;
  77134. /**
  77135. * Enumerates each value of the given parameters as numbers.
  77136. * @param data the data to enumerate
  77137. * @param byteOffset the byte offset of the data
  77138. * @param byteStride the byte stride of the data
  77139. * @param componentCount the number of components per element
  77140. * @param componentType the type of the component
  77141. * @param count the number of values to enumerate
  77142. * @param normalized whether the data is normalized
  77143. * @param callback the callback function called for each value
  77144. */
  77145. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77146. private static _GetFloatValue;
  77147. }
  77148. }
  77149. declare module BABYLON {
  77150. /**
  77151. * @hidden
  77152. */
  77153. export class IntersectionInfo {
  77154. bu: Nullable<number>;
  77155. bv: Nullable<number>;
  77156. distance: number;
  77157. faceId: number;
  77158. subMeshId: number;
  77159. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77160. }
  77161. }
  77162. declare module BABYLON {
  77163. /**
  77164. * Represens a plane by the equation ax + by + cz + d = 0
  77165. */
  77166. export class Plane {
  77167. private static _TmpMatrix;
  77168. /**
  77169. * Normal of the plane (a,b,c)
  77170. */
  77171. normal: Vector3;
  77172. /**
  77173. * d component of the plane
  77174. */
  77175. d: number;
  77176. /**
  77177. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77178. * @param a a component of the plane
  77179. * @param b b component of the plane
  77180. * @param c c component of the plane
  77181. * @param d d component of the plane
  77182. */
  77183. constructor(a: number, b: number, c: number, d: number);
  77184. /**
  77185. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77186. */
  77187. asArray(): number[];
  77188. /**
  77189. * @returns a new plane copied from the current Plane.
  77190. */
  77191. clone(): Plane;
  77192. /**
  77193. * @returns the string "Plane".
  77194. */
  77195. getClassName(): string;
  77196. /**
  77197. * @returns the Plane hash code.
  77198. */
  77199. getHashCode(): number;
  77200. /**
  77201. * Normalize the current Plane in place.
  77202. * @returns the updated Plane.
  77203. */
  77204. normalize(): Plane;
  77205. /**
  77206. * Applies a transformation the plane and returns the result
  77207. * @param transformation the transformation matrix to be applied to the plane
  77208. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77209. */
  77210. transform(transformation: DeepImmutable<Matrix>): Plane;
  77211. /**
  77212. * Calcualtte the dot product between the point and the plane normal
  77213. * @param point point to calculate the dot product with
  77214. * @returns the dot product (float) of the point coordinates and the plane normal.
  77215. */
  77216. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77217. /**
  77218. * Updates the current Plane from the plane defined by the three given points.
  77219. * @param point1 one of the points used to contruct the plane
  77220. * @param point2 one of the points used to contruct the plane
  77221. * @param point3 one of the points used to contruct the plane
  77222. * @returns the updated Plane.
  77223. */
  77224. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77225. /**
  77226. * Checks if the plane is facing a given direction
  77227. * @param direction the direction to check if the plane is facing
  77228. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77229. * @returns True is the vector "direction" is the same side than the plane normal.
  77230. */
  77231. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77232. /**
  77233. * Calculates the distance to a point
  77234. * @param point point to calculate distance to
  77235. * @returns the signed distance (float) from the given point to the Plane.
  77236. */
  77237. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77238. /**
  77239. * Creates a plane from an array
  77240. * @param array the array to create a plane from
  77241. * @returns a new Plane from the given array.
  77242. */
  77243. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77244. /**
  77245. * Creates a plane from three points
  77246. * @param point1 point used to create the plane
  77247. * @param point2 point used to create the plane
  77248. * @param point3 point used to create the plane
  77249. * @returns a new Plane defined by the three given points.
  77250. */
  77251. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77252. /**
  77253. * Creates a plane from an origin point and a normal
  77254. * @param origin origin of the plane to be constructed
  77255. * @param normal normal of the plane to be constructed
  77256. * @returns a new Plane the normal vector to this plane at the given origin point.
  77257. * Note : the vector "normal" is updated because normalized.
  77258. */
  77259. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77260. /**
  77261. * Calculates the distance from a plane and a point
  77262. * @param origin origin of the plane to be constructed
  77263. * @param normal normal of the plane to be constructed
  77264. * @param point point to calculate distance to
  77265. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77266. */
  77267. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77268. }
  77269. }
  77270. declare module BABYLON {
  77271. /**
  77272. * Class used to store bounding sphere information
  77273. */
  77274. export class BoundingSphere {
  77275. /**
  77276. * Gets the center of the bounding sphere in local space
  77277. */
  77278. readonly center: Vector3;
  77279. /**
  77280. * Radius of the bounding sphere in local space
  77281. */
  77282. radius: number;
  77283. /**
  77284. * Gets the center of the bounding sphere in world space
  77285. */
  77286. readonly centerWorld: Vector3;
  77287. /**
  77288. * Radius of the bounding sphere in world space
  77289. */
  77290. radiusWorld: number;
  77291. /**
  77292. * Gets the minimum vector in local space
  77293. */
  77294. readonly minimum: Vector3;
  77295. /**
  77296. * Gets the maximum vector in local space
  77297. */
  77298. readonly maximum: Vector3;
  77299. private _worldMatrix;
  77300. private static readonly TmpVector3;
  77301. /**
  77302. * Creates a new bounding sphere
  77303. * @param min defines the minimum vector (in local space)
  77304. * @param max defines the maximum vector (in local space)
  77305. * @param worldMatrix defines the new world matrix
  77306. */
  77307. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77308. /**
  77309. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  77310. * @param min defines the new minimum vector (in local space)
  77311. * @param max defines the new maximum vector (in local space)
  77312. * @param worldMatrix defines the new world matrix
  77313. */
  77314. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77315. /**
  77316. * Scale the current bounding sphere by applying a scale factor
  77317. * @param factor defines the scale factor to apply
  77318. * @returns the current bounding box
  77319. */
  77320. scale(factor: number): BoundingSphere;
  77321. /**
  77322. * Gets the world matrix of the bounding box
  77323. * @returns a matrix
  77324. */
  77325. getWorldMatrix(): DeepImmutable<Matrix>;
  77326. /** @hidden */
  77327. _update(worldMatrix: DeepImmutable<Matrix>): void;
  77328. /**
  77329. * Tests if the bounding sphere is intersecting the frustum planes
  77330. * @param frustumPlanes defines the frustum planes to test
  77331. * @returns true if there is an intersection
  77332. */
  77333. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77334. /**
  77335. * Tests if the bounding sphere center is in between the frustum planes.
  77336. * Used for optimistic fast inclusion.
  77337. * @param frustumPlanes defines the frustum planes to test
  77338. * @returns true if the sphere center is in between the frustum planes
  77339. */
  77340. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77341. /**
  77342. * Tests if a point is inside the bounding sphere
  77343. * @param point defines the point to test
  77344. * @returns true if the point is inside the bounding sphere
  77345. */
  77346. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77347. /**
  77348. * Checks if two sphere intersct
  77349. * @param sphere0 sphere 0
  77350. * @param sphere1 sphere 1
  77351. * @returns true if the speres intersect
  77352. */
  77353. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  77354. }
  77355. }
  77356. declare module BABYLON {
  77357. /**
  77358. * Class used to store bounding box information
  77359. */
  77360. export class BoundingBox implements ICullable {
  77361. /**
  77362. * Gets the 8 vectors representing the bounding box in local space
  77363. */
  77364. readonly vectors: Vector3[];
  77365. /**
  77366. * Gets the center of the bounding box in local space
  77367. */
  77368. readonly center: Vector3;
  77369. /**
  77370. * Gets the center of the bounding box in world space
  77371. */
  77372. readonly centerWorld: Vector3;
  77373. /**
  77374. * Gets the extend size in local space
  77375. */
  77376. readonly extendSize: Vector3;
  77377. /**
  77378. * Gets the extend size in world space
  77379. */
  77380. readonly extendSizeWorld: Vector3;
  77381. /**
  77382. * Gets the OBB (object bounding box) directions
  77383. */
  77384. readonly directions: Vector3[];
  77385. /**
  77386. * Gets the 8 vectors representing the bounding box in world space
  77387. */
  77388. readonly vectorsWorld: Vector3[];
  77389. /**
  77390. * Gets the minimum vector in world space
  77391. */
  77392. readonly minimumWorld: Vector3;
  77393. /**
  77394. * Gets the maximum vector in world space
  77395. */
  77396. readonly maximumWorld: Vector3;
  77397. /**
  77398. * Gets the minimum vector in local space
  77399. */
  77400. readonly minimum: Vector3;
  77401. /**
  77402. * Gets the maximum vector in local space
  77403. */
  77404. readonly maximum: Vector3;
  77405. private _worldMatrix;
  77406. private static readonly TmpVector3;
  77407. /**
  77408. * @hidden
  77409. */
  77410. _tag: number;
  77411. /**
  77412. * Creates a new bounding box
  77413. * @param min defines the minimum vector (in local space)
  77414. * @param max defines the maximum vector (in local space)
  77415. * @param worldMatrix defines the new world matrix
  77416. */
  77417. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77418. /**
  77419. * Recreates the entire bounding box from scratch as if we call the constructor in place
  77420. * @param min defines the new minimum vector (in local space)
  77421. * @param max defines the new maximum vector (in local space)
  77422. * @param worldMatrix defines the new world matrix
  77423. */
  77424. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77425. /**
  77426. * Scale the current bounding box by applying a scale factor
  77427. * @param factor defines the scale factor to apply
  77428. * @returns the current bounding box
  77429. */
  77430. scale(factor: number): BoundingBox;
  77431. /**
  77432. * Gets the world matrix of the bounding box
  77433. * @returns a matrix
  77434. */
  77435. getWorldMatrix(): DeepImmutable<Matrix>;
  77436. /** @hidden */
  77437. _update(world: DeepImmutable<Matrix>): void;
  77438. /**
  77439. * Tests if the bounding box is intersecting the frustum planes
  77440. * @param frustumPlanes defines the frustum planes to test
  77441. * @returns true if there is an intersection
  77442. */
  77443. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77444. /**
  77445. * Tests if the bounding box is entirely inside the frustum planes
  77446. * @param frustumPlanes defines the frustum planes to test
  77447. * @returns true if there is an inclusion
  77448. */
  77449. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77450. /**
  77451. * Tests if a point is inside the bounding box
  77452. * @param point defines the point to test
  77453. * @returns true if the point is inside the bounding box
  77454. */
  77455. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77456. /**
  77457. * Tests if the bounding box intersects with a bounding sphere
  77458. * @param sphere defines the sphere to test
  77459. * @returns true if there is an intersection
  77460. */
  77461. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  77462. /**
  77463. * Tests if the bounding box intersects with a box defined by a min and max vectors
  77464. * @param min defines the min vector to use
  77465. * @param max defines the max vector to use
  77466. * @returns true if there is an intersection
  77467. */
  77468. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  77469. /**
  77470. * Tests if two bounding boxes are intersections
  77471. * @param box0 defines the first box to test
  77472. * @param box1 defines the second box to test
  77473. * @returns true if there is an intersection
  77474. */
  77475. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  77476. /**
  77477. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  77478. * @param minPoint defines the minimum vector of the bounding box
  77479. * @param maxPoint defines the maximum vector of the bounding box
  77480. * @param sphereCenter defines the sphere center
  77481. * @param sphereRadius defines the sphere radius
  77482. * @returns true if there is an intersection
  77483. */
  77484. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  77485. /**
  77486. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  77487. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77488. * @param frustumPlanes defines the frustum planes to test
  77489. * @return true if there is an inclusion
  77490. */
  77491. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77492. /**
  77493. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  77494. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77495. * @param frustumPlanes defines the frustum planes to test
  77496. * @return true if there is an intersection
  77497. */
  77498. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77499. }
  77500. }
  77501. declare module BABYLON {
  77502. /** @hidden */
  77503. export class Collider {
  77504. /** Define if a collision was found */
  77505. collisionFound: boolean;
  77506. /**
  77507. * Define last intersection point in local space
  77508. */
  77509. intersectionPoint: Vector3;
  77510. /**
  77511. * Define last collided mesh
  77512. */
  77513. collidedMesh: Nullable<AbstractMesh>;
  77514. private _collisionPoint;
  77515. private _planeIntersectionPoint;
  77516. private _tempVector;
  77517. private _tempVector2;
  77518. private _tempVector3;
  77519. private _tempVector4;
  77520. private _edge;
  77521. private _baseToVertex;
  77522. private _destinationPoint;
  77523. private _slidePlaneNormal;
  77524. private _displacementVector;
  77525. /** @hidden */
  77526. _radius: Vector3;
  77527. /** @hidden */
  77528. _retry: number;
  77529. private _velocity;
  77530. private _basePoint;
  77531. private _epsilon;
  77532. /** @hidden */
  77533. _velocityWorldLength: number;
  77534. /** @hidden */
  77535. _basePointWorld: Vector3;
  77536. private _velocityWorld;
  77537. private _normalizedVelocity;
  77538. /** @hidden */
  77539. _initialVelocity: Vector3;
  77540. /** @hidden */
  77541. _initialPosition: Vector3;
  77542. private _nearestDistance;
  77543. private _collisionMask;
  77544. get collisionMask(): number;
  77545. set collisionMask(mask: number);
  77546. /**
  77547. * Gets the plane normal used to compute the sliding response (in local space)
  77548. */
  77549. get slidePlaneNormal(): Vector3;
  77550. /** @hidden */
  77551. _initialize(source: Vector3, dir: Vector3, e: number): void;
  77552. /** @hidden */
  77553. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  77554. /** @hidden */
  77555. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  77556. /** @hidden */
  77557. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77558. /** @hidden */
  77559. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77560. /** @hidden */
  77561. _getResponse(pos: Vector3, vel: Vector3): void;
  77562. }
  77563. }
  77564. declare module BABYLON {
  77565. /**
  77566. * Interface for cullable objects
  77567. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  77568. */
  77569. export interface ICullable {
  77570. /**
  77571. * Checks if the object or part of the object is in the frustum
  77572. * @param frustumPlanes Camera near/planes
  77573. * @returns true if the object is in frustum otherwise false
  77574. */
  77575. isInFrustum(frustumPlanes: Plane[]): boolean;
  77576. /**
  77577. * Checks if a cullable object (mesh...) is in the camera frustum
  77578. * Unlike isInFrustum this cheks the full bounding box
  77579. * @param frustumPlanes Camera near/planes
  77580. * @returns true if the object is in frustum otherwise false
  77581. */
  77582. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77583. }
  77584. /**
  77585. * Info for a bounding data of a mesh
  77586. */
  77587. export class BoundingInfo implements ICullable {
  77588. /**
  77589. * Bounding box for the mesh
  77590. */
  77591. readonly boundingBox: BoundingBox;
  77592. /**
  77593. * Bounding sphere for the mesh
  77594. */
  77595. readonly boundingSphere: BoundingSphere;
  77596. private _isLocked;
  77597. private static readonly TmpVector3;
  77598. /**
  77599. * Constructs bounding info
  77600. * @param minimum min vector of the bounding box/sphere
  77601. * @param maximum max vector of the bounding box/sphere
  77602. * @param worldMatrix defines the new world matrix
  77603. */
  77604. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77605. /**
  77606. * Recreates the entire bounding info from scratch as if we call the constructor in place
  77607. * @param min defines the new minimum vector (in local space)
  77608. * @param max defines the new maximum vector (in local space)
  77609. * @param worldMatrix defines the new world matrix
  77610. */
  77611. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77612. /**
  77613. * min vector of the bounding box/sphere
  77614. */
  77615. get minimum(): Vector3;
  77616. /**
  77617. * max vector of the bounding box/sphere
  77618. */
  77619. get maximum(): Vector3;
  77620. /**
  77621. * If the info is locked and won't be updated to avoid perf overhead
  77622. */
  77623. get isLocked(): boolean;
  77624. set isLocked(value: boolean);
  77625. /**
  77626. * Updates the bounding sphere and box
  77627. * @param world world matrix to be used to update
  77628. */
  77629. update(world: DeepImmutable<Matrix>): void;
  77630. /**
  77631. * Recreate the bounding info to be centered around a specific point given a specific extend.
  77632. * @param center New center of the bounding info
  77633. * @param extend New extend of the bounding info
  77634. * @returns the current bounding info
  77635. */
  77636. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  77637. /**
  77638. * Scale the current bounding info by applying a scale factor
  77639. * @param factor defines the scale factor to apply
  77640. * @returns the current bounding info
  77641. */
  77642. scale(factor: number): BoundingInfo;
  77643. /**
  77644. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  77645. * @param frustumPlanes defines the frustum to test
  77646. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  77647. * @returns true if the bounding info is in the frustum planes
  77648. */
  77649. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  77650. /**
  77651. * Gets the world distance between the min and max points of the bounding box
  77652. */
  77653. get diagonalLength(): number;
  77654. /**
  77655. * Checks if a cullable object (mesh...) is in the camera frustum
  77656. * Unlike isInFrustum this cheks the full bounding box
  77657. * @param frustumPlanes Camera near/planes
  77658. * @returns true if the object is in frustum otherwise false
  77659. */
  77660. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77661. /** @hidden */
  77662. _checkCollision(collider: Collider): boolean;
  77663. /**
  77664. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  77665. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77666. * @param point the point to check intersection with
  77667. * @returns if the point intersects
  77668. */
  77669. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77670. /**
  77671. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  77672. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77673. * @param boundingInfo the bounding info to check intersection with
  77674. * @param precise if the intersection should be done using OBB
  77675. * @returns if the bounding info intersects
  77676. */
  77677. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  77678. }
  77679. }
  77680. declare module BABYLON {
  77681. /**
  77682. * Extracts minimum and maximum values from a list of indexed positions
  77683. * @param positions defines the positions to use
  77684. * @param indices defines the indices to the positions
  77685. * @param indexStart defines the start index
  77686. * @param indexCount defines the end index
  77687. * @param bias defines bias value to add to the result
  77688. * @return minimum and maximum values
  77689. */
  77690. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  77691. minimum: Vector3;
  77692. maximum: Vector3;
  77693. };
  77694. /**
  77695. * Extracts minimum and maximum values from a list of positions
  77696. * @param positions defines the positions to use
  77697. * @param start defines the start index in the positions array
  77698. * @param count defines the number of positions to handle
  77699. * @param bias defines bias value to add to the result
  77700. * @param stride defines the stride size to use (distance between two positions in the positions array)
  77701. * @return minimum and maximum values
  77702. */
  77703. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  77704. minimum: Vector3;
  77705. maximum: Vector3;
  77706. };
  77707. }
  77708. declare module BABYLON {
  77709. /** @hidden */
  77710. export class WebGLDataBuffer extends DataBuffer {
  77711. private _buffer;
  77712. constructor(resource: WebGLBuffer);
  77713. get underlyingResource(): any;
  77714. }
  77715. }
  77716. declare module BABYLON {
  77717. /** @hidden */
  77718. export class WebGLPipelineContext implements IPipelineContext {
  77719. engine: ThinEngine;
  77720. program: Nullable<WebGLProgram>;
  77721. context?: WebGLRenderingContext;
  77722. vertexShader?: WebGLShader;
  77723. fragmentShader?: WebGLShader;
  77724. isParallelCompiled: boolean;
  77725. onCompiled?: () => void;
  77726. transformFeedback?: WebGLTransformFeedback | null;
  77727. vertexCompilationError: Nullable<string>;
  77728. fragmentCompilationError: Nullable<string>;
  77729. programLinkError: Nullable<string>;
  77730. programValidationError: Nullable<string>;
  77731. get isAsync(): boolean;
  77732. get isReady(): boolean;
  77733. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  77734. }
  77735. }
  77736. declare module BABYLON {
  77737. interface ThinEngine {
  77738. /**
  77739. * Create an uniform buffer
  77740. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77741. * @param elements defines the content of the uniform buffer
  77742. * @returns the webGL uniform buffer
  77743. */
  77744. createUniformBuffer(elements: FloatArray): DataBuffer;
  77745. /**
  77746. * Create a dynamic uniform buffer
  77747. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77748. * @param elements defines the content of the uniform buffer
  77749. * @returns the webGL uniform buffer
  77750. */
  77751. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  77752. /**
  77753. * Update an existing uniform buffer
  77754. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77755. * @param uniformBuffer defines the target uniform buffer
  77756. * @param elements defines the content to update
  77757. * @param offset defines the offset in the uniform buffer where update should start
  77758. * @param count defines the size of the data to update
  77759. */
  77760. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  77761. /**
  77762. * Bind an uniform buffer to the current webGL context
  77763. * @param buffer defines the buffer to bind
  77764. */
  77765. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  77766. /**
  77767. * Bind a buffer to the current webGL context at a given location
  77768. * @param buffer defines the buffer to bind
  77769. * @param location defines the index where to bind the buffer
  77770. */
  77771. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  77772. /**
  77773. * Bind a specific block at a given index in a specific shader program
  77774. * @param pipelineContext defines the pipeline context to use
  77775. * @param blockName defines the block name
  77776. * @param index defines the index where to bind the block
  77777. */
  77778. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  77779. }
  77780. }
  77781. declare module BABYLON {
  77782. /**
  77783. * Uniform buffer objects.
  77784. *
  77785. * Handles blocks of uniform on the GPU.
  77786. *
  77787. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77788. *
  77789. * For more information, please refer to :
  77790. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77791. */
  77792. export class UniformBuffer {
  77793. private _engine;
  77794. private _buffer;
  77795. private _data;
  77796. private _bufferData;
  77797. private _dynamic?;
  77798. private _uniformLocations;
  77799. private _uniformSizes;
  77800. private _uniformLocationPointer;
  77801. private _needSync;
  77802. private _noUBO;
  77803. private _currentEffect;
  77804. /** @hidden */
  77805. _alreadyBound: boolean;
  77806. private static _MAX_UNIFORM_SIZE;
  77807. private static _tempBuffer;
  77808. /**
  77809. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  77810. * This is dynamic to allow compat with webgl 1 and 2.
  77811. * You will need to pass the name of the uniform as well as the value.
  77812. */
  77813. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  77814. /**
  77815. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  77816. * This is dynamic to allow compat with webgl 1 and 2.
  77817. * You will need to pass the name of the uniform as well as the value.
  77818. */
  77819. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  77820. /**
  77821. * Lambda to Update a single float in a uniform buffer.
  77822. * This is dynamic to allow compat with webgl 1 and 2.
  77823. * You will need to pass the name of the uniform as well as the value.
  77824. */
  77825. updateFloat: (name: string, x: number) => void;
  77826. /**
  77827. * Lambda to Update a vec2 of float in a uniform buffer.
  77828. * This is dynamic to allow compat with webgl 1 and 2.
  77829. * You will need to pass the name of the uniform as well as the value.
  77830. */
  77831. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  77832. /**
  77833. * Lambda to Update a vec3 of float in a uniform buffer.
  77834. * This is dynamic to allow compat with webgl 1 and 2.
  77835. * You will need to pass the name of the uniform as well as the value.
  77836. */
  77837. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  77838. /**
  77839. * Lambda to Update a vec4 of float in a uniform buffer.
  77840. * This is dynamic to allow compat with webgl 1 and 2.
  77841. * You will need to pass the name of the uniform as well as the value.
  77842. */
  77843. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  77844. /**
  77845. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  77846. * This is dynamic to allow compat with webgl 1 and 2.
  77847. * You will need to pass the name of the uniform as well as the value.
  77848. */
  77849. updateMatrix: (name: string, mat: Matrix) => void;
  77850. /**
  77851. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  77852. * This is dynamic to allow compat with webgl 1 and 2.
  77853. * You will need to pass the name of the uniform as well as the value.
  77854. */
  77855. updateVector3: (name: string, vector: Vector3) => void;
  77856. /**
  77857. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  77858. * This is dynamic to allow compat with webgl 1 and 2.
  77859. * You will need to pass the name of the uniform as well as the value.
  77860. */
  77861. updateVector4: (name: string, vector: Vector4) => void;
  77862. /**
  77863. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  77864. * This is dynamic to allow compat with webgl 1 and 2.
  77865. * You will need to pass the name of the uniform as well as the value.
  77866. */
  77867. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  77868. /**
  77869. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  77870. * This is dynamic to allow compat with webgl 1 and 2.
  77871. * You will need to pass the name of the uniform as well as the value.
  77872. */
  77873. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  77874. /**
  77875. * Instantiates a new Uniform buffer objects.
  77876. *
  77877. * Handles blocks of uniform on the GPU.
  77878. *
  77879. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77880. *
  77881. * For more information, please refer to :
  77882. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77883. * @param engine Define the engine the buffer is associated with
  77884. * @param data Define the data contained in the buffer
  77885. * @param dynamic Define if the buffer is updatable
  77886. */
  77887. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  77888. /**
  77889. * Indicates if the buffer is using the WebGL2 UBO implementation,
  77890. * or just falling back on setUniformXXX calls.
  77891. */
  77892. get useUbo(): boolean;
  77893. /**
  77894. * Indicates if the WebGL underlying uniform buffer is in sync
  77895. * with the javascript cache data.
  77896. */
  77897. get isSync(): boolean;
  77898. /**
  77899. * Indicates if the WebGL underlying uniform buffer is dynamic.
  77900. * Also, a dynamic UniformBuffer will disable cache verification and always
  77901. * update the underlying WebGL uniform buffer to the GPU.
  77902. * @returns if Dynamic, otherwise false
  77903. */
  77904. isDynamic(): boolean;
  77905. /**
  77906. * The data cache on JS side.
  77907. * @returns the underlying data as a float array
  77908. */
  77909. getData(): Float32Array;
  77910. /**
  77911. * The underlying WebGL Uniform buffer.
  77912. * @returns the webgl buffer
  77913. */
  77914. getBuffer(): Nullable<DataBuffer>;
  77915. /**
  77916. * std140 layout specifies how to align data within an UBO structure.
  77917. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  77918. * for specs.
  77919. */
  77920. private _fillAlignment;
  77921. /**
  77922. * Adds an uniform in the buffer.
  77923. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  77924. * for the layout to be correct !
  77925. * @param name Name of the uniform, as used in the uniform block in the shader.
  77926. * @param size Data size, or data directly.
  77927. */
  77928. addUniform(name: string, size: number | number[]): void;
  77929. /**
  77930. * Adds a Matrix 4x4 to the uniform buffer.
  77931. * @param name Name of the uniform, as used in the uniform block in the shader.
  77932. * @param mat A 4x4 matrix.
  77933. */
  77934. addMatrix(name: string, mat: Matrix): void;
  77935. /**
  77936. * Adds a vec2 to the uniform buffer.
  77937. * @param name Name of the uniform, as used in the uniform block in the shader.
  77938. * @param x Define the x component value of the vec2
  77939. * @param y Define the y component value of the vec2
  77940. */
  77941. addFloat2(name: string, x: number, y: number): void;
  77942. /**
  77943. * Adds a vec3 to the uniform buffer.
  77944. * @param name Name of the uniform, as used in the uniform block in the shader.
  77945. * @param x Define the x component value of the vec3
  77946. * @param y Define the y component value of the vec3
  77947. * @param z Define the z component value of the vec3
  77948. */
  77949. addFloat3(name: string, x: number, y: number, z: number): void;
  77950. /**
  77951. * Adds a vec3 to the uniform buffer.
  77952. * @param name Name of the uniform, as used in the uniform block in the shader.
  77953. * @param color Define the vec3 from a Color
  77954. */
  77955. addColor3(name: string, color: Color3): void;
  77956. /**
  77957. * Adds a vec4 to the uniform buffer.
  77958. * @param name Name of the uniform, as used in the uniform block in the shader.
  77959. * @param color Define the rgb components from a Color
  77960. * @param alpha Define the a component of the vec4
  77961. */
  77962. addColor4(name: string, color: Color3, alpha: number): void;
  77963. /**
  77964. * Adds a vec3 to the uniform buffer.
  77965. * @param name Name of the uniform, as used in the uniform block in the shader.
  77966. * @param vector Define the vec3 components from a Vector
  77967. */
  77968. addVector3(name: string, vector: Vector3): void;
  77969. /**
  77970. * Adds a Matrix 3x3 to the uniform buffer.
  77971. * @param name Name of the uniform, as used in the uniform block in the shader.
  77972. */
  77973. addMatrix3x3(name: string): void;
  77974. /**
  77975. * Adds a Matrix 2x2 to the uniform buffer.
  77976. * @param name Name of the uniform, as used in the uniform block in the shader.
  77977. */
  77978. addMatrix2x2(name: string): void;
  77979. /**
  77980. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  77981. */
  77982. create(): void;
  77983. /** @hidden */
  77984. _rebuild(): void;
  77985. /**
  77986. * Updates the WebGL Uniform Buffer on the GPU.
  77987. * If the `dynamic` flag is set to true, no cache comparison is done.
  77988. * Otherwise, the buffer will be updated only if the cache differs.
  77989. */
  77990. update(): void;
  77991. /**
  77992. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  77993. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  77994. * @param data Define the flattened data
  77995. * @param size Define the size of the data.
  77996. */
  77997. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  77998. private _valueCache;
  77999. private _cacheMatrix;
  78000. private _updateMatrix3x3ForUniform;
  78001. private _updateMatrix3x3ForEffect;
  78002. private _updateMatrix2x2ForEffect;
  78003. private _updateMatrix2x2ForUniform;
  78004. private _updateFloatForEffect;
  78005. private _updateFloatForUniform;
  78006. private _updateFloat2ForEffect;
  78007. private _updateFloat2ForUniform;
  78008. private _updateFloat3ForEffect;
  78009. private _updateFloat3ForUniform;
  78010. private _updateFloat4ForEffect;
  78011. private _updateFloat4ForUniform;
  78012. private _updateMatrixForEffect;
  78013. private _updateMatrixForUniform;
  78014. private _updateVector3ForEffect;
  78015. private _updateVector3ForUniform;
  78016. private _updateVector4ForEffect;
  78017. private _updateVector4ForUniform;
  78018. private _updateColor3ForEffect;
  78019. private _updateColor3ForUniform;
  78020. private _updateColor4ForEffect;
  78021. private _updateColor4ForUniform;
  78022. /**
  78023. * Sets a sampler uniform on the effect.
  78024. * @param name Define the name of the sampler.
  78025. * @param texture Define the texture to set in the sampler
  78026. */
  78027. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78028. /**
  78029. * Directly updates the value of the uniform in the cache AND on the GPU.
  78030. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78031. * @param data Define the flattened data
  78032. */
  78033. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78034. /**
  78035. * Binds this uniform buffer to an effect.
  78036. * @param effect Define the effect to bind the buffer to
  78037. * @param name Name of the uniform block in the shader.
  78038. */
  78039. bindToEffect(effect: Effect, name: string): void;
  78040. /**
  78041. * Disposes the uniform buffer.
  78042. */
  78043. dispose(): void;
  78044. }
  78045. }
  78046. declare module BABYLON {
  78047. /**
  78048. * Enum that determines the text-wrapping mode to use.
  78049. */
  78050. export enum InspectableType {
  78051. /**
  78052. * Checkbox for booleans
  78053. */
  78054. Checkbox = 0,
  78055. /**
  78056. * Sliders for numbers
  78057. */
  78058. Slider = 1,
  78059. /**
  78060. * Vector3
  78061. */
  78062. Vector3 = 2,
  78063. /**
  78064. * Quaternions
  78065. */
  78066. Quaternion = 3,
  78067. /**
  78068. * Color3
  78069. */
  78070. Color3 = 4,
  78071. /**
  78072. * String
  78073. */
  78074. String = 5
  78075. }
  78076. /**
  78077. * Interface used to define custom inspectable properties.
  78078. * This interface is used by the inspector to display custom property grids
  78079. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78080. */
  78081. export interface IInspectable {
  78082. /**
  78083. * Gets the label to display
  78084. */
  78085. label: string;
  78086. /**
  78087. * Gets the name of the property to edit
  78088. */
  78089. propertyName: string;
  78090. /**
  78091. * Gets the type of the editor to use
  78092. */
  78093. type: InspectableType;
  78094. /**
  78095. * Gets the minimum value of the property when using in "slider" mode
  78096. */
  78097. min?: number;
  78098. /**
  78099. * Gets the maximum value of the property when using in "slider" mode
  78100. */
  78101. max?: number;
  78102. /**
  78103. * Gets the setp to use when using in "slider" mode
  78104. */
  78105. step?: number;
  78106. }
  78107. }
  78108. declare module BABYLON {
  78109. /**
  78110. * Class used to provide helper for timing
  78111. */
  78112. export class TimingTools {
  78113. /**
  78114. * Polyfill for setImmediate
  78115. * @param action defines the action to execute after the current execution block
  78116. */
  78117. static SetImmediate(action: () => void): void;
  78118. }
  78119. }
  78120. declare module BABYLON {
  78121. /**
  78122. * Class used to enable instatition of objects by class name
  78123. */
  78124. export class InstantiationTools {
  78125. /**
  78126. * Use this object to register external classes like custom textures or material
  78127. * to allow the laoders to instantiate them
  78128. */
  78129. static RegisteredExternalClasses: {
  78130. [key: string]: Object;
  78131. };
  78132. /**
  78133. * Tries to instantiate a new object from a given class name
  78134. * @param className defines the class name to instantiate
  78135. * @returns the new object or null if the system was not able to do the instantiation
  78136. */
  78137. static Instantiate(className: string): any;
  78138. }
  78139. }
  78140. declare module BABYLON {
  78141. /**
  78142. * Define options used to create a depth texture
  78143. */
  78144. export class DepthTextureCreationOptions {
  78145. /** Specifies whether or not a stencil should be allocated in the texture */
  78146. generateStencil?: boolean;
  78147. /** Specifies whether or not bilinear filtering is enable on the texture */
  78148. bilinearFiltering?: boolean;
  78149. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78150. comparisonFunction?: number;
  78151. /** Specifies if the created texture is a cube texture */
  78152. isCube?: boolean;
  78153. }
  78154. }
  78155. declare module BABYLON {
  78156. interface ThinEngine {
  78157. /**
  78158. * Creates a depth stencil cube texture.
  78159. * This is only available in WebGL 2.
  78160. * @param size The size of face edge in the cube texture.
  78161. * @param options The options defining the cube texture.
  78162. * @returns The cube texture
  78163. */
  78164. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78165. /**
  78166. * Creates a cube texture
  78167. * @param rootUrl defines the url where the files to load is located
  78168. * @param scene defines the current scene
  78169. * @param files defines the list of files to load (1 per face)
  78170. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78171. * @param onLoad defines an optional callback raised when the texture is loaded
  78172. * @param onError defines an optional callback raised if there is an issue to load the texture
  78173. * @param format defines the format of the data
  78174. * @param forcedExtension defines the extension to use to pick the right loader
  78175. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78176. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78177. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78178. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  78179. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  78180. * @returns the cube texture as an InternalTexture
  78181. */
  78182. 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;
  78183. /**
  78184. * Creates a cube texture
  78185. * @param rootUrl defines the url where the files to load is located
  78186. * @param scene defines the current scene
  78187. * @param files defines the list of files to load (1 per face)
  78188. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78189. * @param onLoad defines an optional callback raised when the texture is loaded
  78190. * @param onError defines an optional callback raised if there is an issue to load the texture
  78191. * @param format defines the format of the data
  78192. * @param forcedExtension defines the extension to use to pick the right loader
  78193. * @returns the cube texture as an InternalTexture
  78194. */
  78195. 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;
  78196. /**
  78197. * Creates a cube texture
  78198. * @param rootUrl defines the url where the files to load is located
  78199. * @param scene defines the current scene
  78200. * @param files defines the list of files to load (1 per face)
  78201. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78202. * @param onLoad defines an optional callback raised when the texture is loaded
  78203. * @param onError defines an optional callback raised if there is an issue to load the texture
  78204. * @param format defines the format of the data
  78205. * @param forcedExtension defines the extension to use to pick the right loader
  78206. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78207. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78208. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78209. * @returns the cube texture as an InternalTexture
  78210. */
  78211. 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;
  78212. /** @hidden */
  78213. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  78214. /** @hidden */
  78215. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  78216. /** @hidden */
  78217. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78218. /** @hidden */
  78219. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78220. /**
  78221. * @hidden
  78222. */
  78223. _setCubeMapTextureParams(loadMipmap: boolean): void;
  78224. }
  78225. }
  78226. declare module BABYLON {
  78227. /**
  78228. * Class for creating a cube texture
  78229. */
  78230. export class CubeTexture extends BaseTexture {
  78231. private _delayedOnLoad;
  78232. /**
  78233. * The url of the texture
  78234. */
  78235. url: string;
  78236. /**
  78237. * Gets or sets the center of the bounding box associated with the cube texture.
  78238. * It must define where the camera used to render the texture was set
  78239. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78240. */
  78241. boundingBoxPosition: Vector3;
  78242. private _boundingBoxSize;
  78243. /**
  78244. * Gets or sets the size of the bounding box associated with the cube texture
  78245. * When defined, the cubemap will switch to local mode
  78246. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  78247. * @example https://www.babylonjs-playground.com/#RNASML
  78248. */
  78249. set boundingBoxSize(value: Vector3);
  78250. /**
  78251. * Returns the bounding box size
  78252. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78253. */
  78254. get boundingBoxSize(): Vector3;
  78255. protected _rotationY: number;
  78256. /**
  78257. * Sets texture matrix rotation angle around Y axis in radians.
  78258. */
  78259. set rotationY(value: number);
  78260. /**
  78261. * Gets texture matrix rotation angle around Y axis radians.
  78262. */
  78263. get rotationY(): number;
  78264. /**
  78265. * Are mip maps generated for this texture or not.
  78266. */
  78267. get noMipmap(): boolean;
  78268. private _noMipmap;
  78269. private _files;
  78270. protected _forcedExtension: Nullable<string>;
  78271. private _extensions;
  78272. private _textureMatrix;
  78273. private _format;
  78274. private _createPolynomials;
  78275. /** @hidden */
  78276. _prefiltered: boolean;
  78277. /**
  78278. * Creates a cube texture from an array of image urls
  78279. * @param files defines an array of image urls
  78280. * @param scene defines the hosting scene
  78281. * @param noMipmap specifies if mip maps are not used
  78282. * @returns a cube texture
  78283. */
  78284. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  78285. /**
  78286. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  78287. * @param url defines the url of the prefiltered texture
  78288. * @param scene defines the scene the texture is attached to
  78289. * @param forcedExtension defines the extension of the file if different from the url
  78290. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78291. * @return the prefiltered texture
  78292. */
  78293. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  78294. /**
  78295. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  78296. * as prefiltered data.
  78297. * @param rootUrl defines the url of the texture or the root name of the six images
  78298. * @param scene defines the scene the texture is attached to
  78299. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  78300. * @param noMipmap defines if mipmaps should be created or not
  78301. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  78302. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  78303. * @param onError defines a callback triggered in case of error during load
  78304. * @param format defines the internal format to use for the texture once loaded
  78305. * @param prefiltered defines whether or not the texture is created from prefiltered data
  78306. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  78307. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78308. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78309. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78310. * @return the cube texture
  78311. */
  78312. 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);
  78313. /**
  78314. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  78315. */
  78316. get isPrefiltered(): boolean;
  78317. /**
  78318. * Get the current class name of the texture useful for serialization or dynamic coding.
  78319. * @returns "CubeTexture"
  78320. */
  78321. getClassName(): string;
  78322. /**
  78323. * Update the url (and optional buffer) of this texture if url was null during construction.
  78324. * @param url the url of the texture
  78325. * @param forcedExtension defines the extension to use
  78326. * @param onLoad callback called when the texture is loaded (defaults to null)
  78327. */
  78328. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  78329. /**
  78330. * Delays loading of the cube texture
  78331. * @param forcedExtension defines the extension to use
  78332. */
  78333. delayLoad(forcedExtension?: string): void;
  78334. /**
  78335. * Returns the reflection texture matrix
  78336. * @returns the reflection texture matrix
  78337. */
  78338. getReflectionTextureMatrix(): Matrix;
  78339. /**
  78340. * Sets the reflection texture matrix
  78341. * @param value Reflection texture matrix
  78342. */
  78343. setReflectionTextureMatrix(value: Matrix): void;
  78344. /**
  78345. * Parses text to create a cube texture
  78346. * @param parsedTexture define the serialized text to read from
  78347. * @param scene defines the hosting scene
  78348. * @param rootUrl defines the root url of the cube texture
  78349. * @returns a cube texture
  78350. */
  78351. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  78352. /**
  78353. * Makes a clone, or deep copy, of the cube texture
  78354. * @returns a new cube texture
  78355. */
  78356. clone(): CubeTexture;
  78357. }
  78358. }
  78359. declare module BABYLON {
  78360. /**
  78361. * Manages the defines for the Material
  78362. */
  78363. export class MaterialDefines {
  78364. /** @hidden */
  78365. protected _keys: string[];
  78366. private _isDirty;
  78367. /** @hidden */
  78368. _renderId: number;
  78369. /** @hidden */
  78370. _areLightsDirty: boolean;
  78371. /** @hidden */
  78372. _areLightsDisposed: boolean;
  78373. /** @hidden */
  78374. _areAttributesDirty: boolean;
  78375. /** @hidden */
  78376. _areTexturesDirty: boolean;
  78377. /** @hidden */
  78378. _areFresnelDirty: boolean;
  78379. /** @hidden */
  78380. _areMiscDirty: boolean;
  78381. /** @hidden */
  78382. _areImageProcessingDirty: boolean;
  78383. /** @hidden */
  78384. _normals: boolean;
  78385. /** @hidden */
  78386. _uvs: boolean;
  78387. /** @hidden */
  78388. _needNormals: boolean;
  78389. /** @hidden */
  78390. _needUVs: boolean;
  78391. [id: string]: any;
  78392. /**
  78393. * Specifies if the material needs to be re-calculated
  78394. */
  78395. get isDirty(): boolean;
  78396. /**
  78397. * Marks the material to indicate that it has been re-calculated
  78398. */
  78399. markAsProcessed(): void;
  78400. /**
  78401. * Marks the material to indicate that it needs to be re-calculated
  78402. */
  78403. markAsUnprocessed(): void;
  78404. /**
  78405. * Marks the material to indicate all of its defines need to be re-calculated
  78406. */
  78407. markAllAsDirty(): void;
  78408. /**
  78409. * Marks the material to indicate that image processing needs to be re-calculated
  78410. */
  78411. markAsImageProcessingDirty(): void;
  78412. /**
  78413. * Marks the material to indicate the lights need to be re-calculated
  78414. * @param disposed Defines whether the light is dirty due to dispose or not
  78415. */
  78416. markAsLightDirty(disposed?: boolean): void;
  78417. /**
  78418. * Marks the attribute state as changed
  78419. */
  78420. markAsAttributesDirty(): void;
  78421. /**
  78422. * Marks the texture state as changed
  78423. */
  78424. markAsTexturesDirty(): void;
  78425. /**
  78426. * Marks the fresnel state as changed
  78427. */
  78428. markAsFresnelDirty(): void;
  78429. /**
  78430. * Marks the misc state as changed
  78431. */
  78432. markAsMiscDirty(): void;
  78433. /**
  78434. * Rebuilds the material defines
  78435. */
  78436. rebuild(): void;
  78437. /**
  78438. * Specifies if two material defines are equal
  78439. * @param other - A material define instance to compare to
  78440. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  78441. */
  78442. isEqual(other: MaterialDefines): boolean;
  78443. /**
  78444. * Clones this instance's defines to another instance
  78445. * @param other - material defines to clone values to
  78446. */
  78447. cloneTo(other: MaterialDefines): void;
  78448. /**
  78449. * Resets the material define values
  78450. */
  78451. reset(): void;
  78452. /**
  78453. * Converts the material define values to a string
  78454. * @returns - String of material define information
  78455. */
  78456. toString(): string;
  78457. }
  78458. }
  78459. declare module BABYLON {
  78460. /**
  78461. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78462. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78463. * 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;
  78464. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78465. */
  78466. export class ColorCurves {
  78467. private _dirty;
  78468. private _tempColor;
  78469. private _globalCurve;
  78470. private _highlightsCurve;
  78471. private _midtonesCurve;
  78472. private _shadowsCurve;
  78473. private _positiveCurve;
  78474. private _negativeCurve;
  78475. private _globalHue;
  78476. private _globalDensity;
  78477. private _globalSaturation;
  78478. private _globalExposure;
  78479. /**
  78480. * Gets the global Hue value.
  78481. * 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).
  78482. */
  78483. get globalHue(): number;
  78484. /**
  78485. * Sets the global Hue value.
  78486. * 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).
  78487. */
  78488. set globalHue(value: number);
  78489. /**
  78490. * Gets the global Density value.
  78491. * 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.
  78492. * Values less than zero provide a filter of opposite hue.
  78493. */
  78494. get globalDensity(): number;
  78495. /**
  78496. * Sets the global Density value.
  78497. * 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.
  78498. * Values less than zero provide a filter of opposite hue.
  78499. */
  78500. set globalDensity(value: number);
  78501. /**
  78502. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  78504. */
  78505. get globalSaturation(): number;
  78506. /**
  78507. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  78509. */
  78510. set globalSaturation(value: number);
  78511. /**
  78512. * Gets the global Exposure value.
  78513. * 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.
  78514. */
  78515. get globalExposure(): number;
  78516. /**
  78517. * Sets the global Exposure value.
  78518. * 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.
  78519. */
  78520. set globalExposure(value: number);
  78521. private _highlightsHue;
  78522. private _highlightsDensity;
  78523. private _highlightsSaturation;
  78524. private _highlightsExposure;
  78525. /**
  78526. * Gets the highlights Hue value.
  78527. * 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).
  78528. */
  78529. get highlightsHue(): number;
  78530. /**
  78531. * Sets the highlights Hue value.
  78532. * 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).
  78533. */
  78534. set highlightsHue(value: number);
  78535. /**
  78536. * Gets the highlights Density value.
  78537. * 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.
  78538. * Values less than zero provide a filter of opposite hue.
  78539. */
  78540. get highlightsDensity(): number;
  78541. /**
  78542. * Sets the highlights Density value.
  78543. * 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.
  78544. * Values less than zero provide a filter of opposite hue.
  78545. */
  78546. set highlightsDensity(value: number);
  78547. /**
  78548. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  78550. */
  78551. get highlightsSaturation(): number;
  78552. /**
  78553. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  78555. */
  78556. set highlightsSaturation(value: number);
  78557. /**
  78558. * Gets the highlights Exposure value.
  78559. * 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.
  78560. */
  78561. get highlightsExposure(): number;
  78562. /**
  78563. * Sets the highlights Exposure value.
  78564. * 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.
  78565. */
  78566. set highlightsExposure(value: number);
  78567. private _midtonesHue;
  78568. private _midtonesDensity;
  78569. private _midtonesSaturation;
  78570. private _midtonesExposure;
  78571. /**
  78572. * Gets the midtones Hue value.
  78573. * 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).
  78574. */
  78575. get midtonesHue(): number;
  78576. /**
  78577. * Sets the midtones Hue value.
  78578. * 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).
  78579. */
  78580. set midtonesHue(value: number);
  78581. /**
  78582. * Gets the midtones Density value.
  78583. * 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.
  78584. * Values less than zero provide a filter of opposite hue.
  78585. */
  78586. get midtonesDensity(): number;
  78587. /**
  78588. * Sets the midtones Density value.
  78589. * 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.
  78590. * Values less than zero provide a filter of opposite hue.
  78591. */
  78592. set midtonesDensity(value: number);
  78593. /**
  78594. * Gets the midtones Saturation 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 saturation and negative values decrease saturation.
  78596. */
  78597. get midtonesSaturation(): number;
  78598. /**
  78599. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  78601. */
  78602. set midtonesSaturation(value: number);
  78603. /**
  78604. * Gets the midtones Exposure value.
  78605. * 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.
  78606. */
  78607. get midtonesExposure(): number;
  78608. /**
  78609. * Sets the midtones Exposure value.
  78610. * 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.
  78611. */
  78612. set midtonesExposure(value: number);
  78613. private _shadowsHue;
  78614. private _shadowsDensity;
  78615. private _shadowsSaturation;
  78616. private _shadowsExposure;
  78617. /**
  78618. * Gets the shadows Hue value.
  78619. * 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).
  78620. */
  78621. get shadowsHue(): number;
  78622. /**
  78623. * Sets the shadows Hue value.
  78624. * 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).
  78625. */
  78626. set shadowsHue(value: number);
  78627. /**
  78628. * Gets the shadows Density value.
  78629. * 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.
  78630. * Values less than zero provide a filter of opposite hue.
  78631. */
  78632. get shadowsDensity(): number;
  78633. /**
  78634. * Sets the shadows Density value.
  78635. * 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.
  78636. * Values less than zero provide a filter of opposite hue.
  78637. */
  78638. set shadowsDensity(value: number);
  78639. /**
  78640. * Gets the shadows Saturation 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 saturation and negative values decrease saturation.
  78642. */
  78643. get shadowsSaturation(): number;
  78644. /**
  78645. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  78647. */
  78648. set shadowsSaturation(value: number);
  78649. /**
  78650. * Gets the shadows Exposure value.
  78651. * 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.
  78652. */
  78653. get shadowsExposure(): number;
  78654. /**
  78655. * Sets the shadows Exposure value.
  78656. * 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.
  78657. */
  78658. set shadowsExposure(value: number);
  78659. /**
  78660. * Returns the class name
  78661. * @returns The class name
  78662. */
  78663. getClassName(): string;
  78664. /**
  78665. * Binds the color curves to the shader.
  78666. * @param colorCurves The color curve to bind
  78667. * @param effect The effect to bind to
  78668. * @param positiveUniform The positive uniform shader parameter
  78669. * @param neutralUniform The neutral uniform shader parameter
  78670. * @param negativeUniform The negative uniform shader parameter
  78671. */
  78672. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  78673. /**
  78674. * Prepare the list of uniforms associated with the ColorCurves effects.
  78675. * @param uniformsList The list of uniforms used in the effect
  78676. */
  78677. static PrepareUniforms(uniformsList: string[]): void;
  78678. /**
  78679. * Returns color grading data based on a hue, density, saturation and exposure value.
  78680. * @param filterHue The hue of the color filter.
  78681. * @param filterDensity The density of the color filter.
  78682. * @param saturation The saturation.
  78683. * @param exposure The exposure.
  78684. * @param result The result data container.
  78685. */
  78686. private getColorGradingDataToRef;
  78687. /**
  78688. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  78689. * @param value The input slider value in range [-100,100].
  78690. * @returns Adjusted value.
  78691. */
  78692. private static applyColorGradingSliderNonlinear;
  78693. /**
  78694. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  78695. * @param hue The hue (H) input.
  78696. * @param saturation The saturation (S) input.
  78697. * @param brightness The brightness (B) input.
  78698. * @result An RGBA color represented as Vector4.
  78699. */
  78700. private static fromHSBToRef;
  78701. /**
  78702. * Returns a value clamped between min and max
  78703. * @param value The value to clamp
  78704. * @param min The minimum of value
  78705. * @param max The maximum of value
  78706. * @returns The clamped value.
  78707. */
  78708. private static clamp;
  78709. /**
  78710. * Clones the current color curve instance.
  78711. * @return The cloned curves
  78712. */
  78713. clone(): ColorCurves;
  78714. /**
  78715. * Serializes the current color curve instance to a json representation.
  78716. * @return a JSON representation
  78717. */
  78718. serialize(): any;
  78719. /**
  78720. * Parses the color curve from a json representation.
  78721. * @param source the JSON source to parse
  78722. * @return The parsed curves
  78723. */
  78724. static Parse(source: any): ColorCurves;
  78725. }
  78726. }
  78727. declare module BABYLON {
  78728. /**
  78729. * Interface to follow in your material defines to integrate easily the
  78730. * Image proccessing functions.
  78731. * @hidden
  78732. */
  78733. export interface IImageProcessingConfigurationDefines {
  78734. IMAGEPROCESSING: boolean;
  78735. VIGNETTE: boolean;
  78736. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78737. VIGNETTEBLENDMODEOPAQUE: boolean;
  78738. TONEMAPPING: boolean;
  78739. TONEMAPPING_ACES: boolean;
  78740. CONTRAST: boolean;
  78741. EXPOSURE: boolean;
  78742. COLORCURVES: boolean;
  78743. COLORGRADING: boolean;
  78744. COLORGRADING3D: boolean;
  78745. SAMPLER3DGREENDEPTH: boolean;
  78746. SAMPLER3DBGRMAP: boolean;
  78747. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78748. }
  78749. /**
  78750. * @hidden
  78751. */
  78752. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  78753. IMAGEPROCESSING: boolean;
  78754. VIGNETTE: boolean;
  78755. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78756. VIGNETTEBLENDMODEOPAQUE: boolean;
  78757. TONEMAPPING: boolean;
  78758. TONEMAPPING_ACES: boolean;
  78759. CONTRAST: boolean;
  78760. COLORCURVES: boolean;
  78761. COLORGRADING: boolean;
  78762. COLORGRADING3D: boolean;
  78763. SAMPLER3DGREENDEPTH: boolean;
  78764. SAMPLER3DBGRMAP: boolean;
  78765. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78766. EXPOSURE: boolean;
  78767. constructor();
  78768. }
  78769. /**
  78770. * This groups together the common properties used for image processing either in direct forward pass
  78771. * or through post processing effect depending on the use of the image processing pipeline in your scene
  78772. * or not.
  78773. */
  78774. export class ImageProcessingConfiguration {
  78775. /**
  78776. * Default tone mapping applied in BabylonJS.
  78777. */
  78778. static readonly TONEMAPPING_STANDARD: number;
  78779. /**
  78780. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  78781. * to other engines rendering to increase portability.
  78782. */
  78783. static readonly TONEMAPPING_ACES: number;
  78784. /**
  78785. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  78786. */
  78787. colorCurves: Nullable<ColorCurves>;
  78788. private _colorCurvesEnabled;
  78789. /**
  78790. * Gets wether the color curves effect is enabled.
  78791. */
  78792. get colorCurvesEnabled(): boolean;
  78793. /**
  78794. * Sets wether the color curves effect is enabled.
  78795. */
  78796. set colorCurvesEnabled(value: boolean);
  78797. private _colorGradingTexture;
  78798. /**
  78799. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78800. */
  78801. get colorGradingTexture(): Nullable<BaseTexture>;
  78802. /**
  78803. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78804. */
  78805. set colorGradingTexture(value: Nullable<BaseTexture>);
  78806. private _colorGradingEnabled;
  78807. /**
  78808. * Gets wether the color grading effect is enabled.
  78809. */
  78810. get colorGradingEnabled(): boolean;
  78811. /**
  78812. * Sets wether the color grading effect is enabled.
  78813. */
  78814. set colorGradingEnabled(value: boolean);
  78815. private _colorGradingWithGreenDepth;
  78816. /**
  78817. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  78818. */
  78819. get colorGradingWithGreenDepth(): boolean;
  78820. /**
  78821. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  78822. */
  78823. set colorGradingWithGreenDepth(value: boolean);
  78824. private _colorGradingBGR;
  78825. /**
  78826. * Gets wether the color grading texture contains BGR values.
  78827. */
  78828. get colorGradingBGR(): boolean;
  78829. /**
  78830. * Sets wether the color grading texture contains BGR values.
  78831. */
  78832. set colorGradingBGR(value: boolean);
  78833. /** @hidden */
  78834. _exposure: number;
  78835. /**
  78836. * Gets the Exposure used in the effect.
  78837. */
  78838. get exposure(): number;
  78839. /**
  78840. * Sets the Exposure used in the effect.
  78841. */
  78842. set exposure(value: number);
  78843. private _toneMappingEnabled;
  78844. /**
  78845. * Gets wether the tone mapping effect is enabled.
  78846. */
  78847. get toneMappingEnabled(): boolean;
  78848. /**
  78849. * Sets wether the tone mapping effect is enabled.
  78850. */
  78851. set toneMappingEnabled(value: boolean);
  78852. private _toneMappingType;
  78853. /**
  78854. * Gets the type of tone mapping effect.
  78855. */
  78856. get toneMappingType(): number;
  78857. /**
  78858. * Sets the type of tone mapping effect used in BabylonJS.
  78859. */
  78860. set toneMappingType(value: number);
  78861. protected _contrast: number;
  78862. /**
  78863. * Gets the contrast used in the effect.
  78864. */
  78865. get contrast(): number;
  78866. /**
  78867. * Sets the contrast used in the effect.
  78868. */
  78869. set contrast(value: number);
  78870. /**
  78871. * Vignette stretch size.
  78872. */
  78873. vignetteStretch: number;
  78874. /**
  78875. * Vignette centre X Offset.
  78876. */
  78877. vignetteCentreX: number;
  78878. /**
  78879. * Vignette centre Y Offset.
  78880. */
  78881. vignetteCentreY: number;
  78882. /**
  78883. * Vignette weight or intensity of the vignette effect.
  78884. */
  78885. vignetteWeight: number;
  78886. /**
  78887. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  78888. * if vignetteEnabled is set to true.
  78889. */
  78890. vignetteColor: Color4;
  78891. /**
  78892. * Camera field of view used by the Vignette effect.
  78893. */
  78894. vignetteCameraFov: number;
  78895. private _vignetteBlendMode;
  78896. /**
  78897. * Gets the vignette blend mode allowing different kind of effect.
  78898. */
  78899. get vignetteBlendMode(): number;
  78900. /**
  78901. * Sets the vignette blend mode allowing different kind of effect.
  78902. */
  78903. set vignetteBlendMode(value: number);
  78904. private _vignetteEnabled;
  78905. /**
  78906. * Gets wether the vignette effect is enabled.
  78907. */
  78908. get vignetteEnabled(): boolean;
  78909. /**
  78910. * Sets wether the vignette effect is enabled.
  78911. */
  78912. set vignetteEnabled(value: boolean);
  78913. private _applyByPostProcess;
  78914. /**
  78915. * Gets wether the image processing is applied through a post process or not.
  78916. */
  78917. get applyByPostProcess(): boolean;
  78918. /**
  78919. * Sets wether the image processing is applied through a post process or not.
  78920. */
  78921. set applyByPostProcess(value: boolean);
  78922. private _isEnabled;
  78923. /**
  78924. * Gets wether the image processing is enabled or not.
  78925. */
  78926. get isEnabled(): boolean;
  78927. /**
  78928. * Sets wether the image processing is enabled or not.
  78929. */
  78930. set isEnabled(value: boolean);
  78931. /**
  78932. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  78933. */
  78934. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  78935. /**
  78936. * Method called each time the image processing information changes requires to recompile the effect.
  78937. */
  78938. protected _updateParameters(): void;
  78939. /**
  78940. * Gets the current class name.
  78941. * @return "ImageProcessingConfiguration"
  78942. */
  78943. getClassName(): string;
  78944. /**
  78945. * Prepare the list of uniforms associated with the Image Processing effects.
  78946. * @param uniforms The list of uniforms used in the effect
  78947. * @param defines the list of defines currently in use
  78948. */
  78949. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  78950. /**
  78951. * Prepare the list of samplers associated with the Image Processing effects.
  78952. * @param samplersList The list of uniforms used in the effect
  78953. * @param defines the list of defines currently in use
  78954. */
  78955. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  78956. /**
  78957. * Prepare the list of defines associated to the shader.
  78958. * @param defines the list of defines to complete
  78959. * @param forPostProcess Define if we are currently in post process mode or not
  78960. */
  78961. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  78962. /**
  78963. * Returns true if all the image processing information are ready.
  78964. * @returns True if ready, otherwise, false
  78965. */
  78966. isReady(): boolean;
  78967. /**
  78968. * Binds the image processing to the shader.
  78969. * @param effect The effect to bind to
  78970. * @param overrideAspectRatio Override the aspect ratio of the effect
  78971. */
  78972. bind(effect: Effect, overrideAspectRatio?: number): void;
  78973. /**
  78974. * Clones the current image processing instance.
  78975. * @return The cloned image processing
  78976. */
  78977. clone(): ImageProcessingConfiguration;
  78978. /**
  78979. * Serializes the current image processing instance to a json representation.
  78980. * @return a JSON representation
  78981. */
  78982. serialize(): any;
  78983. /**
  78984. * Parses the image processing from a json representation.
  78985. * @param source the JSON source to parse
  78986. * @return The parsed image processing
  78987. */
  78988. static Parse(source: any): ImageProcessingConfiguration;
  78989. private static _VIGNETTEMODE_MULTIPLY;
  78990. private static _VIGNETTEMODE_OPAQUE;
  78991. /**
  78992. * Used to apply the vignette as a mix with the pixel color.
  78993. */
  78994. static get VIGNETTEMODE_MULTIPLY(): number;
  78995. /**
  78996. * Used to apply the vignette as a replacement of the pixel color.
  78997. */
  78998. static get VIGNETTEMODE_OPAQUE(): number;
  78999. }
  79000. }
  79001. declare module BABYLON {
  79002. /** @hidden */
  79003. export var postprocessVertexShader: {
  79004. name: string;
  79005. shader: string;
  79006. };
  79007. }
  79008. declare module BABYLON {
  79009. interface ThinEngine {
  79010. /**
  79011. * Creates a new render target texture
  79012. * @param size defines the size of the texture
  79013. * @param options defines the options used to create the texture
  79014. * @returns a new render target texture stored in an InternalTexture
  79015. */
  79016. createRenderTargetTexture(size: number | {
  79017. width: number;
  79018. height: number;
  79019. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  79020. /**
  79021. * Creates a depth stencil texture.
  79022. * This is only available in WebGL 2 or with the depth texture extension available.
  79023. * @param size The size of face edge in the texture.
  79024. * @param options The options defining the texture.
  79025. * @returns The texture
  79026. */
  79027. createDepthStencilTexture(size: number | {
  79028. width: number;
  79029. height: number;
  79030. }, options: DepthTextureCreationOptions): InternalTexture;
  79031. /** @hidden */
  79032. _createDepthStencilTexture(size: number | {
  79033. width: number;
  79034. height: number;
  79035. }, options: DepthTextureCreationOptions): InternalTexture;
  79036. }
  79037. }
  79038. declare module BABYLON {
  79039. /** Defines supported spaces */
  79040. export enum Space {
  79041. /** Local (object) space */
  79042. LOCAL = 0,
  79043. /** World space */
  79044. WORLD = 1,
  79045. /** Bone space */
  79046. BONE = 2
  79047. }
  79048. /** Defines the 3 main axes */
  79049. export class Axis {
  79050. /** X axis */
  79051. static X: Vector3;
  79052. /** Y axis */
  79053. static Y: Vector3;
  79054. /** Z axis */
  79055. static Z: Vector3;
  79056. }
  79057. }
  79058. declare module BABYLON {
  79059. /**
  79060. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79061. * This is the base of the follow, arc rotate cameras and Free camera
  79062. * @see http://doc.babylonjs.com/features/cameras
  79063. */
  79064. export class TargetCamera extends Camera {
  79065. private static _RigCamTransformMatrix;
  79066. private static _TargetTransformMatrix;
  79067. private static _TargetFocalPoint;
  79068. /**
  79069. * Define the current direction the camera is moving to
  79070. */
  79071. cameraDirection: Vector3;
  79072. /**
  79073. * Define the current rotation the camera is rotating to
  79074. */
  79075. cameraRotation: Vector2;
  79076. /**
  79077. * When set, the up vector of the camera will be updated by the rotation of the camera
  79078. */
  79079. updateUpVectorFromRotation: boolean;
  79080. private _tmpQuaternion;
  79081. /**
  79082. * Define the current rotation of the camera
  79083. */
  79084. rotation: Vector3;
  79085. /**
  79086. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79087. */
  79088. rotationQuaternion: Quaternion;
  79089. /**
  79090. * Define the current speed of the camera
  79091. */
  79092. speed: number;
  79093. /**
  79094. * Add constraint to the camera to prevent it to move freely in all directions and
  79095. * around all axis.
  79096. */
  79097. noRotationConstraint: boolean;
  79098. /**
  79099. * Define the current target of the camera as an object or a position.
  79100. */
  79101. lockedTarget: any;
  79102. /** @hidden */
  79103. _currentTarget: Vector3;
  79104. /** @hidden */
  79105. _initialFocalDistance: number;
  79106. /** @hidden */
  79107. _viewMatrix: Matrix;
  79108. /** @hidden */
  79109. _camMatrix: Matrix;
  79110. /** @hidden */
  79111. _cameraTransformMatrix: Matrix;
  79112. /** @hidden */
  79113. _cameraRotationMatrix: Matrix;
  79114. /** @hidden */
  79115. _referencePoint: Vector3;
  79116. /** @hidden */
  79117. _transformedReferencePoint: Vector3;
  79118. protected _globalCurrentTarget: Vector3;
  79119. protected _globalCurrentUpVector: Vector3;
  79120. /** @hidden */
  79121. _reset: () => void;
  79122. private _defaultUp;
  79123. /**
  79124. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79125. * This is the base of the follow, arc rotate cameras and Free camera
  79126. * @see http://doc.babylonjs.com/features/cameras
  79127. * @param name Defines the name of the camera in the scene
  79128. * @param position Defines the start position of the camera in the scene
  79129. * @param scene Defines the scene the camera belongs to
  79130. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79131. */
  79132. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79133. /**
  79134. * Gets the position in front of the camera at a given distance.
  79135. * @param distance The distance from the camera we want the position to be
  79136. * @returns the position
  79137. */
  79138. getFrontPosition(distance: number): Vector3;
  79139. /** @hidden */
  79140. _getLockedTargetPosition(): Nullable<Vector3>;
  79141. private _storedPosition;
  79142. private _storedRotation;
  79143. private _storedRotationQuaternion;
  79144. /**
  79145. * Store current camera state of the camera (fov, position, rotation, etc..)
  79146. * @returns the camera
  79147. */
  79148. storeState(): Camera;
  79149. /**
  79150. * Restored camera state. You must call storeState() first
  79151. * @returns whether it was successful or not
  79152. * @hidden
  79153. */
  79154. _restoreStateValues(): boolean;
  79155. /** @hidden */
  79156. _initCache(): void;
  79157. /** @hidden */
  79158. _updateCache(ignoreParentClass?: boolean): void;
  79159. /** @hidden */
  79160. _isSynchronizedViewMatrix(): boolean;
  79161. /** @hidden */
  79162. _computeLocalCameraSpeed(): number;
  79163. /**
  79164. * Defines the target the camera should look at.
  79165. * @param target Defines the new target as a Vector or a mesh
  79166. */
  79167. setTarget(target: Vector3): void;
  79168. /**
  79169. * Return the current target position of the camera. This value is expressed in local space.
  79170. * @returns the target position
  79171. */
  79172. getTarget(): Vector3;
  79173. /** @hidden */
  79174. _decideIfNeedsToMove(): boolean;
  79175. /** @hidden */
  79176. _updatePosition(): void;
  79177. /** @hidden */
  79178. _checkInputs(): void;
  79179. protected _updateCameraRotationMatrix(): void;
  79180. /**
  79181. * 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)
  79182. * @returns the current camera
  79183. */
  79184. private _rotateUpVectorWithCameraRotationMatrix;
  79185. private _cachedRotationZ;
  79186. private _cachedQuaternionRotationZ;
  79187. /** @hidden */
  79188. _getViewMatrix(): Matrix;
  79189. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  79190. /**
  79191. * @hidden
  79192. */
  79193. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  79194. /**
  79195. * @hidden
  79196. */
  79197. _updateRigCameras(): void;
  79198. private _getRigCamPositionAndTarget;
  79199. /**
  79200. * Gets the current object class name.
  79201. * @return the class name
  79202. */
  79203. getClassName(): string;
  79204. }
  79205. }
  79206. declare module BABYLON {
  79207. /**
  79208. * Gather the list of keyboard event types as constants.
  79209. */
  79210. export class KeyboardEventTypes {
  79211. /**
  79212. * The keydown event is fired when a key becomes active (pressed).
  79213. */
  79214. static readonly KEYDOWN: number;
  79215. /**
  79216. * The keyup event is fired when a key has been released.
  79217. */
  79218. static readonly KEYUP: number;
  79219. }
  79220. /**
  79221. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79222. */
  79223. export class KeyboardInfo {
  79224. /**
  79225. * Defines the type of event (KeyboardEventTypes)
  79226. */
  79227. type: number;
  79228. /**
  79229. * Defines the related dom event
  79230. */
  79231. event: KeyboardEvent;
  79232. /**
  79233. * Instantiates a new keyboard info.
  79234. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79235. * @param type Defines the type of event (KeyboardEventTypes)
  79236. * @param event Defines the related dom event
  79237. */
  79238. constructor(
  79239. /**
  79240. * Defines the type of event (KeyboardEventTypes)
  79241. */
  79242. type: number,
  79243. /**
  79244. * Defines the related dom event
  79245. */
  79246. event: KeyboardEvent);
  79247. }
  79248. /**
  79249. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79250. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  79251. */
  79252. export class KeyboardInfoPre extends KeyboardInfo {
  79253. /**
  79254. * Defines the type of event (KeyboardEventTypes)
  79255. */
  79256. type: number;
  79257. /**
  79258. * Defines the related dom event
  79259. */
  79260. event: KeyboardEvent;
  79261. /**
  79262. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  79263. */
  79264. skipOnPointerObservable: boolean;
  79265. /**
  79266. * Instantiates a new keyboard pre info.
  79267. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79268. * @param type Defines the type of event (KeyboardEventTypes)
  79269. * @param event Defines the related dom event
  79270. */
  79271. constructor(
  79272. /**
  79273. * Defines the type of event (KeyboardEventTypes)
  79274. */
  79275. type: number,
  79276. /**
  79277. * Defines the related dom event
  79278. */
  79279. event: KeyboardEvent);
  79280. }
  79281. }
  79282. declare module BABYLON {
  79283. /**
  79284. * Manage the keyboard inputs to control the movement of a free camera.
  79285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79286. */
  79287. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  79288. /**
  79289. * Defines the camera the input is attached to.
  79290. */
  79291. camera: FreeCamera;
  79292. /**
  79293. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79294. */
  79295. keysUp: number[];
  79296. /**
  79297. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79298. */
  79299. keysDown: number[];
  79300. /**
  79301. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79302. */
  79303. keysLeft: number[];
  79304. /**
  79305. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79306. */
  79307. keysRight: number[];
  79308. private _keys;
  79309. private _onCanvasBlurObserver;
  79310. private _onKeyboardObserver;
  79311. private _engine;
  79312. private _scene;
  79313. /**
  79314. * Attach the input controls to a specific dom element to get the input from.
  79315. * @param element Defines the element the controls should be listened from
  79316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79317. */
  79318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79319. /**
  79320. * Detach the current controls from the specified dom element.
  79321. * @param element Defines the element to stop listening the inputs from
  79322. */
  79323. detachControl(element: Nullable<HTMLElement>): void;
  79324. /**
  79325. * Update the current camera state depending on the inputs that have been used this frame.
  79326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79327. */
  79328. checkInputs(): void;
  79329. /**
  79330. * Gets the class name of the current intput.
  79331. * @returns the class name
  79332. */
  79333. getClassName(): string;
  79334. /** @hidden */
  79335. _onLostFocus(): void;
  79336. /**
  79337. * Get the friendly name associated with the input class.
  79338. * @returns the input friendly name
  79339. */
  79340. getSimpleName(): string;
  79341. }
  79342. }
  79343. declare module BABYLON {
  79344. /**
  79345. * Interface describing all the common properties and methods a shadow light needs to implement.
  79346. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  79347. * as well as binding the different shadow properties to the effects.
  79348. */
  79349. export interface IShadowLight extends Light {
  79350. /**
  79351. * The light id in the scene (used in scene.findLighById for instance)
  79352. */
  79353. id: string;
  79354. /**
  79355. * The position the shdow will be casted from.
  79356. */
  79357. position: Vector3;
  79358. /**
  79359. * In 2d mode (needCube being false), the direction used to cast the shadow.
  79360. */
  79361. direction: Vector3;
  79362. /**
  79363. * The transformed position. Position of the light in world space taking parenting in account.
  79364. */
  79365. transformedPosition: Vector3;
  79366. /**
  79367. * The transformed direction. Direction of the light in world space taking parenting in account.
  79368. */
  79369. transformedDirection: Vector3;
  79370. /**
  79371. * The friendly name of the light in the scene.
  79372. */
  79373. name: string;
  79374. /**
  79375. * Defines the shadow projection clipping minimum z value.
  79376. */
  79377. shadowMinZ: number;
  79378. /**
  79379. * Defines the shadow projection clipping maximum z value.
  79380. */
  79381. shadowMaxZ: number;
  79382. /**
  79383. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79384. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79385. */
  79386. computeTransformedInformation(): boolean;
  79387. /**
  79388. * Gets the scene the light belongs to.
  79389. * @returns The scene
  79390. */
  79391. getScene(): Scene;
  79392. /**
  79393. * Callback defining a custom Projection Matrix Builder.
  79394. * This can be used to override the default projection matrix computation.
  79395. */
  79396. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79397. /**
  79398. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79399. * @param matrix The materix to updated with the projection information
  79400. * @param viewMatrix The transform matrix of the light
  79401. * @param renderList The list of mesh to render in the map
  79402. * @returns The current light
  79403. */
  79404. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79405. /**
  79406. * Gets the current depth scale used in ESM.
  79407. * @returns The scale
  79408. */
  79409. getDepthScale(): number;
  79410. /**
  79411. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79412. * @returns true if a cube texture needs to be use
  79413. */
  79414. needCube(): boolean;
  79415. /**
  79416. * Detects if the projection matrix requires to be recomputed this frame.
  79417. * @returns true if it requires to be recomputed otherwise, false.
  79418. */
  79419. needProjectionMatrixCompute(): boolean;
  79420. /**
  79421. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79422. */
  79423. forceProjectionMatrixCompute(): void;
  79424. /**
  79425. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79426. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79427. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79428. */
  79429. getShadowDirection(faceIndex?: number): Vector3;
  79430. /**
  79431. * Gets the minZ used for shadow according to both the scene and the light.
  79432. * @param activeCamera The camera we are returning the min for
  79433. * @returns the depth min z
  79434. */
  79435. getDepthMinZ(activeCamera: Camera): number;
  79436. /**
  79437. * Gets the maxZ used for shadow according to both the scene and the light.
  79438. * @param activeCamera The camera we are returning the max for
  79439. * @returns the depth max z
  79440. */
  79441. getDepthMaxZ(activeCamera: Camera): number;
  79442. }
  79443. /**
  79444. * Base implementation IShadowLight
  79445. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  79446. */
  79447. export abstract class ShadowLight extends Light implements IShadowLight {
  79448. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  79449. protected _position: Vector3;
  79450. protected _setPosition(value: Vector3): void;
  79451. /**
  79452. * Sets the position the shadow will be casted from. Also use as the light position for both
  79453. * point and spot lights.
  79454. */
  79455. get position(): Vector3;
  79456. /**
  79457. * Sets the position the shadow will be casted from. Also use as the light position for both
  79458. * point and spot lights.
  79459. */
  79460. set position(value: Vector3);
  79461. protected _direction: Vector3;
  79462. protected _setDirection(value: Vector3): void;
  79463. /**
  79464. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  79465. * Also use as the light direction on spot and directional lights.
  79466. */
  79467. get direction(): Vector3;
  79468. /**
  79469. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  79470. * Also use as the light direction on spot and directional lights.
  79471. */
  79472. set direction(value: Vector3);
  79473. private _shadowMinZ;
  79474. /**
  79475. * Gets the shadow projection clipping minimum z value.
  79476. */
  79477. get shadowMinZ(): number;
  79478. /**
  79479. * Sets the shadow projection clipping minimum z value.
  79480. */
  79481. set shadowMinZ(value: number);
  79482. private _shadowMaxZ;
  79483. /**
  79484. * Sets the shadow projection clipping maximum z value.
  79485. */
  79486. get shadowMaxZ(): number;
  79487. /**
  79488. * Gets the shadow projection clipping maximum z value.
  79489. */
  79490. set shadowMaxZ(value: number);
  79491. /**
  79492. * Callback defining a custom Projection Matrix Builder.
  79493. * This can be used to override the default projection matrix computation.
  79494. */
  79495. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79496. /**
  79497. * The transformed position. Position of the light in world space taking parenting in account.
  79498. */
  79499. transformedPosition: Vector3;
  79500. /**
  79501. * The transformed direction. Direction of the light in world space taking parenting in account.
  79502. */
  79503. transformedDirection: Vector3;
  79504. private _needProjectionMatrixCompute;
  79505. /**
  79506. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79507. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79508. */
  79509. computeTransformedInformation(): boolean;
  79510. /**
  79511. * Return the depth scale used for the shadow map.
  79512. * @returns the depth scale.
  79513. */
  79514. getDepthScale(): number;
  79515. /**
  79516. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79517. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79518. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79519. */
  79520. getShadowDirection(faceIndex?: number): Vector3;
  79521. /**
  79522. * Returns the ShadowLight absolute position in the World.
  79523. * @returns the position vector in world space
  79524. */
  79525. getAbsolutePosition(): Vector3;
  79526. /**
  79527. * Sets the ShadowLight direction toward the passed target.
  79528. * @param target The point to target in local space
  79529. * @returns the updated ShadowLight direction
  79530. */
  79531. setDirectionToTarget(target: Vector3): Vector3;
  79532. /**
  79533. * Returns the light rotation in euler definition.
  79534. * @returns the x y z rotation in local space.
  79535. */
  79536. getRotation(): Vector3;
  79537. /**
  79538. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79539. * @returns true if a cube texture needs to be use
  79540. */
  79541. needCube(): boolean;
  79542. /**
  79543. * Detects if the projection matrix requires to be recomputed this frame.
  79544. * @returns true if it requires to be recomputed otherwise, false.
  79545. */
  79546. needProjectionMatrixCompute(): boolean;
  79547. /**
  79548. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79549. */
  79550. forceProjectionMatrixCompute(): void;
  79551. /** @hidden */
  79552. _initCache(): void;
  79553. /** @hidden */
  79554. _isSynchronized(): boolean;
  79555. /**
  79556. * Computes the world matrix of the node
  79557. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79558. * @returns the world matrix
  79559. */
  79560. computeWorldMatrix(force?: boolean): Matrix;
  79561. /**
  79562. * Gets the minZ used for shadow according to both the scene and the light.
  79563. * @param activeCamera The camera we are returning the min for
  79564. * @returns the depth min z
  79565. */
  79566. getDepthMinZ(activeCamera: Camera): number;
  79567. /**
  79568. * Gets the maxZ used for shadow according to both the scene and the light.
  79569. * @param activeCamera The camera we are returning the max for
  79570. * @returns the depth max z
  79571. */
  79572. getDepthMaxZ(activeCamera: Camera): number;
  79573. /**
  79574. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79575. * @param matrix The materix to updated with the projection information
  79576. * @param viewMatrix The transform matrix of the light
  79577. * @param renderList The list of mesh to render in the map
  79578. * @returns The current light
  79579. */
  79580. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79581. }
  79582. }
  79583. declare module BABYLON {
  79584. /**
  79585. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  79586. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  79587. */
  79588. export class EffectFallbacks implements IEffectFallbacks {
  79589. private _defines;
  79590. private _currentRank;
  79591. private _maxRank;
  79592. private _mesh;
  79593. /**
  79594. * Removes the fallback from the bound mesh.
  79595. */
  79596. unBindMesh(): void;
  79597. /**
  79598. * Adds a fallback on the specified property.
  79599. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79600. * @param define The name of the define in the shader
  79601. */
  79602. addFallback(rank: number, define: string): void;
  79603. /**
  79604. * Sets the mesh to use CPU skinning when needing to fallback.
  79605. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79606. * @param mesh The mesh to use the fallbacks.
  79607. */
  79608. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  79609. /**
  79610. * Checks to see if more fallbacks are still availible.
  79611. */
  79612. get hasMoreFallbacks(): boolean;
  79613. /**
  79614. * Removes the defines that should be removed when falling back.
  79615. * @param currentDefines defines the current define statements for the shader.
  79616. * @param effect defines the current effect we try to compile
  79617. * @returns The resulting defines with defines of the current rank removed.
  79618. */
  79619. reduce(currentDefines: string, effect: Effect): string;
  79620. }
  79621. }
  79622. declare module BABYLON {
  79623. /**
  79624. * "Static Class" containing the most commonly used helper while dealing with material for
  79625. * rendering purpose.
  79626. *
  79627. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  79628. *
  79629. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  79630. */
  79631. export class MaterialHelper {
  79632. /**
  79633. * Bind the current view position to an effect.
  79634. * @param effect The effect to be bound
  79635. * @param scene The scene the eyes position is used from
  79636. */
  79637. static BindEyePosition(effect: Effect, scene: Scene): void;
  79638. /**
  79639. * Helps preparing the defines values about the UVs in used in the effect.
  79640. * UVs are shared as much as we can accross channels in the shaders.
  79641. * @param texture The texture we are preparing the UVs for
  79642. * @param defines The defines to update
  79643. * @param key The channel key "diffuse", "specular"... used in the shader
  79644. */
  79645. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  79646. /**
  79647. * Binds a texture matrix value to its corrsponding uniform
  79648. * @param texture The texture to bind the matrix for
  79649. * @param uniformBuffer The uniform buffer receivin the data
  79650. * @param key The channel key "diffuse", "specular"... used in the shader
  79651. */
  79652. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  79653. /**
  79654. * Gets the current status of the fog (should it be enabled?)
  79655. * @param mesh defines the mesh to evaluate for fog support
  79656. * @param scene defines the hosting scene
  79657. * @returns true if fog must be enabled
  79658. */
  79659. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  79660. /**
  79661. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  79662. * @param mesh defines the current mesh
  79663. * @param scene defines the current scene
  79664. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  79665. * @param pointsCloud defines if point cloud rendering has to be turned on
  79666. * @param fogEnabled defines if fog has to be turned on
  79667. * @param alphaTest defines if alpha testing has to be turned on
  79668. * @param defines defines the current list of defines
  79669. */
  79670. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  79671. /**
  79672. * Helper used to prepare the list of defines associated with frame values for shader compilation
  79673. * @param scene defines the current scene
  79674. * @param engine defines the current engine
  79675. * @param defines specifies the list of active defines
  79676. * @param useInstances defines if instances have to be turned on
  79677. * @param useClipPlane defines if clip plane have to be turned on
  79678. */
  79679. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  79680. /**
  79681. * Prepares the defines for bones
  79682. * @param mesh The mesh containing the geometry data we will draw
  79683. * @param defines The defines to update
  79684. */
  79685. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  79686. /**
  79687. * Prepares the defines for morph targets
  79688. * @param mesh The mesh containing the geometry data we will draw
  79689. * @param defines The defines to update
  79690. */
  79691. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  79692. /**
  79693. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  79694. * @param mesh The mesh containing the geometry data we will draw
  79695. * @param defines The defines to update
  79696. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  79697. * @param useBones Precise whether bones should be used or not (override mesh info)
  79698. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  79699. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  79700. * @returns false if defines are considered not dirty and have not been checked
  79701. */
  79702. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  79703. /**
  79704. * Prepares the defines related to multiview
  79705. * @param scene The scene we are intending to draw
  79706. * @param defines The defines to update
  79707. */
  79708. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  79709. /**
  79710. * Prepares the defines related to the light information passed in parameter
  79711. * @param scene The scene we are intending to draw
  79712. * @param mesh The mesh the effect is compiling for
  79713. * @param light The light the effect is compiling for
  79714. * @param lightIndex The index of the light
  79715. * @param defines The defines to update
  79716. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79717. * @param state Defines the current state regarding what is needed (normals, etc...)
  79718. */
  79719. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  79720. needNormals: boolean;
  79721. needRebuild: boolean;
  79722. shadowEnabled: boolean;
  79723. specularEnabled: boolean;
  79724. lightmapMode: boolean;
  79725. }): void;
  79726. /**
  79727. * Prepares the defines related to the light information passed in parameter
  79728. * @param scene The scene we are intending to draw
  79729. * @param mesh The mesh the effect is compiling for
  79730. * @param defines The defines to update
  79731. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79732. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  79733. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  79734. * @returns true if normals will be required for the rest of the effect
  79735. */
  79736. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  79737. /**
  79738. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  79739. * @param lightIndex defines the light index
  79740. * @param uniformsList The uniform list
  79741. * @param samplersList The sampler list
  79742. * @param projectedLightTexture defines if projected texture must be used
  79743. * @param uniformBuffersList defines an optional list of uniform buffers
  79744. */
  79745. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  79746. /**
  79747. * Prepares the uniforms and samplers list to be used in the effect
  79748. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  79749. * @param samplersList The sampler list
  79750. * @param defines The defines helping in the list generation
  79751. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  79752. */
  79753. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  79754. /**
  79755. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  79756. * @param defines The defines to update while falling back
  79757. * @param fallbacks The authorized effect fallbacks
  79758. * @param maxSimultaneousLights The maximum number of lights allowed
  79759. * @param rank the current rank of the Effect
  79760. * @returns The newly affected rank
  79761. */
  79762. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  79763. private static _TmpMorphInfluencers;
  79764. /**
  79765. * Prepares the list of attributes required for morph targets according to the effect defines.
  79766. * @param attribs The current list of supported attribs
  79767. * @param mesh The mesh to prepare the morph targets attributes for
  79768. * @param influencers The number of influencers
  79769. */
  79770. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  79771. /**
  79772. * Prepares the list of attributes required for morph targets according to the effect defines.
  79773. * @param attribs The current list of supported attribs
  79774. * @param mesh The mesh to prepare the morph targets attributes for
  79775. * @param defines The current Defines of the effect
  79776. */
  79777. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  79778. /**
  79779. * Prepares the list of attributes required for bones according to the effect defines.
  79780. * @param attribs The current list of supported attribs
  79781. * @param mesh The mesh to prepare the bones attributes for
  79782. * @param defines The current Defines of the effect
  79783. * @param fallbacks The current efffect fallback strategy
  79784. */
  79785. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  79786. /**
  79787. * Check and prepare the list of attributes required for instances according to the effect defines.
  79788. * @param attribs The current list of supported attribs
  79789. * @param defines The current MaterialDefines of the effect
  79790. */
  79791. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  79792. /**
  79793. * Add the list of attributes required for instances to the attribs array.
  79794. * @param attribs The current list of supported attribs
  79795. */
  79796. static PushAttributesForInstances(attribs: string[]): void;
  79797. /**
  79798. * Binds the light information to the effect.
  79799. * @param light The light containing the generator
  79800. * @param effect The effect we are binding the data to
  79801. * @param lightIndex The light index in the effect used to render
  79802. */
  79803. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  79804. /**
  79805. * Binds the lights information from the scene to the effect for the given mesh.
  79806. * @param light Light to bind
  79807. * @param lightIndex Light index
  79808. * @param scene The scene where the light belongs to
  79809. * @param effect The effect we are binding the data to
  79810. * @param useSpecular Defines if specular is supported
  79811. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79812. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79813. */
  79814. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79815. /**
  79816. * Binds the lights information from the scene to the effect for the given mesh.
  79817. * @param scene The scene the lights belongs to
  79818. * @param mesh The mesh we are binding the information to render
  79819. * @param effect The effect we are binding the data to
  79820. * @param defines The generated defines for the effect
  79821. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  79822. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79823. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79824. */
  79825. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79826. private static _tempFogColor;
  79827. /**
  79828. * Binds the fog information from the scene to the effect for the given mesh.
  79829. * @param scene The scene the lights belongs to
  79830. * @param mesh The mesh we are binding the information to render
  79831. * @param effect The effect we are binding the data to
  79832. * @param linearSpace Defines if the fog effect is applied in linear space
  79833. */
  79834. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  79835. /**
  79836. * Binds the bones information from the mesh to the effect.
  79837. * @param mesh The mesh we are binding the information to render
  79838. * @param effect The effect we are binding the data to
  79839. */
  79840. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  79841. /**
  79842. * Binds the morph targets information from the mesh to the effect.
  79843. * @param abstractMesh The mesh we are binding the information to render
  79844. * @param effect The effect we are binding the data to
  79845. */
  79846. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  79847. /**
  79848. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  79849. * @param defines The generated defines used in the effect
  79850. * @param effect The effect we are binding the data to
  79851. * @param scene The scene we are willing to render with logarithmic scale for
  79852. */
  79853. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  79854. /**
  79855. * Binds the clip plane information from the scene to the effect.
  79856. * @param scene The scene the clip plane information are extracted from
  79857. * @param effect The effect we are binding the data to
  79858. */
  79859. static BindClipPlane(effect: Effect, scene: Scene): void;
  79860. }
  79861. }
  79862. declare module BABYLON {
  79863. /** @hidden */
  79864. export var packingFunctions: {
  79865. name: string;
  79866. shader: string;
  79867. };
  79868. }
  79869. declare module BABYLON {
  79870. /** @hidden */
  79871. export var shadowMapPixelShader: {
  79872. name: string;
  79873. shader: string;
  79874. };
  79875. }
  79876. declare module BABYLON {
  79877. /** @hidden */
  79878. export var bonesDeclaration: {
  79879. name: string;
  79880. shader: string;
  79881. };
  79882. }
  79883. declare module BABYLON {
  79884. /** @hidden */
  79885. export var morphTargetsVertexGlobalDeclaration: {
  79886. name: string;
  79887. shader: string;
  79888. };
  79889. }
  79890. declare module BABYLON {
  79891. /** @hidden */
  79892. export var morphTargetsVertexDeclaration: {
  79893. name: string;
  79894. shader: string;
  79895. };
  79896. }
  79897. declare module BABYLON {
  79898. /** @hidden */
  79899. export var instancesDeclaration: {
  79900. name: string;
  79901. shader: string;
  79902. };
  79903. }
  79904. declare module BABYLON {
  79905. /** @hidden */
  79906. export var helperFunctions: {
  79907. name: string;
  79908. shader: string;
  79909. };
  79910. }
  79911. declare module BABYLON {
  79912. /** @hidden */
  79913. export var morphTargetsVertex: {
  79914. name: string;
  79915. shader: string;
  79916. };
  79917. }
  79918. declare module BABYLON {
  79919. /** @hidden */
  79920. export var instancesVertex: {
  79921. name: string;
  79922. shader: string;
  79923. };
  79924. }
  79925. declare module BABYLON {
  79926. /** @hidden */
  79927. export var bonesVertex: {
  79928. name: string;
  79929. shader: string;
  79930. };
  79931. }
  79932. declare module BABYLON {
  79933. /** @hidden */
  79934. export var shadowMapVertexShader: {
  79935. name: string;
  79936. shader: string;
  79937. };
  79938. }
  79939. declare module BABYLON {
  79940. /** @hidden */
  79941. export var depthBoxBlurPixelShader: {
  79942. name: string;
  79943. shader: string;
  79944. };
  79945. }
  79946. declare module BABYLON {
  79947. /**
  79948. * Defines the options associated with the creation of a custom shader for a shadow generator.
  79949. */
  79950. export interface ICustomShaderOptions {
  79951. /**
  79952. * Gets or sets the custom shader name to use
  79953. */
  79954. shaderName: string;
  79955. /**
  79956. * The list of attribute names used in the shader
  79957. */
  79958. attributes?: string[];
  79959. /**
  79960. * The list of unifrom names used in the shader
  79961. */
  79962. uniforms?: string[];
  79963. /**
  79964. * The list of sampler names used in the shader
  79965. */
  79966. samplers?: string[];
  79967. /**
  79968. * The list of defines used in the shader
  79969. */
  79970. defines?: string[];
  79971. }
  79972. /**
  79973. * Interface to implement to create a shadow generator compatible with BJS.
  79974. */
  79975. export interface IShadowGenerator {
  79976. /**
  79977. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  79978. * @returns The render target texture if present otherwise, null
  79979. */
  79980. getShadowMap(): Nullable<RenderTargetTexture>;
  79981. /**
  79982. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  79983. * @returns The render target texture if the shadow map is present otherwise, null
  79984. */
  79985. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  79986. /**
  79987. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  79988. * @param subMesh The submesh we want to render in the shadow map
  79989. * @param useInstances Defines wether will draw in the map using instances
  79990. * @returns true if ready otherwise, false
  79991. */
  79992. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  79993. /**
  79994. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  79995. * @param defines Defines of the material we want to update
  79996. * @param lightIndex Index of the light in the enabled light list of the material
  79997. */
  79998. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  79999. /**
  80000. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80001. * defined in the generator but impacting the effect).
  80002. * It implies the unifroms available on the materials are the standard BJS ones.
  80003. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80004. * @param effect The effect we are binfing the information for
  80005. */
  80006. bindShadowLight(lightIndex: string, effect: Effect): void;
  80007. /**
  80008. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80009. * (eq to shadow prjection matrix * light transform matrix)
  80010. * @returns The transform matrix used to create the shadow map
  80011. */
  80012. getTransformMatrix(): Matrix;
  80013. /**
  80014. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80015. * Cube and 2D textures for instance.
  80016. */
  80017. recreateShadowMap(): void;
  80018. /**
  80019. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80020. * @param onCompiled Callback triggered at the and of the effects compilation
  80021. * @param options Sets of optional options forcing the compilation with different modes
  80022. */
  80023. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80024. useInstances: boolean;
  80025. }>): void;
  80026. /**
  80027. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80028. * @param options Sets of optional options forcing the compilation with different modes
  80029. * @returns A promise that resolves when the compilation completes
  80030. */
  80031. forceCompilationAsync(options?: Partial<{
  80032. useInstances: boolean;
  80033. }>): Promise<void>;
  80034. /**
  80035. * Serializes the shadow generator setup to a json object.
  80036. * @returns The serialized JSON object
  80037. */
  80038. serialize(): any;
  80039. /**
  80040. * Disposes the Shadow map and related Textures and effects.
  80041. */
  80042. dispose(): void;
  80043. }
  80044. /**
  80045. * Default implementation IShadowGenerator.
  80046. * This is the main object responsible of generating shadows in the framework.
  80047. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80048. */
  80049. export class ShadowGenerator implements IShadowGenerator {
  80050. /**
  80051. * Shadow generator mode None: no filtering applied.
  80052. */
  80053. static readonly FILTER_NONE: number;
  80054. /**
  80055. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80056. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80057. */
  80058. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80059. /**
  80060. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80061. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80062. */
  80063. static readonly FILTER_POISSONSAMPLING: number;
  80064. /**
  80065. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80066. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80067. */
  80068. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80069. /**
  80070. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80071. * edge artifacts on steep falloff.
  80072. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80073. */
  80074. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80075. /**
  80076. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80077. * edge artifacts on steep falloff.
  80078. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80079. */
  80080. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80081. /**
  80082. * Shadow generator mode PCF: Percentage Closer Filtering
  80083. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80084. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80085. */
  80086. static readonly FILTER_PCF: number;
  80087. /**
  80088. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80089. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80090. * Contact Hardening
  80091. */
  80092. static readonly FILTER_PCSS: number;
  80093. /**
  80094. * Reserved for PCF and PCSS
  80095. * Highest Quality.
  80096. *
  80097. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80098. *
  80099. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80100. */
  80101. static readonly QUALITY_HIGH: number;
  80102. /**
  80103. * Reserved for PCF and PCSS
  80104. * Good tradeoff for quality/perf cross devices
  80105. *
  80106. * Execute PCF on a 3*3 kernel.
  80107. *
  80108. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80109. */
  80110. static readonly QUALITY_MEDIUM: number;
  80111. /**
  80112. * Reserved for PCF and PCSS
  80113. * The lowest quality but the fastest.
  80114. *
  80115. * Execute PCF on a 1*1 kernel.
  80116. *
  80117. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80118. */
  80119. static readonly QUALITY_LOW: number;
  80120. /** Gets or sets the custom shader name to use */
  80121. customShaderOptions: ICustomShaderOptions;
  80122. /**
  80123. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80124. */
  80125. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80126. /**
  80127. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80128. */
  80129. onAfterShadowMapRenderObservable: Observable<Effect>;
  80130. /**
  80131. * Observable triggered before a mesh is rendered in the shadow map.
  80132. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80133. */
  80134. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80135. /**
  80136. * Observable triggered after a mesh is rendered in the shadow map.
  80137. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80138. */
  80139. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80140. private _bias;
  80141. /**
  80142. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80143. */
  80144. get bias(): number;
  80145. /**
  80146. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80147. */
  80148. set bias(bias: number);
  80149. private _normalBias;
  80150. /**
  80151. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80152. */
  80153. get normalBias(): number;
  80154. /**
  80155. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80156. */
  80157. set normalBias(normalBias: number);
  80158. private _blurBoxOffset;
  80159. /**
  80160. * Gets the blur box offset: offset applied during the blur pass.
  80161. * Only useful if useKernelBlur = false
  80162. */
  80163. get blurBoxOffset(): number;
  80164. /**
  80165. * Sets the blur box offset: offset applied during the blur pass.
  80166. * Only useful if useKernelBlur = false
  80167. */
  80168. set blurBoxOffset(value: number);
  80169. private _blurScale;
  80170. /**
  80171. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80172. * 2 means half of the size.
  80173. */
  80174. get blurScale(): number;
  80175. /**
  80176. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  80177. * 2 means half of the size.
  80178. */
  80179. set blurScale(value: number);
  80180. private _blurKernel;
  80181. /**
  80182. * Gets the blur kernel: kernel size of the blur pass.
  80183. * Only useful if useKernelBlur = true
  80184. */
  80185. get blurKernel(): number;
  80186. /**
  80187. * Sets the blur kernel: kernel size of the blur pass.
  80188. * Only useful if useKernelBlur = true
  80189. */
  80190. set blurKernel(value: number);
  80191. private _useKernelBlur;
  80192. /**
  80193. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  80194. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80195. */
  80196. get useKernelBlur(): boolean;
  80197. /**
  80198. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  80199. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80200. */
  80201. set useKernelBlur(value: boolean);
  80202. private _depthScale;
  80203. /**
  80204. * Gets the depth scale used in ESM mode.
  80205. */
  80206. get depthScale(): number;
  80207. /**
  80208. * Sets the depth scale used in ESM mode.
  80209. * This can override the scale stored on the light.
  80210. */
  80211. set depthScale(value: number);
  80212. private _filter;
  80213. /**
  80214. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  80215. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80216. */
  80217. get filter(): number;
  80218. /**
  80219. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  80220. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80221. */
  80222. set filter(value: number);
  80223. /**
  80224. * Gets if the current filter is set to Poisson Sampling.
  80225. */
  80226. get usePoissonSampling(): boolean;
  80227. /**
  80228. * Sets the current filter to Poisson Sampling.
  80229. */
  80230. set usePoissonSampling(value: boolean);
  80231. /**
  80232. * Gets if the current filter is set to ESM.
  80233. */
  80234. get useExponentialShadowMap(): boolean;
  80235. /**
  80236. * Sets the current filter is to ESM.
  80237. */
  80238. set useExponentialShadowMap(value: boolean);
  80239. /**
  80240. * Gets if the current filter is set to filtered ESM.
  80241. */
  80242. get useBlurExponentialShadowMap(): boolean;
  80243. /**
  80244. * Gets if the current filter is set to filtered ESM.
  80245. */
  80246. set useBlurExponentialShadowMap(value: boolean);
  80247. /**
  80248. * Gets if the current filter is set to "close ESM" (using the inverse of the
  80249. * exponential to prevent steep falloff artifacts).
  80250. */
  80251. get useCloseExponentialShadowMap(): boolean;
  80252. /**
  80253. * Sets the current filter to "close ESM" (using the inverse of the
  80254. * exponential to prevent steep falloff artifacts).
  80255. */
  80256. set useCloseExponentialShadowMap(value: boolean);
  80257. /**
  80258. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  80259. * exponential to prevent steep falloff artifacts).
  80260. */
  80261. get useBlurCloseExponentialShadowMap(): boolean;
  80262. /**
  80263. * Sets the current filter to filtered "close ESM" (using the inverse of the
  80264. * exponential to prevent steep falloff artifacts).
  80265. */
  80266. set useBlurCloseExponentialShadowMap(value: boolean);
  80267. /**
  80268. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  80269. */
  80270. get usePercentageCloserFiltering(): boolean;
  80271. /**
  80272. * Sets the current filter to "PCF" (percentage closer filtering).
  80273. */
  80274. set usePercentageCloserFiltering(value: boolean);
  80275. private _filteringQuality;
  80276. /**
  80277. * Gets the PCF or PCSS Quality.
  80278. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80279. */
  80280. get filteringQuality(): number;
  80281. /**
  80282. * Sets the PCF or PCSS Quality.
  80283. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80284. */
  80285. set filteringQuality(filteringQuality: number);
  80286. /**
  80287. * Gets if the current filter is set to "PCSS" (contact hardening).
  80288. */
  80289. get useContactHardeningShadow(): boolean;
  80290. /**
  80291. * Sets the current filter to "PCSS" (contact hardening).
  80292. */
  80293. set useContactHardeningShadow(value: boolean);
  80294. private _contactHardeningLightSizeUVRatio;
  80295. /**
  80296. * Gets 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. get contactHardeningLightSizeUVRatio(): number;
  80305. /**
  80306. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80307. * Using a ratio helps keeping shape stability independently of the map size.
  80308. *
  80309. * It does not account for the light projection as it was having too much
  80310. * instability during the light setup or during light position changes.
  80311. *
  80312. * Only valid if useContactHardeningShadow is true.
  80313. */
  80314. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  80315. private _darkness;
  80316. /** Gets or sets the actual darkness of a shadow */
  80317. get darkness(): number;
  80318. set darkness(value: number);
  80319. /**
  80320. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  80321. * 0 means strongest and 1 would means no shadow.
  80322. * @returns the darkness.
  80323. */
  80324. getDarkness(): number;
  80325. /**
  80326. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  80327. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  80328. * @returns the shadow generator allowing fluent coding.
  80329. */
  80330. setDarkness(darkness: number): ShadowGenerator;
  80331. private _transparencyShadow;
  80332. /** Gets or sets the ability to have transparent shadow */
  80333. get transparencyShadow(): boolean;
  80334. set transparencyShadow(value: boolean);
  80335. /**
  80336. * Sets the ability to have transparent shadow (boolean).
  80337. * @param transparent True if transparent else False
  80338. * @returns the shadow generator allowing fluent coding
  80339. */
  80340. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  80341. private _shadowMap;
  80342. private _shadowMap2;
  80343. /**
  80344. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80345. * @returns The render target texture if present otherwise, null
  80346. */
  80347. getShadowMap(): Nullable<RenderTargetTexture>;
  80348. /**
  80349. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80350. * @returns The render target texture if the shadow map is present otherwise, null
  80351. */
  80352. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80353. /**
  80354. * Gets the class name of that object
  80355. * @returns "ShadowGenerator"
  80356. */
  80357. getClassName(): string;
  80358. /**
  80359. * Helper function to add a mesh and its descendants to the list of shadow casters.
  80360. * @param mesh Mesh to add
  80361. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  80362. * @returns the Shadow Generator itself
  80363. */
  80364. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80365. /**
  80366. * Helper function to remove a mesh and its descendants from the list of shadow casters
  80367. * @param mesh Mesh to remove
  80368. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  80369. * @returns the Shadow Generator itself
  80370. */
  80371. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80372. /**
  80373. * Controls the extent to which the shadows fade out at the edge of the frustum
  80374. * Used only by directionals and spots
  80375. */
  80376. frustumEdgeFalloff: number;
  80377. private _light;
  80378. /**
  80379. * Returns the associated light object.
  80380. * @returns the light generating the shadow
  80381. */
  80382. getLight(): IShadowLight;
  80383. /**
  80384. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  80385. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  80386. * It might on the other hand introduce peter panning.
  80387. */
  80388. forceBackFacesOnly: boolean;
  80389. private _scene;
  80390. private _lightDirection;
  80391. private _effect;
  80392. private _viewMatrix;
  80393. private _projectionMatrix;
  80394. private _transformMatrix;
  80395. private _cachedPosition;
  80396. private _cachedDirection;
  80397. private _cachedDefines;
  80398. private _currentRenderID;
  80399. private _boxBlurPostprocess;
  80400. private _kernelBlurXPostprocess;
  80401. private _kernelBlurYPostprocess;
  80402. private _blurPostProcesses;
  80403. private _mapSize;
  80404. private _currentFaceIndex;
  80405. private _currentFaceIndexCache;
  80406. private _textureType;
  80407. private _defaultTextureMatrix;
  80408. private _storedUniqueId;
  80409. /** @hidden */
  80410. static _SceneComponentInitialization: (scene: Scene) => void;
  80411. /**
  80412. * Creates a ShadowGenerator object.
  80413. * A ShadowGenerator is the required tool to use the shadows.
  80414. * Each light casting shadows needs to use its own ShadowGenerator.
  80415. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  80416. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  80417. * @param light The light object generating the shadows.
  80418. * @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.
  80419. */
  80420. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  80421. private _initializeGenerator;
  80422. private _initializeShadowMap;
  80423. private _initializeBlurRTTAndPostProcesses;
  80424. private _renderForShadowMap;
  80425. private _renderSubMeshForShadowMap;
  80426. private _applyFilterValues;
  80427. /**
  80428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80429. * @param onCompiled Callback triggered at the and of the effects compilation
  80430. * @param options Sets of optional options forcing the compilation with different modes
  80431. */
  80432. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80433. useInstances: boolean;
  80434. }>): void;
  80435. /**
  80436. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80437. * @param options Sets of optional options forcing the compilation with different modes
  80438. * @returns A promise that resolves when the compilation completes
  80439. */
  80440. forceCompilationAsync(options?: Partial<{
  80441. useInstances: boolean;
  80442. }>): Promise<void>;
  80443. /**
  80444. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80445. * @param subMesh The submesh we want to render in the shadow map
  80446. * @param useInstances Defines wether will draw in the map using instances
  80447. * @returns true if ready otherwise, false
  80448. */
  80449. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80450. /**
  80451. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80452. * @param defines Defines of the material we want to update
  80453. * @param lightIndex Index of the light in the enabled light list of the material
  80454. */
  80455. prepareDefines(defines: any, lightIndex: number): void;
  80456. /**
  80457. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80458. * defined in the generator but impacting the effect).
  80459. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80460. * @param effect The effect we are binfing the information for
  80461. */
  80462. bindShadowLight(lightIndex: string, effect: Effect): void;
  80463. /**
  80464. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80465. * (eq to shadow prjection matrix * light transform matrix)
  80466. * @returns The transform matrix used to create the shadow map
  80467. */
  80468. getTransformMatrix(): Matrix;
  80469. /**
  80470. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80471. * Cube and 2D textures for instance.
  80472. */
  80473. recreateShadowMap(): void;
  80474. private _disposeBlurPostProcesses;
  80475. private _disposeRTTandPostProcesses;
  80476. /**
  80477. * Disposes the ShadowGenerator.
  80478. * Returns nothing.
  80479. */
  80480. dispose(): void;
  80481. /**
  80482. * Serializes the shadow generator setup to a json object.
  80483. * @returns The serialized JSON object
  80484. */
  80485. serialize(): any;
  80486. /**
  80487. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  80488. * @param parsedShadowGenerator The JSON object to parse
  80489. * @param scene The scene to create the shadow map for
  80490. * @returns The parsed shadow generator
  80491. */
  80492. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  80493. }
  80494. }
  80495. declare module BABYLON {
  80496. /**
  80497. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  80498. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  80499. * 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.
  80500. */
  80501. export abstract class Light extends Node {
  80502. /**
  80503. * Falloff Default: light is falling off following the material specification:
  80504. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  80505. */
  80506. static readonly FALLOFF_DEFAULT: number;
  80507. /**
  80508. * Falloff Physical: light is falling off following the inverse squared distance law.
  80509. */
  80510. static readonly FALLOFF_PHYSICAL: number;
  80511. /**
  80512. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  80513. * to enhance interoperability with other engines.
  80514. */
  80515. static readonly FALLOFF_GLTF: number;
  80516. /**
  80517. * Falloff Standard: light is falling off like in the standard material
  80518. * to enhance interoperability with other materials.
  80519. */
  80520. static readonly FALLOFF_STANDARD: number;
  80521. /**
  80522. * If every light affecting the material is in this lightmapMode,
  80523. * material.lightmapTexture adds or multiplies
  80524. * (depends on material.useLightmapAsShadowmap)
  80525. * after every other light calculations.
  80526. */
  80527. static readonly LIGHTMAP_DEFAULT: number;
  80528. /**
  80529. * material.lightmapTexture as only diffuse lighting from this light
  80530. * adds only specular lighting from this light
  80531. * adds dynamic shadows
  80532. */
  80533. static readonly LIGHTMAP_SPECULAR: number;
  80534. /**
  80535. * material.lightmapTexture as only lighting
  80536. * no light calculation from this light
  80537. * only adds dynamic shadows from this light
  80538. */
  80539. static readonly LIGHTMAP_SHADOWSONLY: number;
  80540. /**
  80541. * Each light type uses the default quantity according to its type:
  80542. * point/spot lights use luminous intensity
  80543. * directional lights use illuminance
  80544. */
  80545. static readonly INTENSITYMODE_AUTOMATIC: number;
  80546. /**
  80547. * lumen (lm)
  80548. */
  80549. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  80550. /**
  80551. * candela (lm/sr)
  80552. */
  80553. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  80554. /**
  80555. * lux (lm/m^2)
  80556. */
  80557. static readonly INTENSITYMODE_ILLUMINANCE: number;
  80558. /**
  80559. * nit (cd/m^2)
  80560. */
  80561. static readonly INTENSITYMODE_LUMINANCE: number;
  80562. /**
  80563. * Light type const id of the point light.
  80564. */
  80565. static readonly LIGHTTYPEID_POINTLIGHT: number;
  80566. /**
  80567. * Light type const id of the directional light.
  80568. */
  80569. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  80570. /**
  80571. * Light type const id of the spot light.
  80572. */
  80573. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  80574. /**
  80575. * Light type const id of the hemispheric light.
  80576. */
  80577. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  80578. /**
  80579. * Diffuse gives the basic color to an object.
  80580. */
  80581. diffuse: Color3;
  80582. /**
  80583. * Specular produces a highlight color on an object.
  80584. * Note: This is note affecting PBR materials.
  80585. */
  80586. specular: Color3;
  80587. /**
  80588. * Defines the falloff type for this light. This lets overrriding how punctual light are
  80589. * falling off base on range or angle.
  80590. * This can be set to any values in Light.FALLOFF_x.
  80591. *
  80592. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  80593. * other types of materials.
  80594. */
  80595. falloffType: number;
  80596. /**
  80597. * Strength of the light.
  80598. * Note: By default it is define in the framework own unit.
  80599. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  80600. */
  80601. intensity: number;
  80602. private _range;
  80603. protected _inverseSquaredRange: number;
  80604. /**
  80605. * Defines how far from the source the light is impacting in scene units.
  80606. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80607. */
  80608. get range(): number;
  80609. /**
  80610. * Defines how far from the source the light is impacting in scene units.
  80611. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80612. */
  80613. set range(value: number);
  80614. /**
  80615. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  80616. * of light.
  80617. */
  80618. private _photometricScale;
  80619. private _intensityMode;
  80620. /**
  80621. * Gets the photometric scale used to interpret the intensity.
  80622. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80623. */
  80624. get intensityMode(): number;
  80625. /**
  80626. * Sets the photometric scale used to interpret the intensity.
  80627. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80628. */
  80629. set intensityMode(value: number);
  80630. private _radius;
  80631. /**
  80632. * Gets the light radius used by PBR Materials to simulate soft area lights.
  80633. */
  80634. get radius(): number;
  80635. /**
  80636. * sets the light radius used by PBR Materials to simulate soft area lights.
  80637. */
  80638. set radius(value: number);
  80639. private _renderPriority;
  80640. /**
  80641. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  80642. * exceeding the number allowed of the materials.
  80643. */
  80644. renderPriority: number;
  80645. private _shadowEnabled;
  80646. /**
  80647. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80648. * the current shadow generator.
  80649. */
  80650. get shadowEnabled(): boolean;
  80651. /**
  80652. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80653. * the current shadow generator.
  80654. */
  80655. set shadowEnabled(value: boolean);
  80656. private _includedOnlyMeshes;
  80657. /**
  80658. * Gets the only meshes impacted by this light.
  80659. */
  80660. get includedOnlyMeshes(): AbstractMesh[];
  80661. /**
  80662. * Sets the only meshes impacted by this light.
  80663. */
  80664. set includedOnlyMeshes(value: AbstractMesh[]);
  80665. private _excludedMeshes;
  80666. /**
  80667. * Gets the meshes not impacted by this light.
  80668. */
  80669. get excludedMeshes(): AbstractMesh[];
  80670. /**
  80671. * Sets the meshes not impacted by this light.
  80672. */
  80673. set excludedMeshes(value: AbstractMesh[]);
  80674. private _excludeWithLayerMask;
  80675. /**
  80676. * Gets the layer id use to find what meshes are not impacted by the light.
  80677. * Inactive if 0
  80678. */
  80679. get excludeWithLayerMask(): number;
  80680. /**
  80681. * Sets the layer id use to find what meshes are not impacted by the light.
  80682. * Inactive if 0
  80683. */
  80684. set excludeWithLayerMask(value: number);
  80685. private _includeOnlyWithLayerMask;
  80686. /**
  80687. * Gets the layer id use to find what meshes are impacted by the light.
  80688. * Inactive if 0
  80689. */
  80690. get includeOnlyWithLayerMask(): number;
  80691. /**
  80692. * Sets the layer id use to find what meshes are impacted by the light.
  80693. * Inactive if 0
  80694. */
  80695. set includeOnlyWithLayerMask(value: number);
  80696. private _lightmapMode;
  80697. /**
  80698. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80699. */
  80700. get lightmapMode(): number;
  80701. /**
  80702. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80703. */
  80704. set lightmapMode(value: number);
  80705. /**
  80706. * Shadow generator associted to the light.
  80707. * @hidden Internal use only.
  80708. */
  80709. _shadowGenerator: Nullable<IShadowGenerator>;
  80710. /**
  80711. * @hidden Internal use only.
  80712. */
  80713. _excludedMeshesIds: string[];
  80714. /**
  80715. * @hidden Internal use only.
  80716. */
  80717. _includedOnlyMeshesIds: string[];
  80718. /**
  80719. * The current light unifom buffer.
  80720. * @hidden Internal use only.
  80721. */
  80722. _uniformBuffer: UniformBuffer;
  80723. /** @hidden */
  80724. _renderId: number;
  80725. /**
  80726. * Creates a Light object in the scene.
  80727. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80728. * @param name The firendly name of the light
  80729. * @param scene The scene the light belongs too
  80730. */
  80731. constructor(name: string, scene: Scene);
  80732. protected abstract _buildUniformLayout(): void;
  80733. /**
  80734. * Sets the passed Effect "effect" with the Light information.
  80735. * @param effect The effect to update
  80736. * @param lightIndex The index of the light in the effect to update
  80737. * @returns The light
  80738. */
  80739. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  80740. /**
  80741. * Sets the passed Effect "effect" with the Light textures.
  80742. * @param effect The effect to update
  80743. * @param lightIndex The index of the light in the effect to update
  80744. * @returns The light
  80745. */
  80746. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  80747. /**
  80748. * Binds the lights information from the scene to the effect for the given mesh.
  80749. * @param lightIndex Light index
  80750. * @param scene The scene where the light belongs to
  80751. * @param effect The effect we are binding the data to
  80752. * @param useSpecular Defines if specular is supported
  80753. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  80754. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80755. */
  80756. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  80757. /**
  80758. * Sets the passed Effect "effect" with the Light information.
  80759. * @param effect The effect to update
  80760. * @param lightDataUniformName The uniform used to store light data (position or direction)
  80761. * @returns The light
  80762. */
  80763. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  80764. /**
  80765. * Returns the string "Light".
  80766. * @returns the class name
  80767. */
  80768. getClassName(): string;
  80769. /** @hidden */
  80770. readonly _isLight: boolean;
  80771. /**
  80772. * Converts the light information to a readable string for debug purpose.
  80773. * @param fullDetails Supports for multiple levels of logging within scene loading
  80774. * @returns the human readable light info
  80775. */
  80776. toString(fullDetails?: boolean): string;
  80777. /** @hidden */
  80778. protected _syncParentEnabledState(): void;
  80779. /**
  80780. * Set the enabled state of this node.
  80781. * @param value - the new enabled state
  80782. */
  80783. setEnabled(value: boolean): void;
  80784. /**
  80785. * Returns the Light associated shadow generator if any.
  80786. * @return the associated shadow generator.
  80787. */
  80788. getShadowGenerator(): Nullable<IShadowGenerator>;
  80789. /**
  80790. * Returns a Vector3, the absolute light position in the World.
  80791. * @returns the world space position of the light
  80792. */
  80793. getAbsolutePosition(): Vector3;
  80794. /**
  80795. * Specifies if the light will affect the passed mesh.
  80796. * @param mesh The mesh to test against the light
  80797. * @return true the mesh is affected otherwise, false.
  80798. */
  80799. canAffectMesh(mesh: AbstractMesh): boolean;
  80800. /**
  80801. * Sort function to order lights for rendering.
  80802. * @param a First Light object to compare to second.
  80803. * @param b Second Light object to compare first.
  80804. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  80805. */
  80806. static CompareLightsPriority(a: Light, b: Light): number;
  80807. /**
  80808. * Releases resources associated with this node.
  80809. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80810. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80811. */
  80812. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80813. /**
  80814. * Returns the light type ID (integer).
  80815. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80816. */
  80817. getTypeID(): number;
  80818. /**
  80819. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  80820. * @returns the scaled intensity in intensity mode unit
  80821. */
  80822. getScaledIntensity(): number;
  80823. /**
  80824. * Returns a new Light object, named "name", from the current one.
  80825. * @param name The name of the cloned light
  80826. * @returns the new created light
  80827. */
  80828. clone(name: string): Nullable<Light>;
  80829. /**
  80830. * Serializes the current light into a Serialization object.
  80831. * @returns the serialized object.
  80832. */
  80833. serialize(): any;
  80834. /**
  80835. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  80836. * This new light is named "name" and added to the passed scene.
  80837. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  80838. * @param name The friendly name of the light
  80839. * @param scene The scene the new light will belong to
  80840. * @returns the constructor function
  80841. */
  80842. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  80843. /**
  80844. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  80845. * @param parsedLight The JSON representation of the light
  80846. * @param scene The scene to create the parsed light in
  80847. * @returns the created light after parsing
  80848. */
  80849. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  80850. private _hookArrayForExcluded;
  80851. private _hookArrayForIncludedOnly;
  80852. private _resyncMeshes;
  80853. /**
  80854. * Forces the meshes to update their light related information in their rendering used effects
  80855. * @hidden Internal Use Only
  80856. */
  80857. _markMeshesAsLightDirty(): void;
  80858. /**
  80859. * Recomputes the cached photometric scale if needed.
  80860. */
  80861. private _computePhotometricScale;
  80862. /**
  80863. * Returns the Photometric Scale according to the light type and intensity mode.
  80864. */
  80865. private _getPhotometricScale;
  80866. /**
  80867. * Reorder the light in the scene according to their defined priority.
  80868. * @hidden Internal Use Only
  80869. */
  80870. _reorderLightsInScene(): void;
  80871. /**
  80872. * Prepares the list of defines specific to the light type.
  80873. * @param defines the list of defines
  80874. * @param lightIndex defines the index of the light for the effect
  80875. */
  80876. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80877. }
  80878. }
  80879. declare module BABYLON {
  80880. /**
  80881. * Interface used to define Action
  80882. */
  80883. export interface IAction {
  80884. /**
  80885. * Trigger for the action
  80886. */
  80887. trigger: number;
  80888. /** Options of the trigger */
  80889. triggerOptions: any;
  80890. /**
  80891. * Gets the trigger parameters
  80892. * @returns the trigger parameters
  80893. */
  80894. getTriggerParameter(): any;
  80895. /**
  80896. * Internal only - executes current action event
  80897. * @hidden
  80898. */
  80899. _executeCurrent(evt?: ActionEvent): void;
  80900. /**
  80901. * Serialize placeholder for child classes
  80902. * @param parent of child
  80903. * @returns the serialized object
  80904. */
  80905. serialize(parent: any): any;
  80906. /**
  80907. * Internal only
  80908. * @hidden
  80909. */
  80910. _prepare(): void;
  80911. /**
  80912. * Internal only - manager for action
  80913. * @hidden
  80914. */
  80915. _actionManager: AbstractActionManager;
  80916. /**
  80917. * Adds action to chain of actions, may be a DoNothingAction
  80918. * @param action defines the next action to execute
  80919. * @returns The action passed in
  80920. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80921. */
  80922. then(action: IAction): IAction;
  80923. }
  80924. /**
  80925. * The action to be carried out following a trigger
  80926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  80927. */
  80928. export class Action implements IAction {
  80929. /** the trigger, with or without parameters, for the action */
  80930. triggerOptions: any;
  80931. /**
  80932. * Trigger for the action
  80933. */
  80934. trigger: number;
  80935. /**
  80936. * Internal only - manager for action
  80937. * @hidden
  80938. */
  80939. _actionManager: ActionManager;
  80940. private _nextActiveAction;
  80941. private _child;
  80942. private _condition?;
  80943. private _triggerParameter;
  80944. /**
  80945. * An event triggered prior to action being executed.
  80946. */
  80947. onBeforeExecuteObservable: Observable<Action>;
  80948. /**
  80949. * Creates a new Action
  80950. * @param triggerOptions the trigger, with or without parameters, for the action
  80951. * @param condition an optional determinant of action
  80952. */
  80953. constructor(
  80954. /** the trigger, with or without parameters, for the action */
  80955. triggerOptions: any, condition?: Condition);
  80956. /**
  80957. * Internal only
  80958. * @hidden
  80959. */
  80960. _prepare(): void;
  80961. /**
  80962. * Gets the trigger parameters
  80963. * @returns the trigger parameters
  80964. */
  80965. getTriggerParameter(): any;
  80966. /**
  80967. * Internal only - executes current action event
  80968. * @hidden
  80969. */
  80970. _executeCurrent(evt?: ActionEvent): void;
  80971. /**
  80972. * Execute placeholder for child classes
  80973. * @param evt optional action event
  80974. */
  80975. execute(evt?: ActionEvent): void;
  80976. /**
  80977. * Skips to next active action
  80978. */
  80979. skipToNextActiveAction(): void;
  80980. /**
  80981. * Adds action to chain of actions, may be a DoNothingAction
  80982. * @param action defines the next action to execute
  80983. * @returns The action passed in
  80984. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80985. */
  80986. then(action: Action): Action;
  80987. /**
  80988. * Internal only
  80989. * @hidden
  80990. */
  80991. _getProperty(propertyPath: string): string;
  80992. /**
  80993. * Internal only
  80994. * @hidden
  80995. */
  80996. _getEffectiveTarget(target: any, propertyPath: string): any;
  80997. /**
  80998. * Serialize placeholder for child classes
  80999. * @param parent of child
  81000. * @returns the serialized object
  81001. */
  81002. serialize(parent: any): any;
  81003. /**
  81004. * Internal only called by serialize
  81005. * @hidden
  81006. */
  81007. protected _serialize(serializedAction: any, parent?: any): any;
  81008. /**
  81009. * Internal only
  81010. * @hidden
  81011. */
  81012. static _SerializeValueAsString: (value: any) => string;
  81013. /**
  81014. * Internal only
  81015. * @hidden
  81016. */
  81017. static _GetTargetProperty: (target: Node | Scene) => {
  81018. name: string;
  81019. targetType: string;
  81020. value: string;
  81021. };
  81022. }
  81023. }
  81024. declare module BABYLON {
  81025. /**
  81026. * A Condition applied to an Action
  81027. */
  81028. export class Condition {
  81029. /**
  81030. * Internal only - manager for action
  81031. * @hidden
  81032. */
  81033. _actionManager: ActionManager;
  81034. /**
  81035. * Internal only
  81036. * @hidden
  81037. */
  81038. _evaluationId: number;
  81039. /**
  81040. * Internal only
  81041. * @hidden
  81042. */
  81043. _currentResult: boolean;
  81044. /**
  81045. * Creates a new Condition
  81046. * @param actionManager the manager of the action the condition is applied to
  81047. */
  81048. constructor(actionManager: ActionManager);
  81049. /**
  81050. * Check if the current condition is valid
  81051. * @returns a boolean
  81052. */
  81053. isValid(): boolean;
  81054. /**
  81055. * Internal only
  81056. * @hidden
  81057. */
  81058. _getProperty(propertyPath: string): string;
  81059. /**
  81060. * Internal only
  81061. * @hidden
  81062. */
  81063. _getEffectiveTarget(target: any, propertyPath: string): any;
  81064. /**
  81065. * Serialize placeholder for child classes
  81066. * @returns the serialized object
  81067. */
  81068. serialize(): any;
  81069. /**
  81070. * Internal only
  81071. * @hidden
  81072. */
  81073. protected _serialize(serializedCondition: any): any;
  81074. }
  81075. /**
  81076. * Defines specific conditional operators as extensions of Condition
  81077. */
  81078. export class ValueCondition extends Condition {
  81079. /** path to specify the property of the target the conditional operator uses */
  81080. propertyPath: string;
  81081. /** the value compared by the conditional operator against the current value of the property */
  81082. value: any;
  81083. /** the conditional operator, default ValueCondition.IsEqual */
  81084. operator: number;
  81085. /**
  81086. * Internal only
  81087. * @hidden
  81088. */
  81089. private static _IsEqual;
  81090. /**
  81091. * Internal only
  81092. * @hidden
  81093. */
  81094. private static _IsDifferent;
  81095. /**
  81096. * Internal only
  81097. * @hidden
  81098. */
  81099. private static _IsGreater;
  81100. /**
  81101. * Internal only
  81102. * @hidden
  81103. */
  81104. private static _IsLesser;
  81105. /**
  81106. * returns the number for IsEqual
  81107. */
  81108. static get IsEqual(): number;
  81109. /**
  81110. * Returns the number for IsDifferent
  81111. */
  81112. static get IsDifferent(): number;
  81113. /**
  81114. * Returns the number for IsGreater
  81115. */
  81116. static get IsGreater(): number;
  81117. /**
  81118. * Returns the number for IsLesser
  81119. */
  81120. static get IsLesser(): number;
  81121. /**
  81122. * Internal only The action manager for the condition
  81123. * @hidden
  81124. */
  81125. _actionManager: ActionManager;
  81126. /**
  81127. * Internal only
  81128. * @hidden
  81129. */
  81130. private _target;
  81131. /**
  81132. * Internal only
  81133. * @hidden
  81134. */
  81135. private _effectiveTarget;
  81136. /**
  81137. * Internal only
  81138. * @hidden
  81139. */
  81140. private _property;
  81141. /**
  81142. * Creates a new ValueCondition
  81143. * @param actionManager manager for the action the condition applies to
  81144. * @param target for the action
  81145. * @param propertyPath path to specify the property of the target the conditional operator uses
  81146. * @param value the value compared by the conditional operator against the current value of the property
  81147. * @param operator the conditional operator, default ValueCondition.IsEqual
  81148. */
  81149. constructor(actionManager: ActionManager, target: any,
  81150. /** path to specify the property of the target the conditional operator uses */
  81151. propertyPath: string,
  81152. /** the value compared by the conditional operator against the current value of the property */
  81153. value: any,
  81154. /** the conditional operator, default ValueCondition.IsEqual */
  81155. operator?: number);
  81156. /**
  81157. * Compares the given value with the property value for the specified conditional operator
  81158. * @returns the result of the comparison
  81159. */
  81160. isValid(): boolean;
  81161. /**
  81162. * Serialize the ValueCondition into a JSON compatible object
  81163. * @returns serialization object
  81164. */
  81165. serialize(): any;
  81166. /**
  81167. * Gets the name of the conditional operator for the ValueCondition
  81168. * @param operator the conditional operator
  81169. * @returns the name
  81170. */
  81171. static GetOperatorName(operator: number): string;
  81172. }
  81173. /**
  81174. * Defines a predicate condition as an extension of Condition
  81175. */
  81176. export class PredicateCondition extends Condition {
  81177. /** defines the predicate function used to validate the condition */
  81178. predicate: () => boolean;
  81179. /**
  81180. * Internal only - manager for action
  81181. * @hidden
  81182. */
  81183. _actionManager: ActionManager;
  81184. /**
  81185. * Creates a new PredicateCondition
  81186. * @param actionManager manager for the action the condition applies to
  81187. * @param predicate defines the predicate function used to validate the condition
  81188. */
  81189. constructor(actionManager: ActionManager,
  81190. /** defines the predicate function used to validate the condition */
  81191. predicate: () => boolean);
  81192. /**
  81193. * @returns the validity of the predicate condition
  81194. */
  81195. isValid(): boolean;
  81196. }
  81197. /**
  81198. * Defines a state condition as an extension of Condition
  81199. */
  81200. export class StateCondition extends Condition {
  81201. /** Value to compare with target state */
  81202. value: string;
  81203. /**
  81204. * Internal only - manager for action
  81205. * @hidden
  81206. */
  81207. _actionManager: ActionManager;
  81208. /**
  81209. * Internal only
  81210. * @hidden
  81211. */
  81212. private _target;
  81213. /**
  81214. * Creates a new StateCondition
  81215. * @param actionManager manager for the action the condition applies to
  81216. * @param target of the condition
  81217. * @param value to compare with target state
  81218. */
  81219. constructor(actionManager: ActionManager, target: any,
  81220. /** Value to compare with target state */
  81221. value: string);
  81222. /**
  81223. * Gets a boolean indicating if the current condition is met
  81224. * @returns the validity of the state
  81225. */
  81226. isValid(): boolean;
  81227. /**
  81228. * Serialize the StateCondition into a JSON compatible object
  81229. * @returns serialization object
  81230. */
  81231. serialize(): any;
  81232. }
  81233. }
  81234. declare module BABYLON {
  81235. /**
  81236. * This defines an action responsible to toggle a boolean once triggered.
  81237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81238. */
  81239. export class SwitchBooleanAction extends Action {
  81240. /**
  81241. * The path to the boolean property in the target object
  81242. */
  81243. propertyPath: string;
  81244. private _target;
  81245. private _effectiveTarget;
  81246. private _property;
  81247. /**
  81248. * Instantiate the action
  81249. * @param triggerOptions defines the trigger options
  81250. * @param target defines the object containing the boolean
  81251. * @param propertyPath defines the path to the boolean property in the target object
  81252. * @param condition defines the trigger related conditions
  81253. */
  81254. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  81255. /** @hidden */
  81256. _prepare(): void;
  81257. /**
  81258. * Execute the action toggle the boolean value.
  81259. */
  81260. execute(): void;
  81261. /**
  81262. * Serializes the actions and its related information.
  81263. * @param parent defines the object to serialize in
  81264. * @returns the serialized object
  81265. */
  81266. serialize(parent: any): any;
  81267. }
  81268. /**
  81269. * This defines an action responsible to set a the state field of the target
  81270. * to a desired value once triggered.
  81271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81272. */
  81273. export class SetStateAction extends Action {
  81274. /**
  81275. * The value to store in the state field.
  81276. */
  81277. value: string;
  81278. private _target;
  81279. /**
  81280. * Instantiate the action
  81281. * @param triggerOptions defines the trigger options
  81282. * @param target defines the object containing the state property
  81283. * @param value defines the value to store in the state field
  81284. * @param condition defines the trigger related conditions
  81285. */
  81286. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  81287. /**
  81288. * Execute the action and store the value on the target state property.
  81289. */
  81290. execute(): void;
  81291. /**
  81292. * Serializes the actions and its related information.
  81293. * @param parent defines the object to serialize in
  81294. * @returns the serialized object
  81295. */
  81296. serialize(parent: any): any;
  81297. }
  81298. /**
  81299. * This defines an action responsible to set a property of the target
  81300. * to a desired value once triggered.
  81301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81302. */
  81303. export class SetValueAction extends Action {
  81304. /**
  81305. * The path of the property to set in the target.
  81306. */
  81307. propertyPath: string;
  81308. /**
  81309. * The value to set in the property
  81310. */
  81311. value: any;
  81312. private _target;
  81313. private _effectiveTarget;
  81314. private _property;
  81315. /**
  81316. * Instantiate the action
  81317. * @param triggerOptions defines the trigger options
  81318. * @param target defines the object containing the property
  81319. * @param propertyPath defines the path of the property to set in the target
  81320. * @param value defines the value to set in the property
  81321. * @param condition defines the trigger related conditions
  81322. */
  81323. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81324. /** @hidden */
  81325. _prepare(): void;
  81326. /**
  81327. * Execute the action and set the targetted property to the desired value.
  81328. */
  81329. execute(): void;
  81330. /**
  81331. * Serializes the actions and its related information.
  81332. * @param parent defines the object to serialize in
  81333. * @returns the serialized object
  81334. */
  81335. serialize(parent: any): any;
  81336. }
  81337. /**
  81338. * This defines an action responsible to increment the target value
  81339. * to a desired value once triggered.
  81340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81341. */
  81342. export class IncrementValueAction extends Action {
  81343. /**
  81344. * The path of the property to increment in the target.
  81345. */
  81346. propertyPath: string;
  81347. /**
  81348. * The value we should increment the property by.
  81349. */
  81350. value: any;
  81351. private _target;
  81352. private _effectiveTarget;
  81353. private _property;
  81354. /**
  81355. * Instantiate the action
  81356. * @param triggerOptions defines the trigger options
  81357. * @param target defines the object containing the property
  81358. * @param propertyPath defines the path of the property to increment in the target
  81359. * @param value defines the value value we should increment the property by
  81360. * @param condition defines the trigger related conditions
  81361. */
  81362. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81363. /** @hidden */
  81364. _prepare(): void;
  81365. /**
  81366. * Execute the action and increment the target of the value amount.
  81367. */
  81368. execute(): void;
  81369. /**
  81370. * Serializes the actions and its related information.
  81371. * @param parent defines the object to serialize in
  81372. * @returns the serialized object
  81373. */
  81374. serialize(parent: any): any;
  81375. }
  81376. /**
  81377. * This defines an action responsible to start an animation once triggered.
  81378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81379. */
  81380. export class PlayAnimationAction extends Action {
  81381. /**
  81382. * Where the animation should start (animation frame)
  81383. */
  81384. from: number;
  81385. /**
  81386. * Where the animation should stop (animation frame)
  81387. */
  81388. to: number;
  81389. /**
  81390. * Define if the animation should loop or stop after the first play.
  81391. */
  81392. loop?: boolean;
  81393. private _target;
  81394. /**
  81395. * Instantiate the action
  81396. * @param triggerOptions defines the trigger options
  81397. * @param target defines the target animation or animation name
  81398. * @param from defines from where the animation should start (animation frame)
  81399. * @param end defines where the animation should stop (animation frame)
  81400. * @param loop defines if the animation should loop or stop after the first play
  81401. * @param condition defines the trigger related conditions
  81402. */
  81403. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  81404. /** @hidden */
  81405. _prepare(): void;
  81406. /**
  81407. * Execute the action and play the animation.
  81408. */
  81409. execute(): void;
  81410. /**
  81411. * Serializes the actions and its related information.
  81412. * @param parent defines the object to serialize in
  81413. * @returns the serialized object
  81414. */
  81415. serialize(parent: any): any;
  81416. }
  81417. /**
  81418. * This defines an action responsible to stop an animation once triggered.
  81419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81420. */
  81421. export class StopAnimationAction extends Action {
  81422. private _target;
  81423. /**
  81424. * Instantiate the action
  81425. * @param triggerOptions defines the trigger options
  81426. * @param target defines the target animation or animation name
  81427. * @param condition defines the trigger related conditions
  81428. */
  81429. constructor(triggerOptions: any, target: any, condition?: Condition);
  81430. /** @hidden */
  81431. _prepare(): void;
  81432. /**
  81433. * Execute the action and stop the animation.
  81434. */
  81435. execute(): void;
  81436. /**
  81437. * Serializes the actions and its related information.
  81438. * @param parent defines the object to serialize in
  81439. * @returns the serialized object
  81440. */
  81441. serialize(parent: any): any;
  81442. }
  81443. /**
  81444. * This defines an action responsible that does nothing once triggered.
  81445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81446. */
  81447. export class DoNothingAction extends Action {
  81448. /**
  81449. * Instantiate the action
  81450. * @param triggerOptions defines the trigger options
  81451. * @param condition defines the trigger related conditions
  81452. */
  81453. constructor(triggerOptions?: any, condition?: Condition);
  81454. /**
  81455. * Execute the action and do nothing.
  81456. */
  81457. execute(): void;
  81458. /**
  81459. * Serializes the actions and its related information.
  81460. * @param parent defines the object to serialize in
  81461. * @returns the serialized object
  81462. */
  81463. serialize(parent: any): any;
  81464. }
  81465. /**
  81466. * This defines an action responsible to trigger several actions once triggered.
  81467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81468. */
  81469. export class CombineAction extends Action {
  81470. /**
  81471. * The list of aggregated animations to run.
  81472. */
  81473. children: Action[];
  81474. /**
  81475. * Instantiate the action
  81476. * @param triggerOptions defines the trigger options
  81477. * @param children defines the list of aggregated animations to run
  81478. * @param condition defines the trigger related conditions
  81479. */
  81480. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  81481. /** @hidden */
  81482. _prepare(): void;
  81483. /**
  81484. * Execute the action and executes all the aggregated actions.
  81485. */
  81486. execute(evt: ActionEvent): void;
  81487. /**
  81488. * Serializes the actions and its related information.
  81489. * @param parent defines the object to serialize in
  81490. * @returns the serialized object
  81491. */
  81492. serialize(parent: any): any;
  81493. }
  81494. /**
  81495. * This defines an action responsible to run code (external event) once triggered.
  81496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81497. */
  81498. export class ExecuteCodeAction extends Action {
  81499. /**
  81500. * The callback function to run.
  81501. */
  81502. func: (evt: ActionEvent) => void;
  81503. /**
  81504. * Instantiate the action
  81505. * @param triggerOptions defines the trigger options
  81506. * @param func defines the callback function to run
  81507. * @param condition defines the trigger related conditions
  81508. */
  81509. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  81510. /**
  81511. * Execute the action and run the attached code.
  81512. */
  81513. execute(evt: ActionEvent): void;
  81514. }
  81515. /**
  81516. * This defines an action responsible to set the parent property of the target once triggered.
  81517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81518. */
  81519. export class SetParentAction extends Action {
  81520. private _parent;
  81521. private _target;
  81522. /**
  81523. * Instantiate the action
  81524. * @param triggerOptions defines the trigger options
  81525. * @param target defines the target containing the parent property
  81526. * @param parent defines from where the animation should start (animation frame)
  81527. * @param condition defines the trigger related conditions
  81528. */
  81529. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  81530. /** @hidden */
  81531. _prepare(): void;
  81532. /**
  81533. * Execute the action and set the parent property.
  81534. */
  81535. execute(): void;
  81536. /**
  81537. * Serializes the actions and its related information.
  81538. * @param parent defines the object to serialize in
  81539. * @returns the serialized object
  81540. */
  81541. serialize(parent: any): any;
  81542. }
  81543. }
  81544. declare module BABYLON {
  81545. /**
  81546. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  81547. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  81548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81549. */
  81550. export class ActionManager extends AbstractActionManager {
  81551. /**
  81552. * Nothing
  81553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81554. */
  81555. static readonly NothingTrigger: number;
  81556. /**
  81557. * On pick
  81558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81559. */
  81560. static readonly OnPickTrigger: number;
  81561. /**
  81562. * On left pick
  81563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81564. */
  81565. static readonly OnLeftPickTrigger: number;
  81566. /**
  81567. * On right pick
  81568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81569. */
  81570. static readonly OnRightPickTrigger: number;
  81571. /**
  81572. * On center pick
  81573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81574. */
  81575. static readonly OnCenterPickTrigger: number;
  81576. /**
  81577. * On pick down
  81578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81579. */
  81580. static readonly OnPickDownTrigger: number;
  81581. /**
  81582. * On double pick
  81583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81584. */
  81585. static readonly OnDoublePickTrigger: number;
  81586. /**
  81587. * On pick up
  81588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81589. */
  81590. static readonly OnPickUpTrigger: number;
  81591. /**
  81592. * On pick out.
  81593. * This trigger will only be raised if you also declared a OnPickDown
  81594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81595. */
  81596. static readonly OnPickOutTrigger: number;
  81597. /**
  81598. * On long press
  81599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81600. */
  81601. static readonly OnLongPressTrigger: number;
  81602. /**
  81603. * On pointer over
  81604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81605. */
  81606. static readonly OnPointerOverTrigger: number;
  81607. /**
  81608. * On pointer out
  81609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81610. */
  81611. static readonly OnPointerOutTrigger: number;
  81612. /**
  81613. * On every frame
  81614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81615. */
  81616. static readonly OnEveryFrameTrigger: number;
  81617. /**
  81618. * On intersection enter
  81619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81620. */
  81621. static readonly OnIntersectionEnterTrigger: number;
  81622. /**
  81623. * On intersection exit
  81624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81625. */
  81626. static readonly OnIntersectionExitTrigger: number;
  81627. /**
  81628. * On key down
  81629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81630. */
  81631. static readonly OnKeyDownTrigger: number;
  81632. /**
  81633. * On key up
  81634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81635. */
  81636. static readonly OnKeyUpTrigger: number;
  81637. private _scene;
  81638. /**
  81639. * Creates a new action manager
  81640. * @param scene defines the hosting scene
  81641. */
  81642. constructor(scene: Scene);
  81643. /**
  81644. * Releases all associated resources
  81645. */
  81646. dispose(): void;
  81647. /**
  81648. * Gets hosting scene
  81649. * @returns the hosting scene
  81650. */
  81651. getScene(): Scene;
  81652. /**
  81653. * Does this action manager handles actions of any of the given triggers
  81654. * @param triggers defines the triggers to be tested
  81655. * @return a boolean indicating whether one (or more) of the triggers is handled
  81656. */
  81657. hasSpecificTriggers(triggers: number[]): boolean;
  81658. /**
  81659. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81660. * speed.
  81661. * @param triggerA defines the trigger to be tested
  81662. * @param triggerB defines the trigger to be tested
  81663. * @return a boolean indicating whether one (or more) of the triggers is handled
  81664. */
  81665. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81666. /**
  81667. * Does this action manager handles actions of a given trigger
  81668. * @param trigger defines the trigger to be tested
  81669. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81670. * @return whether the trigger is handled
  81671. */
  81672. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81673. /**
  81674. * Does this action manager has pointer triggers
  81675. */
  81676. get hasPointerTriggers(): boolean;
  81677. /**
  81678. * Does this action manager has pick triggers
  81679. */
  81680. get hasPickTriggers(): boolean;
  81681. /**
  81682. * Registers an action to this action manager
  81683. * @param action defines the action to be registered
  81684. * @return the action amended (prepared) after registration
  81685. */
  81686. registerAction(action: IAction): Nullable<IAction>;
  81687. /**
  81688. * Unregisters an action to this action manager
  81689. * @param action defines the action to be unregistered
  81690. * @return a boolean indicating whether the action has been unregistered
  81691. */
  81692. unregisterAction(action: IAction): Boolean;
  81693. /**
  81694. * Process a specific trigger
  81695. * @param trigger defines the trigger to process
  81696. * @param evt defines the event details to be processed
  81697. */
  81698. processTrigger(trigger: number, evt?: IActionEvent): void;
  81699. /** @hidden */
  81700. _getEffectiveTarget(target: any, propertyPath: string): any;
  81701. /** @hidden */
  81702. _getProperty(propertyPath: string): string;
  81703. /**
  81704. * Serialize this manager to a JSON object
  81705. * @param name defines the property name to store this manager
  81706. * @returns a JSON representation of this manager
  81707. */
  81708. serialize(name: string): any;
  81709. /**
  81710. * Creates a new ActionManager from a JSON data
  81711. * @param parsedActions defines the JSON data to read from
  81712. * @param object defines the hosting mesh
  81713. * @param scene defines the hosting scene
  81714. */
  81715. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  81716. /**
  81717. * Get a trigger name by index
  81718. * @param trigger defines the trigger index
  81719. * @returns a trigger name
  81720. */
  81721. static GetTriggerName(trigger: number): string;
  81722. }
  81723. }
  81724. declare module BABYLON {
  81725. /**
  81726. * Class representing a ray with position and direction
  81727. */
  81728. export class Ray {
  81729. /** origin point */
  81730. origin: Vector3;
  81731. /** direction */
  81732. direction: Vector3;
  81733. /** length of the ray */
  81734. length: number;
  81735. private static readonly TmpVector3;
  81736. private _tmpRay;
  81737. /**
  81738. * Creates a new ray
  81739. * @param origin origin point
  81740. * @param direction direction
  81741. * @param length length of the ray
  81742. */
  81743. constructor(
  81744. /** origin point */
  81745. origin: Vector3,
  81746. /** direction */
  81747. direction: Vector3,
  81748. /** length of the ray */
  81749. length?: number);
  81750. /**
  81751. * Checks if the ray intersects a box
  81752. * @param minimum bound of the box
  81753. * @param maximum bound of the box
  81754. * @param intersectionTreshold extra extend to be added to the box in all direction
  81755. * @returns if the box was hit
  81756. */
  81757. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  81758. /**
  81759. * Checks if the ray intersects a box
  81760. * @param box the bounding box to check
  81761. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  81762. * @returns if the box was hit
  81763. */
  81764. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  81765. /**
  81766. * If the ray hits a sphere
  81767. * @param sphere the bounding sphere to check
  81768. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  81769. * @returns true if it hits the sphere
  81770. */
  81771. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  81772. /**
  81773. * If the ray hits a triange
  81774. * @param vertex0 triangle vertex
  81775. * @param vertex1 triangle vertex
  81776. * @param vertex2 triangle vertex
  81777. * @returns intersection information if hit
  81778. */
  81779. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  81780. /**
  81781. * Checks if ray intersects a plane
  81782. * @param plane the plane to check
  81783. * @returns the distance away it was hit
  81784. */
  81785. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  81786. /**
  81787. * Calculate the intercept of a ray on a given axis
  81788. * @param axis to check 'x' | 'y' | 'z'
  81789. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  81790. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  81791. */
  81792. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  81793. /**
  81794. * Checks if ray intersects a mesh
  81795. * @param mesh the mesh to check
  81796. * @param fastCheck if only the bounding box should checked
  81797. * @returns picking info of the intersecton
  81798. */
  81799. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  81800. /**
  81801. * Checks if ray intersects a mesh
  81802. * @param meshes the meshes to check
  81803. * @param fastCheck if only the bounding box should checked
  81804. * @param results array to store result in
  81805. * @returns Array of picking infos
  81806. */
  81807. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  81808. private _comparePickingInfo;
  81809. private static smallnum;
  81810. private static rayl;
  81811. /**
  81812. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  81813. * @param sega the first point of the segment to test the intersection against
  81814. * @param segb the second point of the segment to test the intersection against
  81815. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  81816. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  81817. */
  81818. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  81819. /**
  81820. * Update the ray from viewport position
  81821. * @param x position
  81822. * @param y y position
  81823. * @param viewportWidth viewport width
  81824. * @param viewportHeight viewport height
  81825. * @param world world matrix
  81826. * @param view view matrix
  81827. * @param projection projection matrix
  81828. * @returns this ray updated
  81829. */
  81830. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81831. /**
  81832. * Creates a ray with origin and direction of 0,0,0
  81833. * @returns the new ray
  81834. */
  81835. static Zero(): Ray;
  81836. /**
  81837. * Creates a new ray from screen space and viewport
  81838. * @param x position
  81839. * @param y y position
  81840. * @param viewportWidth viewport width
  81841. * @param viewportHeight viewport height
  81842. * @param world world matrix
  81843. * @param view view matrix
  81844. * @param projection projection matrix
  81845. * @returns new ray
  81846. */
  81847. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81848. /**
  81849. * 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
  81850. * transformed to the given world matrix.
  81851. * @param origin The origin point
  81852. * @param end The end point
  81853. * @param world a matrix to transform the ray to. Default is the identity matrix.
  81854. * @returns the new ray
  81855. */
  81856. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  81857. /**
  81858. * Transforms a ray by a matrix
  81859. * @param ray ray to transform
  81860. * @param matrix matrix to apply
  81861. * @returns the resulting new ray
  81862. */
  81863. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  81864. /**
  81865. * Transforms a ray by a matrix
  81866. * @param ray ray to transform
  81867. * @param matrix matrix to apply
  81868. * @param result ray to store result in
  81869. */
  81870. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  81871. /**
  81872. * Unproject a ray from screen space to object space
  81873. * @param sourceX defines the screen space x coordinate to use
  81874. * @param sourceY defines the screen space y coordinate to use
  81875. * @param viewportWidth defines the current width of the viewport
  81876. * @param viewportHeight defines the current height of the viewport
  81877. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81878. * @param view defines the view matrix to use
  81879. * @param projection defines the projection matrix to use
  81880. */
  81881. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  81882. }
  81883. /**
  81884. * Type used to define predicate used to select faces when a mesh intersection is detected
  81885. */
  81886. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  81887. interface Scene {
  81888. /** @hidden */
  81889. _tempPickingRay: Nullable<Ray>;
  81890. /** @hidden */
  81891. _cachedRayForTransform: Ray;
  81892. /** @hidden */
  81893. _pickWithRayInverseMatrix: Matrix;
  81894. /** @hidden */
  81895. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  81896. /** @hidden */
  81897. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  81898. }
  81899. }
  81900. declare module BABYLON {
  81901. /**
  81902. * Groups all the scene component constants in one place to ease maintenance.
  81903. * @hidden
  81904. */
  81905. export class SceneComponentConstants {
  81906. static readonly NAME_EFFECTLAYER: string;
  81907. static readonly NAME_LAYER: string;
  81908. static readonly NAME_LENSFLARESYSTEM: string;
  81909. static readonly NAME_BOUNDINGBOXRENDERER: string;
  81910. static readonly NAME_PARTICLESYSTEM: string;
  81911. static readonly NAME_GAMEPAD: string;
  81912. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  81913. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  81914. static readonly NAME_DEPTHRENDERER: string;
  81915. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  81916. static readonly NAME_SPRITE: string;
  81917. static readonly NAME_OUTLINERENDERER: string;
  81918. static readonly NAME_PROCEDURALTEXTURE: string;
  81919. static readonly NAME_SHADOWGENERATOR: string;
  81920. static readonly NAME_OCTREE: string;
  81921. static readonly NAME_PHYSICSENGINE: string;
  81922. static readonly NAME_AUDIO: string;
  81923. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  81924. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81925. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  81926. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81927. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  81928. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  81929. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  81930. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  81931. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  81932. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  81933. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  81934. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  81935. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  81936. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  81937. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  81938. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  81939. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  81940. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  81941. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  81942. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  81943. static readonly STEP_AFTERRENDER_AUDIO: number;
  81944. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  81945. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  81946. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  81947. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  81948. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  81949. static readonly STEP_POINTERMOVE_SPRITE: number;
  81950. static readonly STEP_POINTERDOWN_SPRITE: number;
  81951. static readonly STEP_POINTERUP_SPRITE: number;
  81952. }
  81953. /**
  81954. * This represents a scene component.
  81955. *
  81956. * This is used to decouple the dependency the scene is having on the different workloads like
  81957. * layers, post processes...
  81958. */
  81959. export interface ISceneComponent {
  81960. /**
  81961. * The name of the component. Each component must have a unique name.
  81962. */
  81963. name: string;
  81964. /**
  81965. * The scene the component belongs to.
  81966. */
  81967. scene: Scene;
  81968. /**
  81969. * Register the component to one instance of a scene.
  81970. */
  81971. register(): void;
  81972. /**
  81973. * Rebuilds the elements related to this component in case of
  81974. * context lost for instance.
  81975. */
  81976. rebuild(): void;
  81977. /**
  81978. * Disposes the component and the associated ressources.
  81979. */
  81980. dispose(): void;
  81981. }
  81982. /**
  81983. * This represents a SERIALIZABLE scene component.
  81984. *
  81985. * This extends Scene Component to add Serialization methods on top.
  81986. */
  81987. export interface ISceneSerializableComponent extends ISceneComponent {
  81988. /**
  81989. * Adds all the elements from the container to the scene
  81990. * @param container the container holding the elements
  81991. */
  81992. addFromContainer(container: AbstractScene): void;
  81993. /**
  81994. * Removes all the elements in the container from the scene
  81995. * @param container contains the elements to remove
  81996. * @param dispose if the removed element should be disposed (default: false)
  81997. */
  81998. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  81999. /**
  82000. * Serializes the component data to the specified json object
  82001. * @param serializationObject The object to serialize to
  82002. */
  82003. serialize(serializationObject: any): void;
  82004. }
  82005. /**
  82006. * Strong typing of a Mesh related stage step action
  82007. */
  82008. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82009. /**
  82010. * Strong typing of a Evaluate Sub Mesh related stage step action
  82011. */
  82012. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82013. /**
  82014. * Strong typing of a Active Mesh related stage step action
  82015. */
  82016. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82017. /**
  82018. * Strong typing of a Camera related stage step action
  82019. */
  82020. export type CameraStageAction = (camera: Camera) => void;
  82021. /**
  82022. * Strong typing of a Camera Frame buffer related stage step action
  82023. */
  82024. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82025. /**
  82026. * Strong typing of a Render Target related stage step action
  82027. */
  82028. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82029. /**
  82030. * Strong typing of a RenderingGroup related stage step action
  82031. */
  82032. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82033. /**
  82034. * Strong typing of a Mesh Render related stage step action
  82035. */
  82036. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82037. /**
  82038. * Strong typing of a simple stage step action
  82039. */
  82040. export type SimpleStageAction = () => void;
  82041. /**
  82042. * Strong typing of a render target action.
  82043. */
  82044. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82045. /**
  82046. * Strong typing of a pointer move action.
  82047. */
  82048. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82049. /**
  82050. * Strong typing of a pointer up/down action.
  82051. */
  82052. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82053. /**
  82054. * Representation of a stage in the scene (Basically a list of ordered steps)
  82055. * @hidden
  82056. */
  82057. export class Stage<T extends Function> extends Array<{
  82058. index: number;
  82059. component: ISceneComponent;
  82060. action: T;
  82061. }> {
  82062. /**
  82063. * Hide ctor from the rest of the world.
  82064. * @param items The items to add.
  82065. */
  82066. private constructor();
  82067. /**
  82068. * Creates a new Stage.
  82069. * @returns A new instance of a Stage
  82070. */
  82071. static Create<T extends Function>(): Stage<T>;
  82072. /**
  82073. * Registers a step in an ordered way in the targeted stage.
  82074. * @param index Defines the position to register the step in
  82075. * @param component Defines the component attached to the step
  82076. * @param action Defines the action to launch during the step
  82077. */
  82078. registerStep(index: number, component: ISceneComponent, action: T): void;
  82079. /**
  82080. * Clears all the steps from the stage.
  82081. */
  82082. clear(): void;
  82083. }
  82084. }
  82085. declare module BABYLON {
  82086. interface Scene {
  82087. /** @hidden */
  82088. _pointerOverSprite: Nullable<Sprite>;
  82089. /** @hidden */
  82090. _pickedDownSprite: Nullable<Sprite>;
  82091. /** @hidden */
  82092. _tempSpritePickingRay: Nullable<Ray>;
  82093. /**
  82094. * All of the sprite managers added to this scene
  82095. * @see http://doc.babylonjs.com/babylon101/sprites
  82096. */
  82097. spriteManagers: Array<ISpriteManager>;
  82098. /**
  82099. * An event triggered when sprites rendering is about to start
  82100. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82101. */
  82102. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82103. /**
  82104. * An event triggered when sprites rendering is done
  82105. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82106. */
  82107. onAfterSpritesRenderingObservable: Observable<Scene>;
  82108. /** @hidden */
  82109. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82110. /** Launch a ray to try to pick a sprite in the scene
  82111. * @param x position on screen
  82112. * @param y position on screen
  82113. * @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
  82114. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82115. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82116. * @returns a PickingInfo
  82117. */
  82118. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82119. /** Use the given ray to pick a sprite in the scene
  82120. * @param ray The ray (in world space) to use to pick meshes
  82121. * @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
  82122. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82123. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82124. * @returns a PickingInfo
  82125. */
  82126. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82127. /** @hidden */
  82128. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82129. /** Launch a ray to try to pick sprites in the scene
  82130. * @param x position on screen
  82131. * @param y position on screen
  82132. * @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
  82133. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82134. * @returns a PickingInfo array
  82135. */
  82136. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82137. /** Use the given ray to pick sprites in the scene
  82138. * @param ray The ray (in world space) to use to pick meshes
  82139. * @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
  82140. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82141. * @returns a PickingInfo array
  82142. */
  82143. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82144. /**
  82145. * Force the sprite under the pointer
  82146. * @param sprite defines the sprite to use
  82147. */
  82148. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82149. /**
  82150. * Gets the sprite under the pointer
  82151. * @returns a Sprite or null if no sprite is under the pointer
  82152. */
  82153. getPointerOverSprite(): Nullable<Sprite>;
  82154. }
  82155. /**
  82156. * Defines the sprite scene component responsible to manage sprites
  82157. * in a given scene.
  82158. */
  82159. export class SpriteSceneComponent implements ISceneComponent {
  82160. /**
  82161. * The component name helpfull to identify the component in the list of scene components.
  82162. */
  82163. readonly name: string;
  82164. /**
  82165. * The scene the component belongs to.
  82166. */
  82167. scene: Scene;
  82168. /** @hidden */
  82169. private _spritePredicate;
  82170. /**
  82171. * Creates a new instance of the component for the given scene
  82172. * @param scene Defines the scene to register the component in
  82173. */
  82174. constructor(scene: Scene);
  82175. /**
  82176. * Registers the component in a given scene
  82177. */
  82178. register(): void;
  82179. /**
  82180. * Rebuilds the elements related to this component in case of
  82181. * context lost for instance.
  82182. */
  82183. rebuild(): void;
  82184. /**
  82185. * Disposes the component and the associated ressources.
  82186. */
  82187. dispose(): void;
  82188. private _pickSpriteButKeepRay;
  82189. private _pointerMove;
  82190. private _pointerDown;
  82191. private _pointerUp;
  82192. }
  82193. }
  82194. declare module BABYLON {
  82195. /** @hidden */
  82196. export var fogFragmentDeclaration: {
  82197. name: string;
  82198. shader: string;
  82199. };
  82200. }
  82201. declare module BABYLON {
  82202. /** @hidden */
  82203. export var fogFragment: {
  82204. name: string;
  82205. shader: string;
  82206. };
  82207. }
  82208. declare module BABYLON {
  82209. /** @hidden */
  82210. export var spritesPixelShader: {
  82211. name: string;
  82212. shader: string;
  82213. };
  82214. }
  82215. declare module BABYLON {
  82216. /** @hidden */
  82217. export var fogVertexDeclaration: {
  82218. name: string;
  82219. shader: string;
  82220. };
  82221. }
  82222. declare module BABYLON {
  82223. /** @hidden */
  82224. export var spritesVertexShader: {
  82225. name: string;
  82226. shader: string;
  82227. };
  82228. }
  82229. declare module BABYLON {
  82230. /**
  82231. * Defines the minimum interface to fullfil in order to be a sprite manager.
  82232. */
  82233. export interface ISpriteManager extends IDisposable {
  82234. /**
  82235. * Restricts the camera to viewing objects with the same layerMask.
  82236. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  82237. */
  82238. layerMask: number;
  82239. /**
  82240. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82241. */
  82242. isPickable: boolean;
  82243. /**
  82244. * Specifies the rendering group id for this mesh (0 by default)
  82245. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82246. */
  82247. renderingGroupId: number;
  82248. /**
  82249. * Defines the list of sprites managed by the manager.
  82250. */
  82251. sprites: Array<Sprite>;
  82252. /**
  82253. * Tests the intersection of a sprite with a specific ray.
  82254. * @param ray The ray we are sending to test the collision
  82255. * @param camera The camera space we are sending rays in
  82256. * @param predicate A predicate allowing excluding sprites from the list of object to test
  82257. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  82258. * @returns picking info or null.
  82259. */
  82260. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82261. /**
  82262. * Intersects the sprites with a ray
  82263. * @param ray defines the ray to intersect with
  82264. * @param camera defines the current active camera
  82265. * @param predicate defines a predicate used to select candidate sprites
  82266. * @returns null if no hit or a PickingInfo array
  82267. */
  82268. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82269. /**
  82270. * Renders the list of sprites on screen.
  82271. */
  82272. render(): void;
  82273. }
  82274. /**
  82275. * Class used to manage multiple sprites on the same spritesheet
  82276. * @see http://doc.babylonjs.com/babylon101/sprites
  82277. */
  82278. export class SpriteManager implements ISpriteManager {
  82279. /** defines the manager's name */
  82280. name: string;
  82281. /** Gets the list of sprites */
  82282. sprites: Sprite[];
  82283. /** Gets or sets the rendering group id (0 by default) */
  82284. renderingGroupId: number;
  82285. /** Gets or sets camera layer mask */
  82286. layerMask: number;
  82287. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  82288. fogEnabled: boolean;
  82289. /** Gets or sets a boolean indicating if the sprites are pickable */
  82290. isPickable: boolean;
  82291. /** Defines the default width of a cell in the spritesheet */
  82292. cellWidth: number;
  82293. /** Defines the default height of a cell in the spritesheet */
  82294. cellHeight: number;
  82295. /** Associative array from JSON sprite data file */
  82296. private _cellData;
  82297. /** Array of sprite names from JSON sprite data file */
  82298. private _spriteMap;
  82299. /** True when packed cell data from JSON file is ready*/
  82300. private _packedAndReady;
  82301. /**
  82302. * An event triggered when the manager is disposed.
  82303. */
  82304. onDisposeObservable: Observable<SpriteManager>;
  82305. private _onDisposeObserver;
  82306. /**
  82307. * Callback called when the manager is disposed
  82308. */
  82309. set onDispose(callback: () => void);
  82310. private _capacity;
  82311. private _fromPacked;
  82312. private _spriteTexture;
  82313. private _epsilon;
  82314. private _scene;
  82315. private _vertexData;
  82316. private _buffer;
  82317. private _vertexBuffers;
  82318. private _indexBuffer;
  82319. private _effectBase;
  82320. private _effectFog;
  82321. /**
  82322. * Gets or sets the spritesheet texture
  82323. */
  82324. get texture(): Texture;
  82325. set texture(value: Texture);
  82326. /**
  82327. * Creates a new sprite manager
  82328. * @param name defines the manager's name
  82329. * @param imgUrl defines the sprite sheet url
  82330. * @param capacity defines the maximum allowed number of sprites
  82331. * @param cellSize defines the size of a sprite cell
  82332. * @param scene defines the hosting scene
  82333. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  82334. * @param samplingMode defines the smapling mode to use with spritesheet
  82335. * @param fromPacked set to false; do not alter
  82336. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  82337. */
  82338. constructor(
  82339. /** defines the manager's name */
  82340. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  82341. private _makePacked;
  82342. private _appendSpriteVertex;
  82343. /**
  82344. * Intersects the sprites with a ray
  82345. * @param ray defines the ray to intersect with
  82346. * @param camera defines the current active camera
  82347. * @param predicate defines a predicate used to select candidate sprites
  82348. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  82349. * @returns null if no hit or a PickingInfo
  82350. */
  82351. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82352. /**
  82353. * Intersects the sprites with a ray
  82354. * @param ray defines the ray to intersect with
  82355. * @param camera defines the current active camera
  82356. * @param predicate defines a predicate used to select candidate sprites
  82357. * @returns null if no hit or a PickingInfo array
  82358. */
  82359. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82360. /**
  82361. * Render all child sprites
  82362. */
  82363. render(): void;
  82364. /**
  82365. * Release associated resources
  82366. */
  82367. dispose(): void;
  82368. }
  82369. }
  82370. declare module BABYLON {
  82371. /**
  82372. * Class used to represent a sprite
  82373. * @see http://doc.babylonjs.com/babylon101/sprites
  82374. */
  82375. export class Sprite {
  82376. /** defines the name */
  82377. name: string;
  82378. /** Gets or sets the current world position */
  82379. position: Vector3;
  82380. /** Gets or sets the main color */
  82381. color: Color4;
  82382. /** Gets or sets the width */
  82383. width: number;
  82384. /** Gets or sets the height */
  82385. height: number;
  82386. /** Gets or sets rotation angle */
  82387. angle: number;
  82388. /** Gets or sets the cell index in the sprite sheet */
  82389. cellIndex: number;
  82390. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  82391. cellRef: string;
  82392. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  82393. invertU: number;
  82394. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  82395. invertV: number;
  82396. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  82397. disposeWhenFinishedAnimating: boolean;
  82398. /** Gets the list of attached animations */
  82399. animations: Animation[];
  82400. /** Gets or sets a boolean indicating if the sprite can be picked */
  82401. isPickable: boolean;
  82402. /**
  82403. * Gets or sets the associated action manager
  82404. */
  82405. actionManager: Nullable<ActionManager>;
  82406. private _animationStarted;
  82407. private _loopAnimation;
  82408. private _fromIndex;
  82409. private _toIndex;
  82410. private _delay;
  82411. private _direction;
  82412. private _manager;
  82413. private _time;
  82414. private _onAnimationEnd;
  82415. /**
  82416. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  82417. */
  82418. isVisible: boolean;
  82419. /**
  82420. * Gets or sets the sprite size
  82421. */
  82422. get size(): number;
  82423. set size(value: number);
  82424. /**
  82425. * Creates a new Sprite
  82426. * @param name defines the name
  82427. * @param manager defines the manager
  82428. */
  82429. constructor(
  82430. /** defines the name */
  82431. name: string, manager: ISpriteManager);
  82432. /**
  82433. * Starts an animation
  82434. * @param from defines the initial key
  82435. * @param to defines the end key
  82436. * @param loop defines if the animation must loop
  82437. * @param delay defines the start delay (in ms)
  82438. * @param onAnimationEnd defines a callback to call when animation ends
  82439. */
  82440. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  82441. /** Stops current animation (if any) */
  82442. stopAnimation(): void;
  82443. /** @hidden */
  82444. _animate(deltaTime: number): void;
  82445. /** Release associated resources */
  82446. dispose(): void;
  82447. }
  82448. }
  82449. declare module BABYLON {
  82450. /**
  82451. * Information about the result of picking within a scene
  82452. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  82453. */
  82454. export class PickingInfo {
  82455. /** @hidden */
  82456. _pickingUnavailable: boolean;
  82457. /**
  82458. * If the pick collided with an object
  82459. */
  82460. hit: boolean;
  82461. /**
  82462. * Distance away where the pick collided
  82463. */
  82464. distance: number;
  82465. /**
  82466. * The location of pick collision
  82467. */
  82468. pickedPoint: Nullable<Vector3>;
  82469. /**
  82470. * The mesh corresponding the the pick collision
  82471. */
  82472. pickedMesh: Nullable<AbstractMesh>;
  82473. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  82474. bu: number;
  82475. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  82476. bv: number;
  82477. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  82478. faceId: number;
  82479. /** Id of the the submesh that was picked */
  82480. subMeshId: number;
  82481. /** If a sprite was picked, this will be the sprite the pick collided with */
  82482. pickedSprite: Nullable<Sprite>;
  82483. /**
  82484. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  82485. */
  82486. originMesh: Nullable<AbstractMesh>;
  82487. /**
  82488. * The ray that was used to perform the picking.
  82489. */
  82490. ray: Nullable<Ray>;
  82491. /**
  82492. * Gets the normal correspodning to the face the pick collided with
  82493. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  82494. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  82495. * @returns The normal correspodning to the face the pick collided with
  82496. */
  82497. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  82498. /**
  82499. * Gets the texture coordinates of where the pick occured
  82500. * @returns the vector containing the coordnates of the texture
  82501. */
  82502. getTextureCoordinates(): Nullable<Vector2>;
  82503. }
  82504. }
  82505. declare module BABYLON {
  82506. /**
  82507. * Gather the list of pointer event types as constants.
  82508. */
  82509. export class PointerEventTypes {
  82510. /**
  82511. * 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.
  82512. */
  82513. static readonly POINTERDOWN: number;
  82514. /**
  82515. * The pointerup event is fired when a pointer is no longer active.
  82516. */
  82517. static readonly POINTERUP: number;
  82518. /**
  82519. * The pointermove event is fired when a pointer changes coordinates.
  82520. */
  82521. static readonly POINTERMOVE: number;
  82522. /**
  82523. * The pointerwheel event is fired when a mouse wheel has been rotated.
  82524. */
  82525. static readonly POINTERWHEEL: number;
  82526. /**
  82527. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  82528. */
  82529. static readonly POINTERPICK: number;
  82530. /**
  82531. * The pointertap event is fired when a the object has been touched and released without drag.
  82532. */
  82533. static readonly POINTERTAP: number;
  82534. /**
  82535. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  82536. */
  82537. static readonly POINTERDOUBLETAP: number;
  82538. }
  82539. /**
  82540. * Base class of pointer info types.
  82541. */
  82542. export class PointerInfoBase {
  82543. /**
  82544. * Defines the type of event (PointerEventTypes)
  82545. */
  82546. type: number;
  82547. /**
  82548. * Defines the related dom event
  82549. */
  82550. event: PointerEvent | MouseWheelEvent;
  82551. /**
  82552. * Instantiates the base class of pointers info.
  82553. * @param type Defines the type of event (PointerEventTypes)
  82554. * @param event Defines the related dom event
  82555. */
  82556. constructor(
  82557. /**
  82558. * Defines the type of event (PointerEventTypes)
  82559. */
  82560. type: number,
  82561. /**
  82562. * Defines the related dom event
  82563. */
  82564. event: PointerEvent | MouseWheelEvent);
  82565. }
  82566. /**
  82567. * This class is used to store pointer related info for the onPrePointerObservable event.
  82568. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  82569. */
  82570. export class PointerInfoPre extends PointerInfoBase {
  82571. /**
  82572. * Ray from a pointer if availible (eg. 6dof controller)
  82573. */
  82574. ray: Nullable<Ray>;
  82575. /**
  82576. * Defines the local position of the pointer on the canvas.
  82577. */
  82578. localPosition: Vector2;
  82579. /**
  82580. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  82581. */
  82582. skipOnPointerObservable: boolean;
  82583. /**
  82584. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  82585. * @param type Defines the type of event (PointerEventTypes)
  82586. * @param event Defines the related dom event
  82587. * @param localX Defines the local x coordinates of the pointer when the event occured
  82588. * @param localY Defines the local y coordinates of the pointer when the event occured
  82589. */
  82590. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  82591. }
  82592. /**
  82593. * This type contains all the data related to a pointer event in Babylon.js.
  82594. * 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.
  82595. */
  82596. export class PointerInfo extends PointerInfoBase {
  82597. /**
  82598. * Defines the picking info associated to the info (if any)\
  82599. */
  82600. pickInfo: Nullable<PickingInfo>;
  82601. /**
  82602. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  82603. * @param type Defines the type of event (PointerEventTypes)
  82604. * @param event Defines the related dom event
  82605. * @param pickInfo Defines the picking info associated to the info (if any)\
  82606. */
  82607. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  82608. /**
  82609. * Defines the picking info associated to the info (if any)\
  82610. */
  82611. pickInfo: Nullable<PickingInfo>);
  82612. }
  82613. /**
  82614. * Data relating to a touch event on the screen.
  82615. */
  82616. export interface PointerTouch {
  82617. /**
  82618. * X coordinate of touch.
  82619. */
  82620. x: number;
  82621. /**
  82622. * Y coordinate of touch.
  82623. */
  82624. y: number;
  82625. /**
  82626. * Id of touch. Unique for each finger.
  82627. */
  82628. pointerId: number;
  82629. /**
  82630. * Event type passed from DOM.
  82631. */
  82632. type: any;
  82633. }
  82634. }
  82635. declare module BABYLON {
  82636. /**
  82637. * Manage the mouse inputs to control the movement of a free camera.
  82638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82639. */
  82640. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  82641. /**
  82642. * Define if touch is enabled in the mouse input
  82643. */
  82644. touchEnabled: boolean;
  82645. /**
  82646. * Defines the camera the input is attached to.
  82647. */
  82648. camera: FreeCamera;
  82649. /**
  82650. * Defines the buttons associated with the input to handle camera move.
  82651. */
  82652. buttons: number[];
  82653. /**
  82654. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  82655. */
  82656. angularSensibility: number;
  82657. private _pointerInput;
  82658. private _onMouseMove;
  82659. private _observer;
  82660. private previousPosition;
  82661. /**
  82662. * Observable for when a pointer move event occurs containing the move offset
  82663. */
  82664. onPointerMovedObservable: Observable<{
  82665. offsetX: number;
  82666. offsetY: number;
  82667. }>;
  82668. /**
  82669. * @hidden
  82670. * If the camera should be rotated automatically based on pointer movement
  82671. */
  82672. _allowCameraRotation: boolean;
  82673. /**
  82674. * Manage the mouse inputs to control the movement of a free camera.
  82675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82676. * @param touchEnabled Defines if touch is enabled or not
  82677. */
  82678. constructor(
  82679. /**
  82680. * Define if touch is enabled in the mouse input
  82681. */
  82682. touchEnabled?: boolean);
  82683. /**
  82684. * Attach the input controls to a specific dom element to get the input from.
  82685. * @param element Defines the element the controls should be listened from
  82686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82687. */
  82688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82689. /**
  82690. * Called on JS contextmenu event.
  82691. * Override this method to provide functionality.
  82692. */
  82693. protected onContextMenu(evt: PointerEvent): void;
  82694. /**
  82695. * Detach the current controls from the specified dom element.
  82696. * @param element Defines the element to stop listening the inputs from
  82697. */
  82698. detachControl(element: Nullable<HTMLElement>): void;
  82699. /**
  82700. * Gets the class name of the current intput.
  82701. * @returns the class name
  82702. */
  82703. getClassName(): string;
  82704. /**
  82705. * Get the friendly name associated with the input class.
  82706. * @returns the input friendly name
  82707. */
  82708. getSimpleName(): string;
  82709. }
  82710. }
  82711. declare module BABYLON {
  82712. /**
  82713. * Manage the touch inputs to control the movement of a free camera.
  82714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82715. */
  82716. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  82717. /**
  82718. * Defines the camera the input is attached to.
  82719. */
  82720. camera: FreeCamera;
  82721. /**
  82722. * Defines the touch sensibility for rotation.
  82723. * The higher the faster.
  82724. */
  82725. touchAngularSensibility: number;
  82726. /**
  82727. * Defines the touch sensibility for move.
  82728. * The higher the faster.
  82729. */
  82730. touchMoveSensibility: number;
  82731. private _offsetX;
  82732. private _offsetY;
  82733. private _pointerPressed;
  82734. private _pointerInput;
  82735. private _observer;
  82736. private _onLostFocus;
  82737. /**
  82738. * Attach the input controls to a specific dom element to get the input from.
  82739. * @param element Defines the element the controls should be listened from
  82740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82741. */
  82742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82743. /**
  82744. * Detach the current controls from the specified dom element.
  82745. * @param element Defines the element to stop listening the inputs from
  82746. */
  82747. detachControl(element: Nullable<HTMLElement>): void;
  82748. /**
  82749. * Update the current camera state depending on the inputs that have been used this frame.
  82750. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82751. */
  82752. checkInputs(): void;
  82753. /**
  82754. * Gets the class name of the current intput.
  82755. * @returns the class name
  82756. */
  82757. getClassName(): string;
  82758. /**
  82759. * Get the friendly name associated with the input class.
  82760. * @returns the input friendly name
  82761. */
  82762. getSimpleName(): string;
  82763. }
  82764. }
  82765. declare module BABYLON {
  82766. /**
  82767. * Default Inputs manager for the FreeCamera.
  82768. * It groups all the default supported inputs for ease of use.
  82769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82770. */
  82771. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  82772. /**
  82773. * @hidden
  82774. */
  82775. _mouseInput: Nullable<FreeCameraMouseInput>;
  82776. /**
  82777. * Instantiates a new FreeCameraInputsManager.
  82778. * @param camera Defines the camera the inputs belong to
  82779. */
  82780. constructor(camera: FreeCamera);
  82781. /**
  82782. * Add keyboard input support to the input manager.
  82783. * @returns the current input manager
  82784. */
  82785. addKeyboard(): FreeCameraInputsManager;
  82786. /**
  82787. * Add mouse input support to the input manager.
  82788. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  82789. * @returns the current input manager
  82790. */
  82791. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  82792. /**
  82793. * Removes the mouse input support from the manager
  82794. * @returns the current input manager
  82795. */
  82796. removeMouse(): FreeCameraInputsManager;
  82797. /**
  82798. * Add touch input support to the input manager.
  82799. * @returns the current input manager
  82800. */
  82801. addTouch(): FreeCameraInputsManager;
  82802. /**
  82803. * Remove all attached input methods from a camera
  82804. */
  82805. clear(): void;
  82806. }
  82807. }
  82808. declare module BABYLON {
  82809. /**
  82810. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82811. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  82812. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82813. */
  82814. export class FreeCamera extends TargetCamera {
  82815. /**
  82816. * Define the collision ellipsoid of the camera.
  82817. * This is helpful to simulate a camera body like the player body around the camera
  82818. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  82819. */
  82820. ellipsoid: Vector3;
  82821. /**
  82822. * Define an offset for the position of the ellipsoid around the camera.
  82823. * This can be helpful to determine the center of the body near the gravity center of the body
  82824. * instead of its head.
  82825. */
  82826. ellipsoidOffset: Vector3;
  82827. /**
  82828. * Enable or disable collisions of the camera with the rest of the scene objects.
  82829. */
  82830. checkCollisions: boolean;
  82831. /**
  82832. * Enable or disable gravity on the camera.
  82833. */
  82834. applyGravity: boolean;
  82835. /**
  82836. * Define the input manager associated to the camera.
  82837. */
  82838. inputs: FreeCameraInputsManager;
  82839. /**
  82840. * Gets the input sensibility for a mouse input. (default is 2000.0)
  82841. * Higher values reduce sensitivity.
  82842. */
  82843. get angularSensibility(): number;
  82844. /**
  82845. * Sets the input sensibility for a mouse input. (default is 2000.0)
  82846. * Higher values reduce sensitivity.
  82847. */
  82848. set angularSensibility(value: number);
  82849. /**
  82850. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82851. */
  82852. get keysUp(): number[];
  82853. set keysUp(value: number[]);
  82854. /**
  82855. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82856. */
  82857. get keysDown(): number[];
  82858. set keysDown(value: number[]);
  82859. /**
  82860. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82861. */
  82862. get keysLeft(): number[];
  82863. set keysLeft(value: number[]);
  82864. /**
  82865. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82866. */
  82867. get keysRight(): number[];
  82868. set keysRight(value: number[]);
  82869. /**
  82870. * Event raised when the camera collide with a mesh in the scene.
  82871. */
  82872. onCollide: (collidedMesh: AbstractMesh) => void;
  82873. private _collider;
  82874. private _needMoveForGravity;
  82875. private _oldPosition;
  82876. private _diffPosition;
  82877. private _newPosition;
  82878. /** @hidden */
  82879. _localDirection: Vector3;
  82880. /** @hidden */
  82881. _transformedDirection: Vector3;
  82882. /**
  82883. * Instantiates a Free Camera.
  82884. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82885. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  82886. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82887. * @param name Define the name of the camera in the scene
  82888. * @param position Define the start position of the camera in the scene
  82889. * @param scene Define the scene the camera belongs to
  82890. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82891. */
  82892. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82893. /**
  82894. * Attached controls to the current camera.
  82895. * @param element Defines the element the controls should be listened from
  82896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82897. */
  82898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82899. /**
  82900. * Detach the current controls from the camera.
  82901. * The camera will stop reacting to inputs.
  82902. * @param element Defines the element to stop listening the inputs from
  82903. */
  82904. detachControl(element: HTMLElement): void;
  82905. private _collisionMask;
  82906. /**
  82907. * Define a collision mask to limit the list of object the camera can collide with
  82908. */
  82909. get collisionMask(): number;
  82910. set collisionMask(mask: number);
  82911. /** @hidden */
  82912. _collideWithWorld(displacement: Vector3): void;
  82913. private _onCollisionPositionChange;
  82914. /** @hidden */
  82915. _checkInputs(): void;
  82916. /** @hidden */
  82917. _decideIfNeedsToMove(): boolean;
  82918. /** @hidden */
  82919. _updatePosition(): void;
  82920. /**
  82921. * Destroy the camera and release the current resources hold by it.
  82922. */
  82923. dispose(): void;
  82924. /**
  82925. * Gets the current object class name.
  82926. * @return the class name
  82927. */
  82928. getClassName(): string;
  82929. }
  82930. }
  82931. declare module BABYLON {
  82932. /**
  82933. * Represents a gamepad control stick position
  82934. */
  82935. export class StickValues {
  82936. /**
  82937. * The x component of the control stick
  82938. */
  82939. x: number;
  82940. /**
  82941. * The y component of the control stick
  82942. */
  82943. y: number;
  82944. /**
  82945. * Initializes the gamepad x and y control stick values
  82946. * @param x The x component of the gamepad control stick value
  82947. * @param y The y component of the gamepad control stick value
  82948. */
  82949. constructor(
  82950. /**
  82951. * The x component of the control stick
  82952. */
  82953. x: number,
  82954. /**
  82955. * The y component of the control stick
  82956. */
  82957. y: number);
  82958. }
  82959. /**
  82960. * An interface which manages callbacks for gamepad button changes
  82961. */
  82962. export interface GamepadButtonChanges {
  82963. /**
  82964. * Called when a gamepad has been changed
  82965. */
  82966. changed: boolean;
  82967. /**
  82968. * Called when a gamepad press event has been triggered
  82969. */
  82970. pressChanged: boolean;
  82971. /**
  82972. * Called when a touch event has been triggered
  82973. */
  82974. touchChanged: boolean;
  82975. /**
  82976. * Called when a value has changed
  82977. */
  82978. valueChanged: boolean;
  82979. }
  82980. /**
  82981. * Represents a gamepad
  82982. */
  82983. export class Gamepad {
  82984. /**
  82985. * The id of the gamepad
  82986. */
  82987. id: string;
  82988. /**
  82989. * The index of the gamepad
  82990. */
  82991. index: number;
  82992. /**
  82993. * The browser gamepad
  82994. */
  82995. browserGamepad: any;
  82996. /**
  82997. * Specifies what type of gamepad this represents
  82998. */
  82999. type: number;
  83000. private _leftStick;
  83001. private _rightStick;
  83002. /** @hidden */
  83003. _isConnected: boolean;
  83004. private _leftStickAxisX;
  83005. private _leftStickAxisY;
  83006. private _rightStickAxisX;
  83007. private _rightStickAxisY;
  83008. /**
  83009. * Triggered when the left control stick has been changed
  83010. */
  83011. private _onleftstickchanged;
  83012. /**
  83013. * Triggered when the right control stick has been changed
  83014. */
  83015. private _onrightstickchanged;
  83016. /**
  83017. * Represents a gamepad controller
  83018. */
  83019. static GAMEPAD: number;
  83020. /**
  83021. * Represents a generic controller
  83022. */
  83023. static GENERIC: number;
  83024. /**
  83025. * Represents an XBox controller
  83026. */
  83027. static XBOX: number;
  83028. /**
  83029. * Represents a pose-enabled controller
  83030. */
  83031. static POSE_ENABLED: number;
  83032. /**
  83033. * Represents an Dual Shock controller
  83034. */
  83035. static DUALSHOCK: number;
  83036. /**
  83037. * Specifies whether the left control stick should be Y-inverted
  83038. */
  83039. protected _invertLeftStickY: boolean;
  83040. /**
  83041. * Specifies if the gamepad has been connected
  83042. */
  83043. get isConnected(): boolean;
  83044. /**
  83045. * Initializes the gamepad
  83046. * @param id The id of the gamepad
  83047. * @param index The index of the gamepad
  83048. * @param browserGamepad The browser gamepad
  83049. * @param leftStickX The x component of the left joystick
  83050. * @param leftStickY The y component of the left joystick
  83051. * @param rightStickX The x component of the right joystick
  83052. * @param rightStickY The y component of the right joystick
  83053. */
  83054. constructor(
  83055. /**
  83056. * The id of the gamepad
  83057. */
  83058. id: string,
  83059. /**
  83060. * The index of the gamepad
  83061. */
  83062. index: number,
  83063. /**
  83064. * The browser gamepad
  83065. */
  83066. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83067. /**
  83068. * Callback triggered when the left joystick has changed
  83069. * @param callback
  83070. */
  83071. onleftstickchanged(callback: (values: StickValues) => void): void;
  83072. /**
  83073. * Callback triggered when the right joystick has changed
  83074. * @param callback
  83075. */
  83076. onrightstickchanged(callback: (values: StickValues) => void): void;
  83077. /**
  83078. * Gets the left joystick
  83079. */
  83080. get leftStick(): StickValues;
  83081. /**
  83082. * Sets the left joystick values
  83083. */
  83084. set leftStick(newValues: StickValues);
  83085. /**
  83086. * Gets the right joystick
  83087. */
  83088. get rightStick(): StickValues;
  83089. /**
  83090. * Sets the right joystick value
  83091. */
  83092. set rightStick(newValues: StickValues);
  83093. /**
  83094. * Updates the gamepad joystick positions
  83095. */
  83096. update(): void;
  83097. /**
  83098. * Disposes the gamepad
  83099. */
  83100. dispose(): void;
  83101. }
  83102. /**
  83103. * Represents a generic gamepad
  83104. */
  83105. export class GenericPad extends Gamepad {
  83106. private _buttons;
  83107. private _onbuttondown;
  83108. private _onbuttonup;
  83109. /**
  83110. * Observable triggered when a button has been pressed
  83111. */
  83112. onButtonDownObservable: Observable<number>;
  83113. /**
  83114. * Observable triggered when a button has been released
  83115. */
  83116. onButtonUpObservable: Observable<number>;
  83117. /**
  83118. * Callback triggered when a button has been pressed
  83119. * @param callback Called when a button has been pressed
  83120. */
  83121. onbuttondown(callback: (buttonPressed: number) => void): void;
  83122. /**
  83123. * Callback triggered when a button has been released
  83124. * @param callback Called when a button has been released
  83125. */
  83126. onbuttonup(callback: (buttonReleased: number) => void): void;
  83127. /**
  83128. * Initializes the generic gamepad
  83129. * @param id The id of the generic gamepad
  83130. * @param index The index of the generic gamepad
  83131. * @param browserGamepad The browser gamepad
  83132. */
  83133. constructor(id: string, index: number, browserGamepad: any);
  83134. private _setButtonValue;
  83135. /**
  83136. * Updates the generic gamepad
  83137. */
  83138. update(): void;
  83139. /**
  83140. * Disposes the generic gamepad
  83141. */
  83142. dispose(): void;
  83143. }
  83144. }
  83145. declare module BABYLON {
  83146. interface Engine {
  83147. /**
  83148. * Creates a raw texture
  83149. * @param data defines the data to store in the texture
  83150. * @param width defines the width of the texture
  83151. * @param height defines the height of the texture
  83152. * @param format defines the format of the data
  83153. * @param generateMipMaps defines if the engine should generate the mip levels
  83154. * @param invertY defines if data must be stored with Y axis inverted
  83155. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83156. * @param compression defines the compression used (null by default)
  83157. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83158. * @returns the raw texture inside an InternalTexture
  83159. */
  83160. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83161. /**
  83162. * Update a raw texture
  83163. * @param texture defines the texture to update
  83164. * @param data defines the data to store in the texture
  83165. * @param format defines the format of the data
  83166. * @param invertY defines if data must be stored with Y axis inverted
  83167. */
  83168. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83169. /**
  83170. * Update a raw texture
  83171. * @param texture defines the texture to update
  83172. * @param data defines the data to store in the texture
  83173. * @param format defines the format of the data
  83174. * @param invertY defines if data must be stored with Y axis inverted
  83175. * @param compression defines the compression used (null by default)
  83176. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83177. */
  83178. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83179. /**
  83180. * Creates a new raw cube texture
  83181. * @param data defines the array of data to use to create each face
  83182. * @param size defines the size of the textures
  83183. * @param format defines the format of the data
  83184. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83185. * @param generateMipMaps defines if the engine should generate the mip levels
  83186. * @param invertY defines if data must be stored with Y axis inverted
  83187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83188. * @param compression defines the compression used (null by default)
  83189. * @returns the cube texture as an InternalTexture
  83190. */
  83191. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83192. /**
  83193. * Update a raw cube texture
  83194. * @param texture defines the texture to udpdate
  83195. * @param data defines the data to store
  83196. * @param format defines the data format
  83197. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83198. * @param invertY defines if data must be stored with Y axis inverted
  83199. */
  83200. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): 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. */
  83210. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83211. /**
  83212. * Update a raw cube texture
  83213. * @param texture defines the texture to udpdate
  83214. * @param data defines the data to store
  83215. * @param format defines the data format
  83216. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83217. * @param invertY defines if data must be stored with Y axis inverted
  83218. * @param compression defines the compression used (null by default)
  83219. * @param level defines which level of the texture to update
  83220. */
  83221. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83222. /**
  83223. * Creates a new raw cube texture from a specified url
  83224. * @param url defines the url where the data is located
  83225. * @param scene defines the current scene
  83226. * @param size defines the size of the textures
  83227. * @param format defines the format of the data
  83228. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83229. * @param noMipmap defines if the engine should avoid generating the mip levels
  83230. * @param callback defines a callback used to extract texture data from loaded data
  83231. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83232. * @param onLoad defines a callback called when texture is loaded
  83233. * @param onError defines a callback called if there is an error
  83234. * @returns the cube texture as an InternalTexture
  83235. */
  83236. 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;
  83237. /**
  83238. * Creates a new raw cube texture from a specified url
  83239. * @param url defines the url where the data is located
  83240. * @param scene defines the current scene
  83241. * @param size defines the size of the textures
  83242. * @param format defines the format of the data
  83243. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83244. * @param noMipmap defines if the engine should avoid generating the mip levels
  83245. * @param callback defines a callback used to extract texture data from loaded data
  83246. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83247. * @param onLoad defines a callback called when texture is loaded
  83248. * @param onError defines a callback called if there is an error
  83249. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83250. * @param invertY defines if data must be stored with Y axis inverted
  83251. * @returns the cube texture as an InternalTexture
  83252. */
  83253. 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;
  83254. /**
  83255. * Creates a new raw 3D texture
  83256. * @param data defines the data used to create the texture
  83257. * @param width defines the width of the texture
  83258. * @param height defines the height of the texture
  83259. * @param depth defines the depth of the texture
  83260. * @param format defines the format of the texture
  83261. * @param generateMipMaps defines if the engine must generate mip levels
  83262. * @param invertY defines if data must be stored with Y axis inverted
  83263. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83264. * @param compression defines the compressed used (can be null)
  83265. * @param textureType defines the compressed used (can be null)
  83266. * @returns a new raw 3D texture (stored in an InternalTexture)
  83267. */
  83268. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83269. /**
  83270. * Update a raw 3D texture
  83271. * @param texture defines the texture to update
  83272. * @param data defines the data to store
  83273. * @param format defines the data format
  83274. * @param invertY defines if data must be stored with Y axis inverted
  83275. */
  83276. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83277. /**
  83278. * Update a raw 3D texture
  83279. * @param texture defines the texture to update
  83280. * @param data defines the data to store
  83281. * @param format defines the data format
  83282. * @param invertY defines if data must be stored with Y axis inverted
  83283. * @param compression defines the used compression (can be null)
  83284. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83285. */
  83286. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83287. /**
  83288. * Creates a new raw 2D array texture
  83289. * @param data defines the data used to create the texture
  83290. * @param width defines the width of the texture
  83291. * @param height defines the height of the texture
  83292. * @param depth defines the number of layers of the texture
  83293. * @param format defines the format of the texture
  83294. * @param generateMipMaps defines if the engine must generate mip levels
  83295. * @param invertY defines if data must be stored with Y axis inverted
  83296. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83297. * @param compression defines the compressed used (can be null)
  83298. * @param textureType defines the compressed used (can be null)
  83299. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83300. */
  83301. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83302. /**
  83303. * Update a raw 2D array texture
  83304. * @param texture defines the texture to update
  83305. * @param data defines the data to store
  83306. * @param format defines the data format
  83307. * @param invertY defines if data must be stored with Y axis inverted
  83308. */
  83309. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83310. /**
  83311. * Update a raw 2D array texture
  83312. * @param texture defines the texture to update
  83313. * @param data defines the data to store
  83314. * @param format defines the data format
  83315. * @param invertY defines if data must be stored with Y axis inverted
  83316. * @param compression defines the used compression (can be null)
  83317. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83318. */
  83319. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83320. }
  83321. }
  83322. declare module BABYLON {
  83323. /**
  83324. * Raw texture can help creating a texture directly from an array of data.
  83325. * This can be super useful if you either get the data from an uncompressed source or
  83326. * if you wish to create your texture pixel by pixel.
  83327. */
  83328. export class RawTexture extends Texture {
  83329. /**
  83330. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83331. */
  83332. format: number;
  83333. private _engine;
  83334. /**
  83335. * Instantiates a new RawTexture.
  83336. * Raw texture can help creating a texture directly from an array of data.
  83337. * This can be super useful if you either get the data from an uncompressed source or
  83338. * if you wish to create your texture pixel by pixel.
  83339. * @param data define the array of data to use to create the texture
  83340. * @param width define the width of the texture
  83341. * @param height define the height of the texture
  83342. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83343. * @param scene define the scene the texture belongs to
  83344. * @param generateMipMaps define whether mip maps should be generated or not
  83345. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83346. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83347. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83348. */
  83349. constructor(data: ArrayBufferView, width: number, height: number,
  83350. /**
  83351. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83352. */
  83353. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83354. /**
  83355. * Updates the texture underlying data.
  83356. * @param data Define the new data of the texture
  83357. */
  83358. update(data: ArrayBufferView): void;
  83359. /**
  83360. * Creates a luminance texture from some data.
  83361. * @param data Define the texture data
  83362. * @param width Define the width of the texture
  83363. * @param height Define the height of the texture
  83364. * @param scene Define the scene the texture belongs to
  83365. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83366. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83367. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83368. * @returns the luminance texture
  83369. */
  83370. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83371. /**
  83372. * Creates a luminance alpha texture from some data.
  83373. * @param data Define the texture data
  83374. * @param width Define the width of the texture
  83375. * @param height Define the height of the texture
  83376. * @param scene Define the scene the texture belongs to
  83377. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83378. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83379. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83380. * @returns the luminance alpha texture
  83381. */
  83382. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83383. /**
  83384. * Creates an alpha texture from some data.
  83385. * @param data Define the texture data
  83386. * @param width Define the width of the texture
  83387. * @param height Define the height of the texture
  83388. * @param scene Define the scene the texture belongs to
  83389. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83390. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83391. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83392. * @returns the alpha texture
  83393. */
  83394. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83395. /**
  83396. * Creates a RGB texture from some data.
  83397. * @param data Define the texture data
  83398. * @param width Define the width of the texture
  83399. * @param height Define the height of the texture
  83400. * @param scene Define the scene the texture belongs to
  83401. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83402. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83403. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83404. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83405. * @returns the RGB alpha texture
  83406. */
  83407. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83408. /**
  83409. * Creates a RGBA texture from some data.
  83410. * @param data Define the texture data
  83411. * @param width Define the width of the texture
  83412. * @param height Define the height of the texture
  83413. * @param scene Define the scene the texture belongs to
  83414. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83415. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83416. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83417. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83418. * @returns the RGBA texture
  83419. */
  83420. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83421. /**
  83422. * Creates a R texture from some data.
  83423. * @param data Define the texture data
  83424. * @param width Define the width of the texture
  83425. * @param height Define the height of the texture
  83426. * @param scene Define the scene the texture belongs to
  83427. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83428. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83429. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83430. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83431. * @returns the R texture
  83432. */
  83433. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83434. }
  83435. }
  83436. declare module BABYLON {
  83437. /**
  83438. * Interface for the size containing width and height
  83439. */
  83440. export interface ISize {
  83441. /**
  83442. * Width
  83443. */
  83444. width: number;
  83445. /**
  83446. * Heighht
  83447. */
  83448. height: number;
  83449. }
  83450. /**
  83451. * Size containing widht and height
  83452. */
  83453. export class Size implements ISize {
  83454. /**
  83455. * Width
  83456. */
  83457. width: number;
  83458. /**
  83459. * Height
  83460. */
  83461. height: number;
  83462. /**
  83463. * Creates a Size object from the given width and height (floats).
  83464. * @param width width of the new size
  83465. * @param height height of the new size
  83466. */
  83467. constructor(width: number, height: number);
  83468. /**
  83469. * Returns a string with the Size width and height
  83470. * @returns a string with the Size width and height
  83471. */
  83472. toString(): string;
  83473. /**
  83474. * "Size"
  83475. * @returns the string "Size"
  83476. */
  83477. getClassName(): string;
  83478. /**
  83479. * Returns the Size hash code.
  83480. * @returns a hash code for a unique width and height
  83481. */
  83482. getHashCode(): number;
  83483. /**
  83484. * Updates the current size from the given one.
  83485. * @param src the given size
  83486. */
  83487. copyFrom(src: Size): void;
  83488. /**
  83489. * Updates in place the current Size from the given floats.
  83490. * @param width width of the new size
  83491. * @param height height of the new size
  83492. * @returns the updated Size.
  83493. */
  83494. copyFromFloats(width: number, height: number): Size;
  83495. /**
  83496. * Updates in place the current Size from the given floats.
  83497. * @param width width to set
  83498. * @param height height to set
  83499. * @returns the updated Size.
  83500. */
  83501. set(width: number, height: number): Size;
  83502. /**
  83503. * Multiplies the width and height by numbers
  83504. * @param w factor to multiple the width by
  83505. * @param h factor to multiple the height by
  83506. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83507. */
  83508. multiplyByFloats(w: number, h: number): Size;
  83509. /**
  83510. * Clones the size
  83511. * @returns a new Size copied from the given one.
  83512. */
  83513. clone(): Size;
  83514. /**
  83515. * True if the current Size and the given one width and height are strictly equal.
  83516. * @param other the other size to compare against
  83517. * @returns True if the current Size and the given one width and height are strictly equal.
  83518. */
  83519. equals(other: Size): boolean;
  83520. /**
  83521. * The surface of the Size : width * height (float).
  83522. */
  83523. get surface(): number;
  83524. /**
  83525. * Create a new size of zero
  83526. * @returns a new Size set to (0.0, 0.0)
  83527. */
  83528. static Zero(): Size;
  83529. /**
  83530. * Sums the width and height of two sizes
  83531. * @param otherSize size to add to this size
  83532. * @returns a new Size set as the addition result of the current Size and the given one.
  83533. */
  83534. add(otherSize: Size): Size;
  83535. /**
  83536. * Subtracts the width and height of two
  83537. * @param otherSize size to subtract to this size
  83538. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83539. */
  83540. subtract(otherSize: Size): Size;
  83541. /**
  83542. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83543. * @param start starting size to lerp between
  83544. * @param end end size to lerp between
  83545. * @param amount amount to lerp between the start and end values
  83546. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83547. */
  83548. static Lerp(start: Size, end: Size, amount: number): Size;
  83549. }
  83550. }
  83551. declare module BABYLON {
  83552. /**
  83553. * Defines a runtime animation
  83554. */
  83555. export class RuntimeAnimation {
  83556. private _events;
  83557. /**
  83558. * The current frame of the runtime animation
  83559. */
  83560. private _currentFrame;
  83561. /**
  83562. * The animation used by the runtime animation
  83563. */
  83564. private _animation;
  83565. /**
  83566. * The target of the runtime animation
  83567. */
  83568. private _target;
  83569. /**
  83570. * The initiating animatable
  83571. */
  83572. private _host;
  83573. /**
  83574. * The original value of the runtime animation
  83575. */
  83576. private _originalValue;
  83577. /**
  83578. * The original blend value of the runtime animation
  83579. */
  83580. private _originalBlendValue;
  83581. /**
  83582. * The offsets cache of the runtime animation
  83583. */
  83584. private _offsetsCache;
  83585. /**
  83586. * The high limits cache of the runtime animation
  83587. */
  83588. private _highLimitsCache;
  83589. /**
  83590. * Specifies if the runtime animation has been stopped
  83591. */
  83592. private _stopped;
  83593. /**
  83594. * The blending factor of the runtime animation
  83595. */
  83596. private _blendingFactor;
  83597. /**
  83598. * The BabylonJS scene
  83599. */
  83600. private _scene;
  83601. /**
  83602. * The current value of the runtime animation
  83603. */
  83604. private _currentValue;
  83605. /** @hidden */
  83606. _animationState: _IAnimationState;
  83607. /**
  83608. * The active target of the runtime animation
  83609. */
  83610. private _activeTargets;
  83611. private _currentActiveTarget;
  83612. private _directTarget;
  83613. /**
  83614. * The target path of the runtime animation
  83615. */
  83616. private _targetPath;
  83617. /**
  83618. * The weight of the runtime animation
  83619. */
  83620. private _weight;
  83621. /**
  83622. * The ratio offset of the runtime animation
  83623. */
  83624. private _ratioOffset;
  83625. /**
  83626. * The previous delay of the runtime animation
  83627. */
  83628. private _previousDelay;
  83629. /**
  83630. * The previous ratio of the runtime animation
  83631. */
  83632. private _previousRatio;
  83633. private _enableBlending;
  83634. private _keys;
  83635. private _minFrame;
  83636. private _maxFrame;
  83637. private _minValue;
  83638. private _maxValue;
  83639. private _targetIsArray;
  83640. /**
  83641. * Gets the current frame of the runtime animation
  83642. */
  83643. get currentFrame(): number;
  83644. /**
  83645. * Gets the weight of the runtime animation
  83646. */
  83647. get weight(): number;
  83648. /**
  83649. * Gets the current value of the runtime animation
  83650. */
  83651. get currentValue(): any;
  83652. /**
  83653. * Gets the target path of the runtime animation
  83654. */
  83655. get targetPath(): string;
  83656. /**
  83657. * Gets the actual target of the runtime animation
  83658. */
  83659. get target(): any;
  83660. /** @hidden */
  83661. _onLoop: () => void;
  83662. /**
  83663. * Create a new RuntimeAnimation object
  83664. * @param target defines the target of the animation
  83665. * @param animation defines the source animation object
  83666. * @param scene defines the hosting scene
  83667. * @param host defines the initiating Animatable
  83668. */
  83669. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  83670. private _preparePath;
  83671. /**
  83672. * Gets the animation from the runtime animation
  83673. */
  83674. get animation(): Animation;
  83675. /**
  83676. * Resets the runtime animation to the beginning
  83677. * @param restoreOriginal defines whether to restore the target property to the original value
  83678. */
  83679. reset(restoreOriginal?: boolean): void;
  83680. /**
  83681. * Specifies if the runtime animation is stopped
  83682. * @returns Boolean specifying if the runtime animation is stopped
  83683. */
  83684. isStopped(): boolean;
  83685. /**
  83686. * Disposes of the runtime animation
  83687. */
  83688. dispose(): void;
  83689. /**
  83690. * Apply the interpolated value to the target
  83691. * @param currentValue defines the value computed by the animation
  83692. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  83693. */
  83694. setValue(currentValue: any, weight: number): void;
  83695. private _getOriginalValues;
  83696. private _setValue;
  83697. /**
  83698. * Gets the loop pmode of the runtime animation
  83699. * @returns Loop Mode
  83700. */
  83701. private _getCorrectLoopMode;
  83702. /**
  83703. * Move the current animation to a given frame
  83704. * @param frame defines the frame to move to
  83705. */
  83706. goToFrame(frame: number): void;
  83707. /**
  83708. * @hidden Internal use only
  83709. */
  83710. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  83711. /**
  83712. * Execute the current animation
  83713. * @param delay defines the delay to add to the current frame
  83714. * @param from defines the lower bound of the animation range
  83715. * @param to defines the upper bound of the animation range
  83716. * @param loop defines if the current animation must loop
  83717. * @param speedRatio defines the current speed ratio
  83718. * @param weight defines the weight of the animation (default is -1 so no weight)
  83719. * @param onLoop optional callback called when animation loops
  83720. * @returns a boolean indicating if the animation is running
  83721. */
  83722. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  83723. }
  83724. }
  83725. declare module BABYLON {
  83726. /**
  83727. * Class used to store an actual running animation
  83728. */
  83729. export class Animatable {
  83730. /** defines the target object */
  83731. target: any;
  83732. /** defines the starting frame number (default is 0) */
  83733. fromFrame: number;
  83734. /** defines the ending frame number (default is 100) */
  83735. toFrame: number;
  83736. /** defines if the animation must loop (default is false) */
  83737. loopAnimation: boolean;
  83738. /** defines a callback to call when animation ends if it is not looping */
  83739. onAnimationEnd?: (() => void) | null | undefined;
  83740. /** defines a callback to call when animation loops */
  83741. onAnimationLoop?: (() => void) | null | undefined;
  83742. private _localDelayOffset;
  83743. private _pausedDelay;
  83744. private _runtimeAnimations;
  83745. private _paused;
  83746. private _scene;
  83747. private _speedRatio;
  83748. private _weight;
  83749. private _syncRoot;
  83750. /**
  83751. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  83752. * This will only apply for non looping animation (default is true)
  83753. */
  83754. disposeOnEnd: boolean;
  83755. /**
  83756. * Gets a boolean indicating if the animation has started
  83757. */
  83758. animationStarted: boolean;
  83759. /**
  83760. * Observer raised when the animation ends
  83761. */
  83762. onAnimationEndObservable: Observable<Animatable>;
  83763. /**
  83764. * Observer raised when the animation loops
  83765. */
  83766. onAnimationLoopObservable: Observable<Animatable>;
  83767. /**
  83768. * Gets the root Animatable used to synchronize and normalize animations
  83769. */
  83770. get syncRoot(): Nullable<Animatable>;
  83771. /**
  83772. * Gets the current frame of the first RuntimeAnimation
  83773. * Used to synchronize Animatables
  83774. */
  83775. get masterFrame(): number;
  83776. /**
  83777. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  83778. */
  83779. get weight(): number;
  83780. set weight(value: number);
  83781. /**
  83782. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  83783. */
  83784. get speedRatio(): number;
  83785. set speedRatio(value: number);
  83786. /**
  83787. * Creates a new Animatable
  83788. * @param scene defines the hosting scene
  83789. * @param target defines the target object
  83790. * @param fromFrame defines the starting frame number (default is 0)
  83791. * @param toFrame defines the ending frame number (default is 100)
  83792. * @param loopAnimation defines if the animation must loop (default is false)
  83793. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  83794. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  83795. * @param animations defines a group of animation to add to the new Animatable
  83796. * @param onAnimationLoop defines a callback to call when animation loops
  83797. */
  83798. constructor(scene: Scene,
  83799. /** defines the target object */
  83800. target: any,
  83801. /** defines the starting frame number (default is 0) */
  83802. fromFrame?: number,
  83803. /** defines the ending frame number (default is 100) */
  83804. toFrame?: number,
  83805. /** defines if the animation must loop (default is false) */
  83806. loopAnimation?: boolean, speedRatio?: number,
  83807. /** defines a callback to call when animation ends if it is not looping */
  83808. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  83809. /** defines a callback to call when animation loops */
  83810. onAnimationLoop?: (() => void) | null | undefined);
  83811. /**
  83812. * Synchronize and normalize current Animatable with a source Animatable
  83813. * This is useful when using animation weights and when animations are not of the same length
  83814. * @param root defines the root Animatable to synchronize with
  83815. * @returns the current Animatable
  83816. */
  83817. syncWith(root: Animatable): Animatable;
  83818. /**
  83819. * Gets the list of runtime animations
  83820. * @returns an array of RuntimeAnimation
  83821. */
  83822. getAnimations(): RuntimeAnimation[];
  83823. /**
  83824. * Adds more animations to the current animatable
  83825. * @param target defines the target of the animations
  83826. * @param animations defines the new animations to add
  83827. */
  83828. appendAnimations(target: any, animations: Animation[]): void;
  83829. /**
  83830. * Gets the source animation for a specific property
  83831. * @param property defines the propertyu to look for
  83832. * @returns null or the source animation for the given property
  83833. */
  83834. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  83835. /**
  83836. * Gets the runtime animation for a specific property
  83837. * @param property defines the propertyu to look for
  83838. * @returns null or the runtime animation for the given property
  83839. */
  83840. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  83841. /**
  83842. * Resets the animatable to its original state
  83843. */
  83844. reset(): void;
  83845. /**
  83846. * Allows the animatable to blend with current running animations
  83847. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83848. * @param blendingSpeed defines the blending speed to use
  83849. */
  83850. enableBlending(blendingSpeed: number): void;
  83851. /**
  83852. * Disable animation blending
  83853. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83854. */
  83855. disableBlending(): void;
  83856. /**
  83857. * Jump directly to a given frame
  83858. * @param frame defines the frame to jump to
  83859. */
  83860. goToFrame(frame: number): void;
  83861. /**
  83862. * Pause the animation
  83863. */
  83864. pause(): void;
  83865. /**
  83866. * Restart the animation
  83867. */
  83868. restart(): void;
  83869. private _raiseOnAnimationEnd;
  83870. /**
  83871. * Stop and delete the current animation
  83872. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  83873. * @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)
  83874. */
  83875. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  83876. /**
  83877. * Wait asynchronously for the animation to end
  83878. * @returns a promise which will be fullfilled when the animation ends
  83879. */
  83880. waitAsync(): Promise<Animatable>;
  83881. /** @hidden */
  83882. _animate(delay: number): boolean;
  83883. }
  83884. interface Scene {
  83885. /** @hidden */
  83886. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  83887. /** @hidden */
  83888. _processLateAnimationBindingsForMatrices(holder: {
  83889. totalWeight: number;
  83890. animations: RuntimeAnimation[];
  83891. originalValue: Matrix;
  83892. }): any;
  83893. /** @hidden */
  83894. _processLateAnimationBindingsForQuaternions(holder: {
  83895. totalWeight: number;
  83896. animations: RuntimeAnimation[];
  83897. originalValue: Quaternion;
  83898. }, refQuaternion: Quaternion): Quaternion;
  83899. /** @hidden */
  83900. _processLateAnimationBindings(): void;
  83901. /**
  83902. * Will start the animation sequence of a given target
  83903. * @param target defines the target
  83904. * @param from defines from which frame should animation start
  83905. * @param to defines until which frame should animation run.
  83906. * @param weight defines the weight to apply to the animation (1.0 by default)
  83907. * @param loop defines if the animation loops
  83908. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83909. * @param onAnimationEnd defines the function to be executed when the animation ends
  83910. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83911. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83912. * @param onAnimationLoop defines the callback to call when an animation loops
  83913. * @returns the animatable object created for this animation
  83914. */
  83915. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83916. /**
  83917. * Will start the animation sequence of a given target
  83918. * @param target defines the target
  83919. * @param from defines from which frame should animation start
  83920. * @param to defines until which frame should animation run.
  83921. * @param loop defines if the animation loops
  83922. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83923. * @param onAnimationEnd defines the function to be executed when the animation ends
  83924. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83925. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83926. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  83927. * @param onAnimationLoop defines the callback to call when an animation loops
  83928. * @returns the animatable object created for this animation
  83929. */
  83930. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83931. /**
  83932. * Will start the animation sequence of a given target and its hierarchy
  83933. * @param target defines the target
  83934. * @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.
  83935. * @param from defines from which frame should animation start
  83936. * @param to defines until which frame should animation run.
  83937. * @param loop defines if the animation loops
  83938. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83939. * @param onAnimationEnd defines the function to be executed when the animation ends
  83940. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83941. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83942. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83943. * @param onAnimationLoop defines the callback to call when an animation loops
  83944. * @returns the list of created animatables
  83945. */
  83946. 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[];
  83947. /**
  83948. * Begin a new animation on a given node
  83949. * @param target defines the target where the animation will take place
  83950. * @param animations defines the list of animations to start
  83951. * @param from defines the initial value
  83952. * @param to defines the final value
  83953. * @param loop defines if you want animation to loop (off by default)
  83954. * @param speedRatio defines the speed ratio to apply to all animations
  83955. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83956. * @param onAnimationLoop defines the callback to call when an animation loops
  83957. * @returns the list of created animatables
  83958. */
  83959. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  83960. /**
  83961. * Begin a new animation on a given node and its hierarchy
  83962. * @param target defines the root node where the animation will take place
  83963. * @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.
  83964. * @param animations defines the list of animations to start
  83965. * @param from defines the initial value
  83966. * @param to defines the final value
  83967. * @param loop defines if you want animation to loop (off by default)
  83968. * @param speedRatio defines the speed ratio to apply to all animations
  83969. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83970. * @param onAnimationLoop defines the callback to call when an animation loops
  83971. * @returns the list of animatables created for all nodes
  83972. */
  83973. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  83974. /**
  83975. * Gets the animatable associated with a specific target
  83976. * @param target defines the target of the animatable
  83977. * @returns the required animatable if found
  83978. */
  83979. getAnimatableByTarget(target: any): Nullable<Animatable>;
  83980. /**
  83981. * Gets all animatables associated with a given target
  83982. * @param target defines the target to look animatables for
  83983. * @returns an array of Animatables
  83984. */
  83985. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  83986. /**
  83987. * Stops and removes all animations that have been applied to the scene
  83988. */
  83989. stopAllAnimations(): void;
  83990. /**
  83991. * Gets the current delta time used by animation engine
  83992. */
  83993. deltaTime: number;
  83994. }
  83995. interface Bone {
  83996. /**
  83997. * Copy an animation range from another bone
  83998. * @param source defines the source bone
  83999. * @param rangeName defines the range name to copy
  84000. * @param frameOffset defines the frame offset
  84001. * @param rescaleAsRequired defines if rescaling must be applied if required
  84002. * @param skelDimensionsRatio defines the scaling ratio
  84003. * @returns true if operation was successful
  84004. */
  84005. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  84006. }
  84007. }
  84008. declare module BABYLON {
  84009. /**
  84010. * Class used to override all child animations of a given target
  84011. */
  84012. export class AnimationPropertiesOverride {
  84013. /**
  84014. * Gets or sets a value indicating if animation blending must be used
  84015. */
  84016. enableBlending: boolean;
  84017. /**
  84018. * Gets or sets the blending speed to use when enableBlending is true
  84019. */
  84020. blendingSpeed: number;
  84021. /**
  84022. * Gets or sets the default loop mode to use
  84023. */
  84024. loopMode: number;
  84025. }
  84026. }
  84027. declare module BABYLON {
  84028. /**
  84029. * Class used to handle skinning animations
  84030. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84031. */
  84032. export class Skeleton implements IAnimatable {
  84033. /** defines the skeleton name */
  84034. name: string;
  84035. /** defines the skeleton Id */
  84036. id: string;
  84037. /**
  84038. * Defines the list of child bones
  84039. */
  84040. bones: Bone[];
  84041. /**
  84042. * Defines an estimate of the dimension of the skeleton at rest
  84043. */
  84044. dimensionsAtRest: Vector3;
  84045. /**
  84046. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84047. */
  84048. needInitialSkinMatrix: boolean;
  84049. /**
  84050. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84051. */
  84052. overrideMesh: Nullable<AbstractMesh>;
  84053. /**
  84054. * Gets the list of animations attached to this skeleton
  84055. */
  84056. animations: Array<Animation>;
  84057. private _scene;
  84058. private _isDirty;
  84059. private _transformMatrices;
  84060. private _transformMatrixTexture;
  84061. private _meshesWithPoseMatrix;
  84062. private _animatables;
  84063. private _identity;
  84064. private _synchronizedWithMesh;
  84065. private _ranges;
  84066. private _lastAbsoluteTransformsUpdateId;
  84067. private _canUseTextureForBones;
  84068. private _uniqueId;
  84069. /** @hidden */
  84070. _numBonesWithLinkedTransformNode: number;
  84071. /** @hidden */
  84072. _hasWaitingData: Nullable<boolean>;
  84073. /**
  84074. * Specifies if the skeleton should be serialized
  84075. */
  84076. doNotSerialize: boolean;
  84077. private _useTextureToStoreBoneMatrices;
  84078. /**
  84079. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84080. * Please note that this option is not available if the hardware does not support it
  84081. */
  84082. get useTextureToStoreBoneMatrices(): boolean;
  84083. set useTextureToStoreBoneMatrices(value: boolean);
  84084. private _animationPropertiesOverride;
  84085. /**
  84086. * Gets or sets the animation properties override
  84087. */
  84088. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84089. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84090. /**
  84091. * List of inspectable custom properties (used by the Inspector)
  84092. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84093. */
  84094. inspectableCustomProperties: IInspectable[];
  84095. /**
  84096. * An observable triggered before computing the skeleton's matrices
  84097. */
  84098. onBeforeComputeObservable: Observable<Skeleton>;
  84099. /**
  84100. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84101. */
  84102. get isUsingTextureForMatrices(): boolean;
  84103. /**
  84104. * Gets the unique ID of this skeleton
  84105. */
  84106. get uniqueId(): number;
  84107. /**
  84108. * Creates a new skeleton
  84109. * @param name defines the skeleton name
  84110. * @param id defines the skeleton Id
  84111. * @param scene defines the hosting scene
  84112. */
  84113. constructor(
  84114. /** defines the skeleton name */
  84115. name: string,
  84116. /** defines the skeleton Id */
  84117. id: string, scene: Scene);
  84118. /**
  84119. * Gets the current object class name.
  84120. * @return the class name
  84121. */
  84122. getClassName(): string;
  84123. /**
  84124. * Returns an array containing the root bones
  84125. * @returns an array containing the root bones
  84126. */
  84127. getChildren(): Array<Bone>;
  84128. /**
  84129. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84130. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84131. * @returns a Float32Array containing matrices data
  84132. */
  84133. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84134. /**
  84135. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84136. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84137. * @returns a raw texture containing the data
  84138. */
  84139. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84140. /**
  84141. * Gets the current hosting scene
  84142. * @returns a scene object
  84143. */
  84144. getScene(): Scene;
  84145. /**
  84146. * Gets a string representing the current skeleton data
  84147. * @param fullDetails defines a boolean indicating if we want a verbose version
  84148. * @returns a string representing the current skeleton data
  84149. */
  84150. toString(fullDetails?: boolean): string;
  84151. /**
  84152. * Get bone's index searching by name
  84153. * @param name defines bone's name to search for
  84154. * @return the indice of the bone. Returns -1 if not found
  84155. */
  84156. getBoneIndexByName(name: string): number;
  84157. /**
  84158. * Creater a new animation range
  84159. * @param name defines the name of the range
  84160. * @param from defines the start key
  84161. * @param to defines the end key
  84162. */
  84163. createAnimationRange(name: string, from: number, to: number): void;
  84164. /**
  84165. * Delete a specific animation range
  84166. * @param name defines the name of the range
  84167. * @param deleteFrames defines if frames must be removed as well
  84168. */
  84169. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84170. /**
  84171. * Gets a specific animation range
  84172. * @param name defines the name of the range to look for
  84173. * @returns the requested animation range or null if not found
  84174. */
  84175. getAnimationRange(name: string): Nullable<AnimationRange>;
  84176. /**
  84177. * Gets the list of all animation ranges defined on this skeleton
  84178. * @returns an array
  84179. */
  84180. getAnimationRanges(): Nullable<AnimationRange>[];
  84181. /**
  84182. * Copy animation range from a source skeleton.
  84183. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  84184. * @param source defines the source skeleton
  84185. * @param name defines the name of the range to copy
  84186. * @param rescaleAsRequired defines if rescaling must be applied if required
  84187. * @returns true if operation was successful
  84188. */
  84189. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  84190. /**
  84191. * Forces the skeleton to go to rest pose
  84192. */
  84193. returnToRest(): void;
  84194. private _getHighestAnimationFrame;
  84195. /**
  84196. * Begin a specific animation range
  84197. * @param name defines the name of the range to start
  84198. * @param loop defines if looping must be turned on (false by default)
  84199. * @param speedRatio defines the speed ratio to apply (1 by default)
  84200. * @param onAnimationEnd defines a callback which will be called when animation will end
  84201. * @returns a new animatable
  84202. */
  84203. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84204. /** @hidden */
  84205. _markAsDirty(): void;
  84206. /** @hidden */
  84207. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84208. /** @hidden */
  84209. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84210. private _computeTransformMatrices;
  84211. /**
  84212. * Build all resources required to render a skeleton
  84213. */
  84214. prepare(): void;
  84215. /**
  84216. * Gets the list of animatables currently running for this skeleton
  84217. * @returns an array of animatables
  84218. */
  84219. getAnimatables(): IAnimatable[];
  84220. /**
  84221. * Clone the current skeleton
  84222. * @param name defines the name of the new skeleton
  84223. * @param id defines the id of the new skeleton
  84224. * @returns the new skeleton
  84225. */
  84226. clone(name: string, id?: string): Skeleton;
  84227. /**
  84228. * Enable animation blending for this skeleton
  84229. * @param blendingSpeed defines the blending speed to apply
  84230. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84231. */
  84232. enableBlending(blendingSpeed?: number): void;
  84233. /**
  84234. * Releases all resources associated with the current skeleton
  84235. */
  84236. dispose(): void;
  84237. /**
  84238. * Serialize the skeleton in a JSON object
  84239. * @returns a JSON object
  84240. */
  84241. serialize(): any;
  84242. /**
  84243. * Creates a new skeleton from serialized data
  84244. * @param parsedSkeleton defines the serialized data
  84245. * @param scene defines the hosting scene
  84246. * @returns a new skeleton
  84247. */
  84248. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  84249. /**
  84250. * Compute all node absolute transforms
  84251. * @param forceUpdate defines if computation must be done even if cache is up to date
  84252. */
  84253. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  84254. /**
  84255. * Gets the root pose matrix
  84256. * @returns a matrix
  84257. */
  84258. getPoseMatrix(): Nullable<Matrix>;
  84259. /**
  84260. * Sorts bones per internal index
  84261. */
  84262. sortBones(): void;
  84263. private _sortBones;
  84264. }
  84265. }
  84266. declare module BABYLON {
  84267. /**
  84268. * Class used to store bone information
  84269. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84270. */
  84271. export class Bone extends Node {
  84272. /**
  84273. * defines the bone name
  84274. */
  84275. name: string;
  84276. private static _tmpVecs;
  84277. private static _tmpQuat;
  84278. private static _tmpMats;
  84279. /**
  84280. * Gets the list of child bones
  84281. */
  84282. children: Bone[];
  84283. /** Gets the animations associated with this bone */
  84284. animations: Animation[];
  84285. /**
  84286. * Gets or sets bone length
  84287. */
  84288. length: number;
  84289. /**
  84290. * @hidden Internal only
  84291. * Set this value to map this bone to a different index in the transform matrices
  84292. * Set this value to -1 to exclude the bone from the transform matrices
  84293. */
  84294. _index: Nullable<number>;
  84295. private _skeleton;
  84296. private _localMatrix;
  84297. private _restPose;
  84298. private _baseMatrix;
  84299. private _absoluteTransform;
  84300. private _invertedAbsoluteTransform;
  84301. private _parent;
  84302. private _scalingDeterminant;
  84303. private _worldTransform;
  84304. private _localScaling;
  84305. private _localRotation;
  84306. private _localPosition;
  84307. private _needToDecompose;
  84308. private _needToCompose;
  84309. /** @hidden */
  84310. _linkedTransformNode: Nullable<TransformNode>;
  84311. /** @hidden */
  84312. _waitingTransformNodeId: Nullable<string>;
  84313. /** @hidden */
  84314. get _matrix(): Matrix;
  84315. /** @hidden */
  84316. set _matrix(value: Matrix);
  84317. /**
  84318. * Create a new bone
  84319. * @param name defines the bone name
  84320. * @param skeleton defines the parent skeleton
  84321. * @param parentBone defines the parent (can be null if the bone is the root)
  84322. * @param localMatrix defines the local matrix
  84323. * @param restPose defines the rest pose matrix
  84324. * @param baseMatrix defines the base matrix
  84325. * @param index defines index of the bone in the hiearchy
  84326. */
  84327. constructor(
  84328. /**
  84329. * defines the bone name
  84330. */
  84331. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  84332. /**
  84333. * Gets the current object class name.
  84334. * @return the class name
  84335. */
  84336. getClassName(): string;
  84337. /**
  84338. * Gets the parent skeleton
  84339. * @returns a skeleton
  84340. */
  84341. getSkeleton(): Skeleton;
  84342. /**
  84343. * Gets parent bone
  84344. * @returns a bone or null if the bone is the root of the bone hierarchy
  84345. */
  84346. getParent(): Nullable<Bone>;
  84347. /**
  84348. * Returns an array containing the root bones
  84349. * @returns an array containing the root bones
  84350. */
  84351. getChildren(): Array<Bone>;
  84352. /**
  84353. * Gets the node index in matrix array generated for rendering
  84354. * @returns the node index
  84355. */
  84356. getIndex(): number;
  84357. /**
  84358. * Sets the parent bone
  84359. * @param parent defines the parent (can be null if the bone is the root)
  84360. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84361. */
  84362. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  84363. /**
  84364. * Gets the local matrix
  84365. * @returns a matrix
  84366. */
  84367. getLocalMatrix(): Matrix;
  84368. /**
  84369. * Gets the base matrix (initial matrix which remains unchanged)
  84370. * @returns a matrix
  84371. */
  84372. getBaseMatrix(): Matrix;
  84373. /**
  84374. * Gets the rest pose matrix
  84375. * @returns a matrix
  84376. */
  84377. getRestPose(): Matrix;
  84378. /**
  84379. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  84380. */
  84381. getWorldMatrix(): Matrix;
  84382. /**
  84383. * Sets the local matrix to rest pose matrix
  84384. */
  84385. returnToRest(): void;
  84386. /**
  84387. * Gets the inverse of the absolute transform matrix.
  84388. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  84389. * @returns a matrix
  84390. */
  84391. getInvertedAbsoluteTransform(): Matrix;
  84392. /**
  84393. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  84394. * @returns a matrix
  84395. */
  84396. getAbsoluteTransform(): Matrix;
  84397. /**
  84398. * Links with the given transform node.
  84399. * The local matrix of this bone is copied from the transform node every frame.
  84400. * @param transformNode defines the transform node to link to
  84401. */
  84402. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  84403. /**
  84404. * Gets the node used to drive the bone's transformation
  84405. * @returns a transform node or null
  84406. */
  84407. getTransformNode(): Nullable<TransformNode>;
  84408. /** Gets or sets current position (in local space) */
  84409. get position(): Vector3;
  84410. set position(newPosition: Vector3);
  84411. /** Gets or sets current rotation (in local space) */
  84412. get rotation(): Vector3;
  84413. set rotation(newRotation: Vector3);
  84414. /** Gets or sets current rotation quaternion (in local space) */
  84415. get rotationQuaternion(): Quaternion;
  84416. set rotationQuaternion(newRotation: Quaternion);
  84417. /** Gets or sets current scaling (in local space) */
  84418. get scaling(): Vector3;
  84419. set scaling(newScaling: Vector3);
  84420. /**
  84421. * Gets the animation properties override
  84422. */
  84423. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84424. private _decompose;
  84425. private _compose;
  84426. /**
  84427. * Update the base and local matrices
  84428. * @param matrix defines the new base or local matrix
  84429. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84430. * @param updateLocalMatrix defines if the local matrix should be updated
  84431. */
  84432. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  84433. /** @hidden */
  84434. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  84435. /**
  84436. * Flag the bone as dirty (Forcing it to update everything)
  84437. */
  84438. markAsDirty(): void;
  84439. /** @hidden */
  84440. _markAsDirtyAndCompose(): void;
  84441. private _markAsDirtyAndDecompose;
  84442. /**
  84443. * Translate the bone in local or world space
  84444. * @param vec The amount to translate the bone
  84445. * @param space The space that the translation is in
  84446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84447. */
  84448. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84449. /**
  84450. * Set the postion of the bone in local or world space
  84451. * @param position The position to set the bone
  84452. * @param space The space that the position is in
  84453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84454. */
  84455. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84456. /**
  84457. * Set the absolute position of the bone (world space)
  84458. * @param position The position to set the bone
  84459. * @param mesh The mesh that this bone is attached to
  84460. */
  84461. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  84462. /**
  84463. * Scale the bone on the x, y and z axes (in local space)
  84464. * @param x The amount to scale the bone on the x axis
  84465. * @param y The amount to scale the bone on the y axis
  84466. * @param z The amount to scale the bone on the z axis
  84467. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  84468. */
  84469. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  84470. /**
  84471. * Set the bone scaling in local space
  84472. * @param scale defines the scaling vector
  84473. */
  84474. setScale(scale: Vector3): void;
  84475. /**
  84476. * Gets the current scaling in local space
  84477. * @returns the current scaling vector
  84478. */
  84479. getScale(): Vector3;
  84480. /**
  84481. * Gets the current scaling in local space and stores it in a target vector
  84482. * @param result defines the target vector
  84483. */
  84484. getScaleToRef(result: Vector3): void;
  84485. /**
  84486. * Set the yaw, pitch, and roll of the bone in local or world space
  84487. * @param yaw The rotation of the bone on the y axis
  84488. * @param pitch The rotation of the bone on the x axis
  84489. * @param roll The rotation of the bone on the z axis
  84490. * @param space The space that the axes of rotation are in
  84491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84492. */
  84493. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  84494. /**
  84495. * Add a rotation to the bone on an axis in local or world space
  84496. * @param axis The axis to rotate the bone on
  84497. * @param amount The amount to rotate the bone
  84498. * @param space The space that the axis is in
  84499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84500. */
  84501. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  84502. /**
  84503. * Set the rotation of the bone to a particular axis angle in local or world space
  84504. * @param axis The axis to rotate the bone on
  84505. * @param angle The angle that the bone should be rotated to
  84506. * @param space The space that the axis is in
  84507. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84508. */
  84509. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  84510. /**
  84511. * Set the euler rotation of the bone in local of world space
  84512. * @param rotation The euler rotation that the bone should be set to
  84513. * @param space The space that the rotation is in
  84514. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84515. */
  84516. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84517. /**
  84518. * Set the quaternion rotation of the bone in local of world space
  84519. * @param quat The quaternion rotation that the bone should be set to
  84520. * @param space The space that the rotation is in
  84521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84522. */
  84523. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  84524. /**
  84525. * Set the rotation matrix of the bone in local of world space
  84526. * @param rotMat The rotation matrix that the bone should be set to
  84527. * @param space The space that the rotation is in
  84528. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84529. */
  84530. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  84531. private _rotateWithMatrix;
  84532. private _getNegativeRotationToRef;
  84533. /**
  84534. * Get the position of the bone in local or world space
  84535. * @param space The space that the returned position is in
  84536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84537. * @returns The position of the bone
  84538. */
  84539. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84540. /**
  84541. * Copy the position of the bone to a vector3 in local or world space
  84542. * @param space The space that the returned position is in
  84543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84544. * @param result The vector3 to copy the position to
  84545. */
  84546. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  84547. /**
  84548. * Get the absolute position of the bone (world space)
  84549. * @param mesh The mesh that this bone is attached to
  84550. * @returns The absolute position of the bone
  84551. */
  84552. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  84553. /**
  84554. * Copy the absolute position of the bone (world space) to the result param
  84555. * @param mesh The mesh that this bone is attached to
  84556. * @param result The vector3 to copy the absolute position to
  84557. */
  84558. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  84559. /**
  84560. * Compute the absolute transforms of this bone and its children
  84561. */
  84562. computeAbsoluteTransforms(): void;
  84563. /**
  84564. * Get the world direction from an axis that is in the local space of the bone
  84565. * @param localAxis The local direction that is used to compute the world direction
  84566. * @param mesh The mesh that this bone is attached to
  84567. * @returns The world direction
  84568. */
  84569. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84570. /**
  84571. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  84572. * @param localAxis The local direction that is used to compute the world direction
  84573. * @param mesh The mesh that this bone is attached to
  84574. * @param result The vector3 that the world direction will be copied to
  84575. */
  84576. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84577. /**
  84578. * Get the euler rotation of the bone in local or world space
  84579. * @param space The space that the rotation should be in
  84580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84581. * @returns The euler rotation
  84582. */
  84583. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84584. /**
  84585. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  84586. * @param space The space that the rotation should be in
  84587. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84588. * @param result The vector3 that the rotation should be copied to
  84589. */
  84590. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84591. /**
  84592. * Get the quaternion rotation of the bone in either local or world space
  84593. * @param space The space that the rotation should be in
  84594. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84595. * @returns The quaternion rotation
  84596. */
  84597. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  84598. /**
  84599. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  84600. * @param space The space that the rotation should be in
  84601. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84602. * @param result The quaternion that the rotation should be copied to
  84603. */
  84604. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  84605. /**
  84606. * Get the rotation matrix of the bone in local or world space
  84607. * @param space The space that the rotation should be in
  84608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84609. * @returns The rotation matrix
  84610. */
  84611. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  84612. /**
  84613. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  84614. * @param space The space that the rotation should be in
  84615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84616. * @param result The quaternion that the rotation should be copied to
  84617. */
  84618. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  84619. /**
  84620. * Get the world position of a point that is in the local space of the bone
  84621. * @param position The local position
  84622. * @param mesh The mesh that this bone is attached to
  84623. * @returns The world position
  84624. */
  84625. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84626. /**
  84627. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  84628. * @param position The local position
  84629. * @param mesh The mesh that this bone is attached to
  84630. * @param result The vector3 that the world position should be copied to
  84631. */
  84632. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84633. /**
  84634. * Get the local position of a point that is in world space
  84635. * @param position The world position
  84636. * @param mesh The mesh that this bone is attached to
  84637. * @returns The local position
  84638. */
  84639. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84640. /**
  84641. * Get the local position of a point that is in world space and copy it to the result param
  84642. * @param position The world position
  84643. * @param mesh The mesh that this bone is attached to
  84644. * @param result The vector3 that the local position should be copied to
  84645. */
  84646. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84647. }
  84648. }
  84649. declare module BABYLON {
  84650. /**
  84651. * 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.
  84652. * @see https://doc.babylonjs.com/how_to/transformnode
  84653. */
  84654. export class TransformNode extends Node {
  84655. /**
  84656. * Object will not rotate to face the camera
  84657. */
  84658. static BILLBOARDMODE_NONE: number;
  84659. /**
  84660. * Object will rotate to face the camera but only on the x axis
  84661. */
  84662. static BILLBOARDMODE_X: number;
  84663. /**
  84664. * Object will rotate to face the camera but only on the y axis
  84665. */
  84666. static BILLBOARDMODE_Y: number;
  84667. /**
  84668. * Object will rotate to face the camera but only on the z axis
  84669. */
  84670. static BILLBOARDMODE_Z: number;
  84671. /**
  84672. * Object will rotate to face the camera
  84673. */
  84674. static BILLBOARDMODE_ALL: number;
  84675. /**
  84676. * Object will rotate to face the camera's position instead of orientation
  84677. */
  84678. static BILLBOARDMODE_USE_POSITION: number;
  84679. private _forward;
  84680. private _forwardInverted;
  84681. private _up;
  84682. private _right;
  84683. private _rightInverted;
  84684. private _position;
  84685. private _rotation;
  84686. private _rotationQuaternion;
  84687. protected _scaling: Vector3;
  84688. protected _isDirty: boolean;
  84689. private _transformToBoneReferal;
  84690. private _isAbsoluteSynced;
  84691. private _billboardMode;
  84692. /**
  84693. * Gets or sets the billboard mode. Default is 0.
  84694. *
  84695. * | Value | Type | Description |
  84696. * | --- | --- | --- |
  84697. * | 0 | BILLBOARDMODE_NONE | |
  84698. * | 1 | BILLBOARDMODE_X | |
  84699. * | 2 | BILLBOARDMODE_Y | |
  84700. * | 4 | BILLBOARDMODE_Z | |
  84701. * | 7 | BILLBOARDMODE_ALL | |
  84702. *
  84703. */
  84704. get billboardMode(): number;
  84705. set billboardMode(value: number);
  84706. private _preserveParentRotationForBillboard;
  84707. /**
  84708. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  84709. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  84710. */
  84711. get preserveParentRotationForBillboard(): boolean;
  84712. set preserveParentRotationForBillboard(value: boolean);
  84713. /**
  84714. * 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
  84715. */
  84716. scalingDeterminant: number;
  84717. private _infiniteDistance;
  84718. /**
  84719. * Gets or sets the distance of the object to max, often used by skybox
  84720. */
  84721. get infiniteDistance(): boolean;
  84722. set infiniteDistance(value: boolean);
  84723. /**
  84724. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  84725. * By default the system will update normals to compensate
  84726. */
  84727. ignoreNonUniformScaling: boolean;
  84728. /**
  84729. * 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
  84730. */
  84731. reIntegrateRotationIntoRotationQuaternion: boolean;
  84732. /** @hidden */
  84733. _poseMatrix: Nullable<Matrix>;
  84734. /** @hidden */
  84735. _localMatrix: Matrix;
  84736. private _usePivotMatrix;
  84737. private _absolutePosition;
  84738. private _absoluteScaling;
  84739. private _absoluteRotationQuaternion;
  84740. private _pivotMatrix;
  84741. private _pivotMatrixInverse;
  84742. protected _postMultiplyPivotMatrix: boolean;
  84743. protected _isWorldMatrixFrozen: boolean;
  84744. /** @hidden */
  84745. _indexInSceneTransformNodesArray: number;
  84746. /**
  84747. * An event triggered after the world matrix is updated
  84748. */
  84749. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  84750. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  84751. /**
  84752. * Gets a string identifying the name of the class
  84753. * @returns "TransformNode" string
  84754. */
  84755. getClassName(): string;
  84756. /**
  84757. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  84758. */
  84759. get position(): Vector3;
  84760. set position(newPosition: Vector3);
  84761. /**
  84762. * 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)).
  84763. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  84764. */
  84765. get rotation(): Vector3;
  84766. set rotation(newRotation: Vector3);
  84767. /**
  84768. * 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)).
  84769. */
  84770. get scaling(): Vector3;
  84771. set scaling(newScaling: Vector3);
  84772. /**
  84773. * 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).
  84774. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  84775. */
  84776. get rotationQuaternion(): Nullable<Quaternion>;
  84777. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  84778. /**
  84779. * The forward direction of that transform in world space.
  84780. */
  84781. get forward(): Vector3;
  84782. /**
  84783. * The up direction of that transform in world space.
  84784. */
  84785. get up(): Vector3;
  84786. /**
  84787. * The right direction of that transform in world space.
  84788. */
  84789. get right(): Vector3;
  84790. /**
  84791. * Copies the parameter passed Matrix into the mesh Pose matrix.
  84792. * @param matrix the matrix to copy the pose from
  84793. * @returns this TransformNode.
  84794. */
  84795. updatePoseMatrix(matrix: Matrix): TransformNode;
  84796. /**
  84797. * Returns the mesh Pose matrix.
  84798. * @returns the pose matrix
  84799. */
  84800. getPoseMatrix(): Matrix;
  84801. /** @hidden */
  84802. _isSynchronized(): boolean;
  84803. /** @hidden */
  84804. _initCache(): void;
  84805. /**
  84806. * Flag the transform node as dirty (Forcing it to update everything)
  84807. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  84808. * @returns this transform node
  84809. */
  84810. markAsDirty(property: string): TransformNode;
  84811. /**
  84812. * Returns the current mesh absolute position.
  84813. * Returns a Vector3.
  84814. */
  84815. get absolutePosition(): Vector3;
  84816. /**
  84817. * Returns the current mesh absolute scaling.
  84818. * Returns a Vector3.
  84819. */
  84820. get absoluteScaling(): Vector3;
  84821. /**
  84822. * Returns the current mesh absolute rotation.
  84823. * Returns a Quaternion.
  84824. */
  84825. get absoluteRotationQuaternion(): Quaternion;
  84826. /**
  84827. * Sets a new matrix to apply before all other transformation
  84828. * @param matrix defines the transform matrix
  84829. * @returns the current TransformNode
  84830. */
  84831. setPreTransformMatrix(matrix: Matrix): TransformNode;
  84832. /**
  84833. * Sets a new pivot matrix to the current node
  84834. * @param matrix defines the new pivot matrix to use
  84835. * @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
  84836. * @returns the current TransformNode
  84837. */
  84838. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  84839. /**
  84840. * Returns the mesh pivot matrix.
  84841. * Default : Identity.
  84842. * @returns the matrix
  84843. */
  84844. getPivotMatrix(): Matrix;
  84845. /**
  84846. * Instantiate (when possible) or clone that node with its hierarchy
  84847. * @param newParent defines the new parent to use for the instance (or clone)
  84848. * @param options defines options to configure how copy is done
  84849. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  84850. * @returns an instance (or a clone) of the current node with its hiearchy
  84851. */
  84852. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  84853. doNotInstantiate: boolean;
  84854. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  84855. /**
  84856. * Prevents the World matrix to be computed any longer
  84857. * @param newWorldMatrix defines an optional matrix to use as world matrix
  84858. * @returns the TransformNode.
  84859. */
  84860. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  84861. /**
  84862. * Allows back the World matrix computation.
  84863. * @returns the TransformNode.
  84864. */
  84865. unfreezeWorldMatrix(): this;
  84866. /**
  84867. * True if the World matrix has been frozen.
  84868. */
  84869. get isWorldMatrixFrozen(): boolean;
  84870. /**
  84871. * Retuns the mesh absolute position in the World.
  84872. * @returns a Vector3.
  84873. */
  84874. getAbsolutePosition(): Vector3;
  84875. /**
  84876. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  84877. * @param absolutePosition the absolute position to set
  84878. * @returns the TransformNode.
  84879. */
  84880. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  84881. /**
  84882. * Sets the mesh position in its local space.
  84883. * @param vector3 the position to set in localspace
  84884. * @returns the TransformNode.
  84885. */
  84886. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  84887. /**
  84888. * Returns the mesh position in the local space from the current World matrix values.
  84889. * @returns a new Vector3.
  84890. */
  84891. getPositionExpressedInLocalSpace(): Vector3;
  84892. /**
  84893. * Translates the mesh along the passed Vector3 in its local space.
  84894. * @param vector3 the distance to translate in localspace
  84895. * @returns the TransformNode.
  84896. */
  84897. locallyTranslate(vector3: Vector3): TransformNode;
  84898. private static _lookAtVectorCache;
  84899. /**
  84900. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  84901. * @param targetPoint the position (must be in same space as current mesh) to look at
  84902. * @param yawCor optional yaw (y-axis) correction in radians
  84903. * @param pitchCor optional pitch (x-axis) correction in radians
  84904. * @param rollCor optional roll (z-axis) correction in radians
  84905. * @param space the choosen space of the target
  84906. * @returns the TransformNode.
  84907. */
  84908. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  84909. /**
  84910. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84911. * This Vector3 is expressed in the World space.
  84912. * @param localAxis axis to rotate
  84913. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84914. */
  84915. getDirection(localAxis: Vector3): Vector3;
  84916. /**
  84917. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  84918. * localAxis is expressed in the mesh local space.
  84919. * result is computed in the Wordl space from the mesh World matrix.
  84920. * @param localAxis axis to rotate
  84921. * @param result the resulting transformnode
  84922. * @returns this TransformNode.
  84923. */
  84924. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  84925. /**
  84926. * Sets this transform node rotation to the given local axis.
  84927. * @param localAxis the axis in local space
  84928. * @param yawCor optional yaw (y-axis) correction in radians
  84929. * @param pitchCor optional pitch (x-axis) correction in radians
  84930. * @param rollCor optional roll (z-axis) correction in radians
  84931. * @returns this TransformNode
  84932. */
  84933. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  84934. /**
  84935. * Sets a new pivot point to the current node
  84936. * @param point defines the new pivot point to use
  84937. * @param space defines if the point is in world or local space (local by default)
  84938. * @returns the current TransformNode
  84939. */
  84940. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  84941. /**
  84942. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  84943. * @returns the pivot point
  84944. */
  84945. getPivotPoint(): Vector3;
  84946. /**
  84947. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  84948. * @param result the vector3 to store the result
  84949. * @returns this TransformNode.
  84950. */
  84951. getPivotPointToRef(result: Vector3): TransformNode;
  84952. /**
  84953. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  84954. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  84955. */
  84956. getAbsolutePivotPoint(): Vector3;
  84957. /**
  84958. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  84959. * @param result vector3 to store the result
  84960. * @returns this TransformNode.
  84961. */
  84962. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  84963. /**
  84964. * Defines the passed node as the parent of the current node.
  84965. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  84966. * @see https://doc.babylonjs.com/how_to/parenting
  84967. * @param node the node ot set as the parent
  84968. * @returns this TransformNode.
  84969. */
  84970. setParent(node: Nullable<Node>): TransformNode;
  84971. private _nonUniformScaling;
  84972. /**
  84973. * True if the scaling property of this object is non uniform eg. (1,2,1)
  84974. */
  84975. get nonUniformScaling(): boolean;
  84976. /** @hidden */
  84977. _updateNonUniformScalingState(value: boolean): boolean;
  84978. /**
  84979. * Attach the current TransformNode to another TransformNode associated with a bone
  84980. * @param bone Bone affecting the TransformNode
  84981. * @param affectedTransformNode TransformNode associated with the bone
  84982. * @returns this object
  84983. */
  84984. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  84985. /**
  84986. * Detach the transform node if its associated with a bone
  84987. * @returns this object
  84988. */
  84989. detachFromBone(): TransformNode;
  84990. private static _rotationAxisCache;
  84991. /**
  84992. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  84993. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  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. * @param axis the axis to rotate around
  84997. * @param amount the amount to rotate in radians
  84998. * @param space Space to rotate in (Default: local)
  84999. * @returns the TransformNode.
  85000. */
  85001. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  85002. /**
  85003. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  85004. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85005. * The passed axis is also normalized. .
  85006. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  85007. * @param point the point to rotate around
  85008. * @param axis the axis to rotate around
  85009. * @param amount the amount to rotate in radians
  85010. * @returns the TransformNode
  85011. */
  85012. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  85013. /**
  85014. * Translates the mesh along the axis vector for the passed distance in the given space.
  85015. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85016. * @param axis the axis to translate in
  85017. * @param distance the distance to translate
  85018. * @param space Space to rotate in (Default: local)
  85019. * @returns the TransformNode.
  85020. */
  85021. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85022. /**
  85023. * Adds a rotation step to the mesh current rotation.
  85024. * x, y, z are Euler angles expressed in radians.
  85025. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85026. * This means this rotation is made in the mesh local space only.
  85027. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85028. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85029. * ```javascript
  85030. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85031. * ```
  85032. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85033. * 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.
  85034. * @param x Rotation to add
  85035. * @param y Rotation to add
  85036. * @param z Rotation to add
  85037. * @returns the TransformNode.
  85038. */
  85039. addRotation(x: number, y: number, z: number): TransformNode;
  85040. /**
  85041. * @hidden
  85042. */
  85043. protected _getEffectiveParent(): Nullable<Node>;
  85044. /**
  85045. * Computes the world matrix of the node
  85046. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85047. * @returns the world matrix
  85048. */
  85049. computeWorldMatrix(force?: boolean): Matrix;
  85050. protected _afterComputeWorldMatrix(): void;
  85051. /**
  85052. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85053. * @param func callback function to add
  85054. *
  85055. * @returns the TransformNode.
  85056. */
  85057. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85058. /**
  85059. * Removes a registered callback function.
  85060. * @param func callback function to remove
  85061. * @returns the TransformNode.
  85062. */
  85063. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85064. /**
  85065. * Gets the position of the current mesh in camera space
  85066. * @param camera defines the camera to use
  85067. * @returns a position
  85068. */
  85069. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85070. /**
  85071. * Returns the distance from the mesh to the active camera
  85072. * @param camera defines the camera to use
  85073. * @returns the distance
  85074. */
  85075. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85076. /**
  85077. * Clone the current transform node
  85078. * @param name Name of the new clone
  85079. * @param newParent New parent for the clone
  85080. * @param doNotCloneChildren Do not clone children hierarchy
  85081. * @returns the new transform node
  85082. */
  85083. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85084. /**
  85085. * Serializes the objects information.
  85086. * @param currentSerializationObject defines the object to serialize in
  85087. * @returns the serialized object
  85088. */
  85089. serialize(currentSerializationObject?: any): any;
  85090. /**
  85091. * Returns a new TransformNode object parsed from the source provided.
  85092. * @param parsedTransformNode is the source.
  85093. * @param scene the scne the object belongs to
  85094. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85095. * @returns a new TransformNode object parsed from the source provided.
  85096. */
  85097. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85098. /**
  85099. * Get all child-transformNodes of this node
  85100. * @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
  85101. * @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
  85102. * @returns an array of TransformNode
  85103. */
  85104. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85105. /**
  85106. * Releases resources associated with this transform node.
  85107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85109. */
  85110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85111. /**
  85112. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85113. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85114. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85115. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85116. * @returns the current mesh
  85117. */
  85118. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85119. private _syncAbsoluteScalingAndRotation;
  85120. }
  85121. }
  85122. declare module BABYLON {
  85123. /**
  85124. * Defines the types of pose enabled controllers that are supported
  85125. */
  85126. export enum PoseEnabledControllerType {
  85127. /**
  85128. * HTC Vive
  85129. */
  85130. VIVE = 0,
  85131. /**
  85132. * Oculus Rift
  85133. */
  85134. OCULUS = 1,
  85135. /**
  85136. * Windows mixed reality
  85137. */
  85138. WINDOWS = 2,
  85139. /**
  85140. * Samsung gear VR
  85141. */
  85142. GEAR_VR = 3,
  85143. /**
  85144. * Google Daydream
  85145. */
  85146. DAYDREAM = 4,
  85147. /**
  85148. * Generic
  85149. */
  85150. GENERIC = 5
  85151. }
  85152. /**
  85153. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85154. */
  85155. export interface MutableGamepadButton {
  85156. /**
  85157. * Value of the button/trigger
  85158. */
  85159. value: number;
  85160. /**
  85161. * If the button/trigger is currently touched
  85162. */
  85163. touched: boolean;
  85164. /**
  85165. * If the button/trigger is currently pressed
  85166. */
  85167. pressed: boolean;
  85168. }
  85169. /**
  85170. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85171. * @hidden
  85172. */
  85173. export interface ExtendedGamepadButton extends GamepadButton {
  85174. /**
  85175. * If the button/trigger is currently pressed
  85176. */
  85177. readonly pressed: boolean;
  85178. /**
  85179. * If the button/trigger is currently touched
  85180. */
  85181. readonly touched: boolean;
  85182. /**
  85183. * Value of the button/trigger
  85184. */
  85185. readonly value: number;
  85186. }
  85187. /** @hidden */
  85188. export interface _GamePadFactory {
  85189. /**
  85190. * Returns wether or not the current gamepad can be created for this type of controller.
  85191. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85192. * @returns true if it can be created, otherwise false
  85193. */
  85194. canCreate(gamepadInfo: any): boolean;
  85195. /**
  85196. * Creates a new instance of the Gamepad.
  85197. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85198. * @returns the new gamepad instance
  85199. */
  85200. create(gamepadInfo: any): Gamepad;
  85201. }
  85202. /**
  85203. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85204. */
  85205. export class PoseEnabledControllerHelper {
  85206. /** @hidden */
  85207. static _ControllerFactories: _GamePadFactory[];
  85208. /** @hidden */
  85209. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  85210. /**
  85211. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85212. * @param vrGamepad the gamepad to initialized
  85213. * @returns a vr controller of the type the gamepad identified as
  85214. */
  85215. static InitiateController(vrGamepad: any): Gamepad;
  85216. }
  85217. /**
  85218. * Defines the PoseEnabledController object that contains state of a vr capable controller
  85219. */
  85220. export class PoseEnabledController extends Gamepad implements PoseControlled {
  85221. /**
  85222. * If the controller is used in a webXR session
  85223. */
  85224. isXR: boolean;
  85225. private _deviceRoomPosition;
  85226. private _deviceRoomRotationQuaternion;
  85227. /**
  85228. * The device position in babylon space
  85229. */
  85230. devicePosition: Vector3;
  85231. /**
  85232. * The device rotation in babylon space
  85233. */
  85234. deviceRotationQuaternion: Quaternion;
  85235. /**
  85236. * The scale factor of the device in babylon space
  85237. */
  85238. deviceScaleFactor: number;
  85239. /**
  85240. * (Likely devicePosition should be used instead) The device position in its room space
  85241. */
  85242. position: Vector3;
  85243. /**
  85244. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  85245. */
  85246. rotationQuaternion: Quaternion;
  85247. /**
  85248. * The type of controller (Eg. Windows mixed reality)
  85249. */
  85250. controllerType: PoseEnabledControllerType;
  85251. protected _calculatedPosition: Vector3;
  85252. private _calculatedRotation;
  85253. /**
  85254. * The raw pose from the device
  85255. */
  85256. rawPose: DevicePose;
  85257. private _trackPosition;
  85258. private _maxRotationDistFromHeadset;
  85259. private _draggedRoomRotation;
  85260. /**
  85261. * @hidden
  85262. */
  85263. _disableTrackPosition(fixedPosition: Vector3): void;
  85264. /**
  85265. * Internal, the mesh attached to the controller
  85266. * @hidden
  85267. */
  85268. _mesh: Nullable<AbstractMesh>;
  85269. private _poseControlledCamera;
  85270. private _leftHandSystemQuaternion;
  85271. /**
  85272. * Internal, matrix used to convert room space to babylon space
  85273. * @hidden
  85274. */
  85275. _deviceToWorld: Matrix;
  85276. /**
  85277. * Node to be used when casting a ray from the controller
  85278. * @hidden
  85279. */
  85280. _pointingPoseNode: Nullable<TransformNode>;
  85281. /**
  85282. * Name of the child mesh that can be used to cast a ray from the controller
  85283. */
  85284. static readonly POINTING_POSE: string;
  85285. /**
  85286. * Creates a new PoseEnabledController from a gamepad
  85287. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  85288. */
  85289. constructor(browserGamepad: any);
  85290. private _workingMatrix;
  85291. /**
  85292. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  85293. */
  85294. update(): void;
  85295. /**
  85296. * Updates only the pose device and mesh without doing any button event checking
  85297. */
  85298. protected _updatePoseAndMesh(): void;
  85299. /**
  85300. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  85301. * @param poseData raw pose fromthe device
  85302. */
  85303. updateFromDevice(poseData: DevicePose): void;
  85304. /**
  85305. * @hidden
  85306. */
  85307. _meshAttachedObservable: Observable<AbstractMesh>;
  85308. /**
  85309. * Attaches a mesh to the controller
  85310. * @param mesh the mesh to be attached
  85311. */
  85312. attachToMesh(mesh: AbstractMesh): void;
  85313. /**
  85314. * Attaches the controllers mesh to a camera
  85315. * @param camera the camera the mesh should be attached to
  85316. */
  85317. attachToPoseControlledCamera(camera: TargetCamera): void;
  85318. /**
  85319. * Disposes of the controller
  85320. */
  85321. dispose(): void;
  85322. /**
  85323. * The mesh that is attached to the controller
  85324. */
  85325. get mesh(): Nullable<AbstractMesh>;
  85326. /**
  85327. * Gets the ray of the controller in the direction the controller is pointing
  85328. * @param length the length the resulting ray should be
  85329. * @returns a ray in the direction the controller is pointing
  85330. */
  85331. getForwardRay(length?: number): Ray;
  85332. }
  85333. }
  85334. declare module BABYLON {
  85335. /**
  85336. * Defines the WebVRController object that represents controllers tracked in 3D space
  85337. */
  85338. export abstract class WebVRController extends PoseEnabledController {
  85339. /**
  85340. * Internal, the default controller model for the controller
  85341. */
  85342. protected _defaultModel: Nullable<AbstractMesh>;
  85343. /**
  85344. * Fired when the trigger state has changed
  85345. */
  85346. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  85347. /**
  85348. * Fired when the main button state has changed
  85349. */
  85350. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85351. /**
  85352. * Fired when the secondary button state has changed
  85353. */
  85354. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85355. /**
  85356. * Fired when the pad state has changed
  85357. */
  85358. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  85359. /**
  85360. * Fired when controllers stick values have changed
  85361. */
  85362. onPadValuesChangedObservable: Observable<StickValues>;
  85363. /**
  85364. * Array of button availible on the controller
  85365. */
  85366. protected _buttons: Array<MutableGamepadButton>;
  85367. private _onButtonStateChange;
  85368. /**
  85369. * Fired when a controller button's state has changed
  85370. * @param callback the callback containing the button that was modified
  85371. */
  85372. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  85373. /**
  85374. * X and Y axis corresponding to the controllers joystick
  85375. */
  85376. pad: StickValues;
  85377. /**
  85378. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  85379. */
  85380. hand: string;
  85381. /**
  85382. * The default controller model for the controller
  85383. */
  85384. get defaultModel(): Nullable<AbstractMesh>;
  85385. /**
  85386. * Creates a new WebVRController from a gamepad
  85387. * @param vrGamepad the gamepad that the WebVRController should be created from
  85388. */
  85389. constructor(vrGamepad: any);
  85390. /**
  85391. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  85392. */
  85393. update(): void;
  85394. /**
  85395. * Function to be called when a button is modified
  85396. */
  85397. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  85398. /**
  85399. * Loads a mesh and attaches it to the controller
  85400. * @param scene the scene the mesh should be added to
  85401. * @param meshLoaded callback for when the mesh has been loaded
  85402. */
  85403. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  85404. private _setButtonValue;
  85405. private _changes;
  85406. private _checkChanges;
  85407. /**
  85408. * Disposes of th webVRCOntroller
  85409. */
  85410. dispose(): void;
  85411. }
  85412. }
  85413. declare module BABYLON {
  85414. /**
  85415. * The HemisphericLight simulates the ambient environment light,
  85416. * so the passed direction is the light reflection direction, not the incoming direction.
  85417. */
  85418. export class HemisphericLight extends Light {
  85419. /**
  85420. * The groundColor is the light in the opposite direction to the one specified during creation.
  85421. * 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.
  85422. */
  85423. groundColor: Color3;
  85424. /**
  85425. * The light reflection direction, not the incoming direction.
  85426. */
  85427. direction: Vector3;
  85428. /**
  85429. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  85430. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  85431. * The HemisphericLight can't cast shadows.
  85432. * Documentation : https://doc.babylonjs.com/babylon101/lights
  85433. * @param name The friendly name of the light
  85434. * @param direction The direction of the light reflection
  85435. * @param scene The scene the light belongs to
  85436. */
  85437. constructor(name: string, direction: Vector3, scene: Scene);
  85438. protected _buildUniformLayout(): void;
  85439. /**
  85440. * Returns the string "HemisphericLight".
  85441. * @return The class name
  85442. */
  85443. getClassName(): string;
  85444. /**
  85445. * Sets the HemisphericLight direction towards the passed target (Vector3).
  85446. * Returns the updated direction.
  85447. * @param target The target the direction should point to
  85448. * @return The computed direction
  85449. */
  85450. setDirectionToTarget(target: Vector3): Vector3;
  85451. /**
  85452. * Returns the shadow generator associated to the light.
  85453. * @returns Always null for hemispheric lights because it does not support shadows.
  85454. */
  85455. getShadowGenerator(): Nullable<IShadowGenerator>;
  85456. /**
  85457. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  85458. * @param effect The effect to update
  85459. * @param lightIndex The index of the light in the effect to update
  85460. * @returns The hemispheric light
  85461. */
  85462. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  85463. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  85464. /**
  85465. * Computes the world matrix of the node
  85466. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85467. * @param useWasUpdatedFlag defines a reserved property
  85468. * @returns the world matrix
  85469. */
  85470. computeWorldMatrix(): Matrix;
  85471. /**
  85472. * Returns the integer 3.
  85473. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  85474. */
  85475. getTypeID(): number;
  85476. /**
  85477. * Prepares the list of defines specific to the light type.
  85478. * @param defines the list of defines
  85479. * @param lightIndex defines the index of the light for the effect
  85480. */
  85481. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  85482. }
  85483. }
  85484. declare module BABYLON {
  85485. /** @hidden */
  85486. export var vrMultiviewToSingleviewPixelShader: {
  85487. name: string;
  85488. shader: string;
  85489. };
  85490. }
  85491. declare module BABYLON {
  85492. /**
  85493. * Renders to multiple views with a single draw call
  85494. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  85495. */
  85496. export class MultiviewRenderTarget extends RenderTargetTexture {
  85497. /**
  85498. * Creates a multiview render target
  85499. * @param scene scene used with the render target
  85500. * @param size the size of the render target (used for each view)
  85501. */
  85502. constructor(scene: Scene, size?: number | {
  85503. width: number;
  85504. height: number;
  85505. } | {
  85506. ratio: number;
  85507. });
  85508. /**
  85509. * @hidden
  85510. * @param faceIndex the face index, if its a cube texture
  85511. */
  85512. _bindFrameBuffer(faceIndex?: number): void;
  85513. /**
  85514. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85515. * @returns the view count
  85516. */
  85517. getViewCount(): number;
  85518. }
  85519. }
  85520. declare module BABYLON {
  85521. /**
  85522. * Represents a camera frustum
  85523. */
  85524. export class Frustum {
  85525. /**
  85526. * Gets the planes representing the frustum
  85527. * @param transform matrix to be applied to the returned planes
  85528. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85529. */
  85530. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85531. /**
  85532. * Gets the near frustum plane transformed by the transform matrix
  85533. * @param transform transformation matrix to be applied to the resulting frustum plane
  85534. * @param frustumPlane the resuling frustum plane
  85535. */
  85536. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85537. /**
  85538. * Gets the far frustum plane transformed by the transform matrix
  85539. * @param transform transformation matrix to be applied to the resulting frustum plane
  85540. * @param frustumPlane the resuling frustum plane
  85541. */
  85542. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85543. /**
  85544. * Gets the left frustum plane transformed by the transform matrix
  85545. * @param transform transformation matrix to be applied to the resulting frustum plane
  85546. * @param frustumPlane the resuling frustum plane
  85547. */
  85548. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85549. /**
  85550. * Gets the right frustum plane transformed by the transform matrix
  85551. * @param transform transformation matrix to be applied to the resulting frustum plane
  85552. * @param frustumPlane the resuling frustum plane
  85553. */
  85554. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85555. /**
  85556. * Gets the top frustum plane transformed by the transform matrix
  85557. * @param transform transformation matrix to be applied to the resulting frustum plane
  85558. * @param frustumPlane the resuling frustum plane
  85559. */
  85560. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85561. /**
  85562. * Gets the bottom frustum plane transformed by the transform matrix
  85563. * @param transform transformation matrix to be applied to the resulting frustum plane
  85564. * @param frustumPlane the resuling frustum plane
  85565. */
  85566. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85567. /**
  85568. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85569. * @param transform transformation matrix to be applied to the resulting frustum planes
  85570. * @param frustumPlanes the resuling frustum planes
  85571. */
  85572. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85573. }
  85574. }
  85575. declare module BABYLON {
  85576. interface Engine {
  85577. /**
  85578. * Creates a new multiview render target
  85579. * @param width defines the width of the texture
  85580. * @param height defines the height of the texture
  85581. * @returns the created multiview texture
  85582. */
  85583. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  85584. /**
  85585. * Binds a multiview framebuffer to be drawn to
  85586. * @param multiviewTexture texture to bind
  85587. */
  85588. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  85589. }
  85590. interface Camera {
  85591. /**
  85592. * @hidden
  85593. * 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)
  85594. */
  85595. _useMultiviewToSingleView: boolean;
  85596. /**
  85597. * @hidden
  85598. * 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)
  85599. */
  85600. _multiviewTexture: Nullable<RenderTargetTexture>;
  85601. /**
  85602. * @hidden
  85603. * ensures the multiview texture of the camera exists and has the specified width/height
  85604. * @param width height to set on the multiview texture
  85605. * @param height width to set on the multiview texture
  85606. */
  85607. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  85608. }
  85609. interface Scene {
  85610. /** @hidden */
  85611. _transformMatrixR: Matrix;
  85612. /** @hidden */
  85613. _multiviewSceneUbo: Nullable<UniformBuffer>;
  85614. /** @hidden */
  85615. _createMultiviewUbo(): void;
  85616. /** @hidden */
  85617. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  85618. /** @hidden */
  85619. _renderMultiviewToSingleView(camera: Camera): void;
  85620. }
  85621. }
  85622. declare module BABYLON {
  85623. /**
  85624. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  85625. * This will not be used for webXR as it supports displaying texture arrays directly
  85626. */
  85627. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  85628. /**
  85629. * Initializes a VRMultiviewToSingleview
  85630. * @param name name of the post process
  85631. * @param camera camera to be applied to
  85632. * @param scaleFactor scaling factor to the size of the output texture
  85633. */
  85634. constructor(name: string, camera: Camera, scaleFactor: number);
  85635. }
  85636. }
  85637. declare module BABYLON {
  85638. /**
  85639. * Interface used to define additional presentation attributes
  85640. */
  85641. export interface IVRPresentationAttributes {
  85642. /**
  85643. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  85644. */
  85645. highRefreshRate: boolean;
  85646. /**
  85647. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  85648. */
  85649. foveationLevel: number;
  85650. }
  85651. interface Engine {
  85652. /** @hidden */
  85653. _vrDisplay: any;
  85654. /** @hidden */
  85655. _vrSupported: boolean;
  85656. /** @hidden */
  85657. _oldSize: Size;
  85658. /** @hidden */
  85659. _oldHardwareScaleFactor: number;
  85660. /** @hidden */
  85661. _vrExclusivePointerMode: boolean;
  85662. /** @hidden */
  85663. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  85664. /** @hidden */
  85665. _onVRDisplayPointerRestricted: () => void;
  85666. /** @hidden */
  85667. _onVRDisplayPointerUnrestricted: () => void;
  85668. /** @hidden */
  85669. _onVrDisplayConnect: Nullable<(display: any) => void>;
  85670. /** @hidden */
  85671. _onVrDisplayDisconnect: Nullable<() => void>;
  85672. /** @hidden */
  85673. _onVrDisplayPresentChange: Nullable<() => void>;
  85674. /**
  85675. * Observable signaled when VR display mode changes
  85676. */
  85677. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85678. /**
  85679. * Observable signaled when VR request present is complete
  85680. */
  85681. onVRRequestPresentComplete: Observable<boolean>;
  85682. /**
  85683. * Observable signaled when VR request present starts
  85684. */
  85685. onVRRequestPresentStart: Observable<Engine>;
  85686. /**
  85687. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85688. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85689. */
  85690. isInVRExclusivePointerMode: boolean;
  85691. /**
  85692. * Gets a boolean indicating if a webVR device was detected
  85693. * @returns true if a webVR device was detected
  85694. */
  85695. isVRDevicePresent(): boolean;
  85696. /**
  85697. * Gets the current webVR device
  85698. * @returns the current webVR device (or null)
  85699. */
  85700. getVRDevice(): any;
  85701. /**
  85702. * Initializes a webVR display and starts listening to display change events
  85703. * The onVRDisplayChangedObservable will be notified upon these changes
  85704. * @returns A promise containing a VRDisplay and if vr is supported
  85705. */
  85706. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85707. /** @hidden */
  85708. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  85709. /**
  85710. * Gets or sets the presentation attributes used to configure VR rendering
  85711. */
  85712. vrPresentationAttributes?: IVRPresentationAttributes;
  85713. /**
  85714. * Call this function to switch to webVR mode
  85715. * Will do nothing if webVR is not supported or if there is no webVR device
  85716. * @param options the webvr options provided to the camera. mainly used for multiview
  85717. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85718. */
  85719. enableVR(options: WebVROptions): void;
  85720. /** @hidden */
  85721. _onVRFullScreenTriggered(): void;
  85722. }
  85723. }
  85724. declare module BABYLON {
  85725. /**
  85726. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  85727. * IMPORTANT!! The data is right-hand data.
  85728. * @export
  85729. * @interface DevicePose
  85730. */
  85731. export interface DevicePose {
  85732. /**
  85733. * The position of the device, values in array are [x,y,z].
  85734. */
  85735. readonly position: Nullable<Float32Array>;
  85736. /**
  85737. * The linearVelocity of the device, values in array are [x,y,z].
  85738. */
  85739. readonly linearVelocity: Nullable<Float32Array>;
  85740. /**
  85741. * The linearAcceleration of the device, values in array are [x,y,z].
  85742. */
  85743. readonly linearAcceleration: Nullable<Float32Array>;
  85744. /**
  85745. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  85746. */
  85747. readonly orientation: Nullable<Float32Array>;
  85748. /**
  85749. * The angularVelocity of the device, values in array are [x,y,z].
  85750. */
  85751. readonly angularVelocity: Nullable<Float32Array>;
  85752. /**
  85753. * The angularAcceleration of the device, values in array are [x,y,z].
  85754. */
  85755. readonly angularAcceleration: Nullable<Float32Array>;
  85756. }
  85757. /**
  85758. * Interface representing a pose controlled object in Babylon.
  85759. * A pose controlled object has both regular pose values as well as pose values
  85760. * from an external device such as a VR head mounted display
  85761. */
  85762. export interface PoseControlled {
  85763. /**
  85764. * The position of the object in babylon space.
  85765. */
  85766. position: Vector3;
  85767. /**
  85768. * The rotation quaternion of the object in babylon space.
  85769. */
  85770. rotationQuaternion: Quaternion;
  85771. /**
  85772. * The position of the device in babylon space.
  85773. */
  85774. devicePosition?: Vector3;
  85775. /**
  85776. * The rotation quaternion of the device in babylon space.
  85777. */
  85778. deviceRotationQuaternion: Quaternion;
  85779. /**
  85780. * The raw pose coming from the device.
  85781. */
  85782. rawPose: Nullable<DevicePose>;
  85783. /**
  85784. * The scale of the device to be used when translating from device space to babylon space.
  85785. */
  85786. deviceScaleFactor: number;
  85787. /**
  85788. * Updates the poseControlled values based on the input device pose.
  85789. * @param poseData the pose data to update the object with
  85790. */
  85791. updateFromDevice(poseData: DevicePose): void;
  85792. }
  85793. /**
  85794. * Set of options to customize the webVRCamera
  85795. */
  85796. export interface WebVROptions {
  85797. /**
  85798. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  85799. */
  85800. trackPosition?: boolean;
  85801. /**
  85802. * Sets the scale of the vrDevice in babylon space. (default: 1)
  85803. */
  85804. positionScale?: number;
  85805. /**
  85806. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  85807. */
  85808. displayName?: string;
  85809. /**
  85810. * Should the native controller meshes be initialized. (default: true)
  85811. */
  85812. controllerMeshes?: boolean;
  85813. /**
  85814. * Creating a default HemiLight only on controllers. (default: true)
  85815. */
  85816. defaultLightingOnControllers?: boolean;
  85817. /**
  85818. * If you don't want to use the default VR button of the helper. (default: false)
  85819. */
  85820. useCustomVRButton?: boolean;
  85821. /**
  85822. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  85823. */
  85824. customVRButton?: HTMLButtonElement;
  85825. /**
  85826. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  85827. */
  85828. rayLength?: number;
  85829. /**
  85830. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  85831. */
  85832. defaultHeight?: number;
  85833. /**
  85834. * If multiview should be used if availible (default: false)
  85835. */
  85836. useMultiview?: boolean;
  85837. }
  85838. /**
  85839. * This represents a WebVR camera.
  85840. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  85841. * @example http://doc.babylonjs.com/how_to/webvr_camera
  85842. */
  85843. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  85844. private webVROptions;
  85845. /**
  85846. * @hidden
  85847. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  85848. */
  85849. _vrDevice: any;
  85850. /**
  85851. * The rawPose of the vrDevice.
  85852. */
  85853. rawPose: Nullable<DevicePose>;
  85854. private _onVREnabled;
  85855. private _specsVersion;
  85856. private _attached;
  85857. private _frameData;
  85858. protected _descendants: Array<Node>;
  85859. private _deviceRoomPosition;
  85860. /** @hidden */
  85861. _deviceRoomRotationQuaternion: Quaternion;
  85862. private _standingMatrix;
  85863. /**
  85864. * Represents device position in babylon space.
  85865. */
  85866. devicePosition: Vector3;
  85867. /**
  85868. * Represents device rotation in babylon space.
  85869. */
  85870. deviceRotationQuaternion: Quaternion;
  85871. /**
  85872. * The scale of the device to be used when translating from device space to babylon space.
  85873. */
  85874. deviceScaleFactor: number;
  85875. private _deviceToWorld;
  85876. private _worldToDevice;
  85877. /**
  85878. * References to the webVR controllers for the vrDevice.
  85879. */
  85880. controllers: Array<WebVRController>;
  85881. /**
  85882. * Emits an event when a controller is attached.
  85883. */
  85884. onControllersAttachedObservable: Observable<WebVRController[]>;
  85885. /**
  85886. * Emits an event when a controller's mesh has been loaded;
  85887. */
  85888. onControllerMeshLoadedObservable: Observable<WebVRController>;
  85889. /**
  85890. * Emits an event when the HMD's pose has been updated.
  85891. */
  85892. onPoseUpdatedFromDeviceObservable: Observable<any>;
  85893. private _poseSet;
  85894. /**
  85895. * If the rig cameras be used as parent instead of this camera.
  85896. */
  85897. rigParenting: boolean;
  85898. private _lightOnControllers;
  85899. private _defaultHeight?;
  85900. /**
  85901. * Instantiates a WebVRFreeCamera.
  85902. * @param name The name of the WebVRFreeCamera
  85903. * @param position The starting anchor position for the camera
  85904. * @param scene The scene the camera belongs to
  85905. * @param webVROptions a set of customizable options for the webVRCamera
  85906. */
  85907. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  85908. /**
  85909. * Gets the device distance from the ground in meters.
  85910. * @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.
  85911. */
  85912. deviceDistanceToRoomGround(): number;
  85913. /**
  85914. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85915. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  85916. */
  85917. useStandingMatrix(callback?: (bool: boolean) => void): void;
  85918. /**
  85919. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85920. * @returns A promise with a boolean set to if the standing matrix is supported.
  85921. */
  85922. useStandingMatrixAsync(): Promise<boolean>;
  85923. /**
  85924. * Disposes the camera
  85925. */
  85926. dispose(): void;
  85927. /**
  85928. * Gets a vrController by name.
  85929. * @param name The name of the controller to retreive
  85930. * @returns the controller matching the name specified or null if not found
  85931. */
  85932. getControllerByName(name: string): Nullable<WebVRController>;
  85933. private _leftController;
  85934. /**
  85935. * The controller corresponding to the users left hand.
  85936. */
  85937. get leftController(): Nullable<WebVRController>;
  85938. private _rightController;
  85939. /**
  85940. * The controller corresponding to the users right hand.
  85941. */
  85942. get rightController(): Nullable<WebVRController>;
  85943. /**
  85944. * Casts a ray forward from the vrCamera's gaze.
  85945. * @param length Length of the ray (default: 100)
  85946. * @returns the ray corresponding to the gaze
  85947. */
  85948. getForwardRay(length?: number): Ray;
  85949. /**
  85950. * @hidden
  85951. * Updates the camera based on device's frame data
  85952. */
  85953. _checkInputs(): void;
  85954. /**
  85955. * Updates the poseControlled values based on the input device pose.
  85956. * @param poseData Pose coming from the device
  85957. */
  85958. updateFromDevice(poseData: DevicePose): void;
  85959. private _htmlElementAttached;
  85960. private _detachIfAttached;
  85961. /**
  85962. * WebVR's attach control will start broadcasting frames to the device.
  85963. * Note that in certain browsers (chrome for example) this function must be called
  85964. * within a user-interaction callback. Example:
  85965. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  85966. *
  85967. * @param element html element to attach the vrDevice to
  85968. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  85969. */
  85970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85971. /**
  85972. * Detaches the camera from the html element and disables VR
  85973. *
  85974. * @param element html element to detach from
  85975. */
  85976. detachControl(element: HTMLElement): void;
  85977. /**
  85978. * @returns the name of this class
  85979. */
  85980. getClassName(): string;
  85981. /**
  85982. * Calls resetPose on the vrDisplay
  85983. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  85984. */
  85985. resetToCurrentRotation(): void;
  85986. /**
  85987. * @hidden
  85988. * Updates the rig cameras (left and right eye)
  85989. */
  85990. _updateRigCameras(): void;
  85991. private _workingVector;
  85992. private _oneVector;
  85993. private _workingMatrix;
  85994. private updateCacheCalled;
  85995. private _correctPositionIfNotTrackPosition;
  85996. /**
  85997. * @hidden
  85998. * Updates the cached values of the camera
  85999. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  86000. */
  86001. _updateCache(ignoreParentClass?: boolean): void;
  86002. /**
  86003. * @hidden
  86004. * Get current device position in babylon world
  86005. */
  86006. _computeDevicePosition(): void;
  86007. /**
  86008. * Updates the current device position and rotation in the babylon world
  86009. */
  86010. update(): void;
  86011. /**
  86012. * @hidden
  86013. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  86014. * @returns an identity matrix
  86015. */
  86016. _getViewMatrix(): Matrix;
  86017. private _tmpMatrix;
  86018. /**
  86019. * This function is called by the two RIG cameras.
  86020. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  86021. * @hidden
  86022. */
  86023. _getWebVRViewMatrix(): Matrix;
  86024. /** @hidden */
  86025. _getWebVRProjectionMatrix(): Matrix;
  86026. private _onGamepadConnectedObserver;
  86027. private _onGamepadDisconnectedObserver;
  86028. private _updateCacheWhenTrackingDisabledObserver;
  86029. /**
  86030. * Initializes the controllers and their meshes
  86031. */
  86032. initControllers(): void;
  86033. }
  86034. }
  86035. declare module BABYLON {
  86036. /**
  86037. * Size options for a post process
  86038. */
  86039. export type PostProcessOptions = {
  86040. width: number;
  86041. height: number;
  86042. };
  86043. /**
  86044. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86045. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86046. */
  86047. export class PostProcess {
  86048. /** Name of the PostProcess. */
  86049. name: string;
  86050. /**
  86051. * Gets or sets the unique id of the post process
  86052. */
  86053. uniqueId: number;
  86054. /**
  86055. * Width of the texture to apply the post process on
  86056. */
  86057. width: number;
  86058. /**
  86059. * Height of the texture to apply the post process on
  86060. */
  86061. height: number;
  86062. /**
  86063. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86064. * @hidden
  86065. */
  86066. _outputTexture: Nullable<InternalTexture>;
  86067. /**
  86068. * Sampling mode used by the shader
  86069. * See https://doc.babylonjs.com/classes/3.1/texture
  86070. */
  86071. renderTargetSamplingMode: number;
  86072. /**
  86073. * Clear color to use when screen clearing
  86074. */
  86075. clearColor: Color4;
  86076. /**
  86077. * If the buffer needs to be cleared before applying the post process. (default: true)
  86078. * Should be set to false if shader will overwrite all previous pixels.
  86079. */
  86080. autoClear: boolean;
  86081. /**
  86082. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86083. */
  86084. alphaMode: number;
  86085. /**
  86086. * Sets the setAlphaBlendConstants of the babylon engine
  86087. */
  86088. alphaConstants: Color4;
  86089. /**
  86090. * Animations to be used for the post processing
  86091. */
  86092. animations: Animation[];
  86093. /**
  86094. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86095. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86096. */
  86097. enablePixelPerfectMode: boolean;
  86098. /**
  86099. * Force the postprocess to be applied without taking in account viewport
  86100. */
  86101. forceFullscreenViewport: boolean;
  86102. /**
  86103. * List of inspectable custom properties (used by the Inspector)
  86104. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86105. */
  86106. inspectableCustomProperties: IInspectable[];
  86107. /**
  86108. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86109. *
  86110. * | Value | Type | Description |
  86111. * | ----- | ----------------------------------- | ----------- |
  86112. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86113. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86114. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86115. *
  86116. */
  86117. scaleMode: number;
  86118. /**
  86119. * Force textures to be a power of two (default: false)
  86120. */
  86121. alwaysForcePOT: boolean;
  86122. private _samples;
  86123. /**
  86124. * Number of sample textures (default: 1)
  86125. */
  86126. get samples(): number;
  86127. set samples(n: number);
  86128. /**
  86129. * Modify the scale of the post process to be the same as the viewport (default: false)
  86130. */
  86131. adaptScaleToCurrentViewport: boolean;
  86132. private _camera;
  86133. private _scene;
  86134. private _engine;
  86135. private _options;
  86136. private _reusable;
  86137. private _textureType;
  86138. /**
  86139. * Smart array of input and output textures for the post process.
  86140. * @hidden
  86141. */
  86142. _textures: SmartArray<InternalTexture>;
  86143. /**
  86144. * The index in _textures that corresponds to the output texture.
  86145. * @hidden
  86146. */
  86147. _currentRenderTextureInd: number;
  86148. private _effect;
  86149. private _samplers;
  86150. private _fragmentUrl;
  86151. private _vertexUrl;
  86152. private _parameters;
  86153. private _scaleRatio;
  86154. protected _indexParameters: any;
  86155. private _shareOutputWithPostProcess;
  86156. private _texelSize;
  86157. private _forcedOutputTexture;
  86158. /**
  86159. * Returns the fragment url or shader name used in the post process.
  86160. * @returns the fragment url or name in the shader store.
  86161. */
  86162. getEffectName(): string;
  86163. /**
  86164. * An event triggered when the postprocess is activated.
  86165. */
  86166. onActivateObservable: Observable<Camera>;
  86167. private _onActivateObserver;
  86168. /**
  86169. * A function that is added to the onActivateObservable
  86170. */
  86171. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86172. /**
  86173. * An event triggered when the postprocess changes its size.
  86174. */
  86175. onSizeChangedObservable: Observable<PostProcess>;
  86176. private _onSizeChangedObserver;
  86177. /**
  86178. * A function that is added to the onSizeChangedObservable
  86179. */
  86180. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  86181. /**
  86182. * An event triggered when the postprocess applies its effect.
  86183. */
  86184. onApplyObservable: Observable<Effect>;
  86185. private _onApplyObserver;
  86186. /**
  86187. * A function that is added to the onApplyObservable
  86188. */
  86189. set onApply(callback: (effect: Effect) => void);
  86190. /**
  86191. * An event triggered before rendering the postprocess
  86192. */
  86193. onBeforeRenderObservable: Observable<Effect>;
  86194. private _onBeforeRenderObserver;
  86195. /**
  86196. * A function that is added to the onBeforeRenderObservable
  86197. */
  86198. set onBeforeRender(callback: (effect: Effect) => void);
  86199. /**
  86200. * An event triggered after rendering the postprocess
  86201. */
  86202. onAfterRenderObservable: Observable<Effect>;
  86203. private _onAfterRenderObserver;
  86204. /**
  86205. * A function that is added to the onAfterRenderObservable
  86206. */
  86207. set onAfterRender(callback: (efect: Effect) => void);
  86208. /**
  86209. * 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
  86210. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  86211. */
  86212. get inputTexture(): InternalTexture;
  86213. set inputTexture(value: InternalTexture);
  86214. /**
  86215. * Gets the camera which post process is applied to.
  86216. * @returns The camera the post process is applied to.
  86217. */
  86218. getCamera(): Camera;
  86219. /**
  86220. * Gets the texel size of the postprocess.
  86221. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  86222. */
  86223. get texelSize(): Vector2;
  86224. /**
  86225. * Creates a new instance PostProcess
  86226. * @param name The name of the PostProcess.
  86227. * @param fragmentUrl The url of the fragment shader to be used.
  86228. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  86229. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  86230. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86231. * @param camera The camera to apply the render pass to.
  86232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86233. * @param engine The engine which the post process will be applied. (default: current engine)
  86234. * @param reusable If the post process can be reused on the same frame. (default: false)
  86235. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  86236. * @param textureType Type of textures used when performing the post process. (default: 0)
  86237. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  86238. * @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
  86239. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  86240. */
  86241. constructor(
  86242. /** Name of the PostProcess. */
  86243. 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);
  86244. /**
  86245. * Gets a string idenfifying the name of the class
  86246. * @returns "PostProcess" string
  86247. */
  86248. getClassName(): string;
  86249. /**
  86250. * Gets the engine which this post process belongs to.
  86251. * @returns The engine the post process was enabled with.
  86252. */
  86253. getEngine(): Engine;
  86254. /**
  86255. * The effect that is created when initializing the post process.
  86256. * @returns The created effect corresponding the the postprocess.
  86257. */
  86258. getEffect(): Effect;
  86259. /**
  86260. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  86261. * @param postProcess The post process to share the output with.
  86262. * @returns This post process.
  86263. */
  86264. shareOutputWith(postProcess: PostProcess): PostProcess;
  86265. /**
  86266. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  86267. * This should be called if the post process that shares output with this post process is disabled/disposed.
  86268. */
  86269. useOwnOutput(): void;
  86270. /**
  86271. * Updates the effect with the current post process compile time values and recompiles the shader.
  86272. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86273. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86274. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86275. * @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
  86276. * @param onCompiled Called when the shader has been compiled.
  86277. * @param onError Called if there is an error when compiling a shader.
  86278. */
  86279. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86280. /**
  86281. * The post process is reusable if it can be used multiple times within one frame.
  86282. * @returns If the post process is reusable
  86283. */
  86284. isReusable(): boolean;
  86285. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  86286. markTextureDirty(): void;
  86287. /**
  86288. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  86289. * 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.
  86290. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  86291. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  86292. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  86293. * @returns The target texture that was bound to be written to.
  86294. */
  86295. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  86296. /**
  86297. * If the post process is supported.
  86298. */
  86299. get isSupported(): boolean;
  86300. /**
  86301. * The aspect ratio of the output texture.
  86302. */
  86303. get aspectRatio(): number;
  86304. /**
  86305. * Get a value indicating if the post-process is ready to be used
  86306. * @returns true if the post-process is ready (shader is compiled)
  86307. */
  86308. isReady(): boolean;
  86309. /**
  86310. * Binds all textures and uniforms to the shader, this will be run on every pass.
  86311. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  86312. */
  86313. apply(): Nullable<Effect>;
  86314. private _disposeTextures;
  86315. /**
  86316. * Disposes the post process.
  86317. * @param camera The camera to dispose the post process on.
  86318. */
  86319. dispose(camera?: Camera): void;
  86320. }
  86321. }
  86322. declare module BABYLON {
  86323. /** @hidden */
  86324. export var kernelBlurVaryingDeclaration: {
  86325. name: string;
  86326. shader: string;
  86327. };
  86328. }
  86329. declare module BABYLON {
  86330. /** @hidden */
  86331. export var kernelBlurFragment: {
  86332. name: string;
  86333. shader: string;
  86334. };
  86335. }
  86336. declare module BABYLON {
  86337. /** @hidden */
  86338. export var kernelBlurFragment2: {
  86339. name: string;
  86340. shader: string;
  86341. };
  86342. }
  86343. declare module BABYLON {
  86344. /** @hidden */
  86345. export var kernelBlurPixelShader: {
  86346. name: string;
  86347. shader: string;
  86348. };
  86349. }
  86350. declare module BABYLON {
  86351. /** @hidden */
  86352. export var kernelBlurVertex: {
  86353. name: string;
  86354. shader: string;
  86355. };
  86356. }
  86357. declare module BABYLON {
  86358. /** @hidden */
  86359. export var kernelBlurVertexShader: {
  86360. name: string;
  86361. shader: string;
  86362. };
  86363. }
  86364. declare module BABYLON {
  86365. /**
  86366. * The Blur Post Process which blurs an image based on a kernel and direction.
  86367. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  86368. */
  86369. export class BlurPostProcess extends PostProcess {
  86370. /** The direction in which to blur the image. */
  86371. direction: Vector2;
  86372. private blockCompilation;
  86373. protected _kernel: number;
  86374. protected _idealKernel: number;
  86375. protected _packedFloat: boolean;
  86376. private _staticDefines;
  86377. /**
  86378. * Sets the length in pixels of the blur sample region
  86379. */
  86380. set kernel(v: number);
  86381. /**
  86382. * Gets the length in pixels of the blur sample region
  86383. */
  86384. get kernel(): number;
  86385. /**
  86386. * Sets wether or not the blur needs to unpack/repack floats
  86387. */
  86388. set packedFloat(v: boolean);
  86389. /**
  86390. * Gets wether or not the blur is unpacking/repacking floats
  86391. */
  86392. get packedFloat(): boolean;
  86393. /**
  86394. * Creates a new instance BlurPostProcess
  86395. * @param name The name of the effect.
  86396. * @param direction The direction in which to blur the image.
  86397. * @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.
  86398. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86399. * @param camera The camera to apply the render pass to.
  86400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86401. * @param engine The engine which the post process will be applied. (default: current engine)
  86402. * @param reusable If the post process can be reused on the same frame. (default: false)
  86403. * @param textureType Type of textures used when performing the post process. (default: 0)
  86404. * @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)
  86405. */
  86406. constructor(name: string,
  86407. /** The direction in which to blur the image. */
  86408. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  86409. /**
  86410. * Updates the effect with the current post process compile time values and recompiles the shader.
  86411. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86412. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86413. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86414. * @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
  86415. * @param onCompiled Called when the shader has been compiled.
  86416. * @param onError Called if there is an error when compiling a shader.
  86417. */
  86418. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86419. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86420. /**
  86421. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  86422. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  86423. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  86424. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  86425. * The gaps between physical kernels are compensated for in the weighting of the samples
  86426. * @param idealKernel Ideal blur kernel.
  86427. * @return Nearest best kernel.
  86428. */
  86429. protected _nearestBestKernel(idealKernel: number): number;
  86430. /**
  86431. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  86432. * @param x The point on the Gaussian distribution to sample.
  86433. * @return the value of the Gaussian function at x.
  86434. */
  86435. protected _gaussianWeight(x: number): number;
  86436. /**
  86437. * Generates a string that can be used as a floating point number in GLSL.
  86438. * @param x Value to print.
  86439. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  86440. * @return GLSL float string.
  86441. */
  86442. protected _glslFloat(x: number, decimalFigures?: number): string;
  86443. }
  86444. }
  86445. declare module BABYLON {
  86446. /**
  86447. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86448. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86449. * You can then easily use it as a reflectionTexture on a flat surface.
  86450. * In case the surface is not a plane, please consider relying on reflection probes.
  86451. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86452. */
  86453. export class MirrorTexture extends RenderTargetTexture {
  86454. private scene;
  86455. /**
  86456. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  86457. * 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.
  86458. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86459. */
  86460. mirrorPlane: Plane;
  86461. /**
  86462. * Define the blur ratio used to blur the reflection if needed.
  86463. */
  86464. set blurRatio(value: number);
  86465. get blurRatio(): number;
  86466. /**
  86467. * Define the adaptive blur kernel used to blur the reflection if needed.
  86468. * This will autocompute the closest best match for the `blurKernel`
  86469. */
  86470. set adaptiveBlurKernel(value: number);
  86471. /**
  86472. * Define the blur kernel used to blur the reflection if needed.
  86473. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86474. */
  86475. set blurKernel(value: number);
  86476. /**
  86477. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  86478. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86479. */
  86480. set blurKernelX(value: number);
  86481. get blurKernelX(): number;
  86482. /**
  86483. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  86484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86485. */
  86486. set blurKernelY(value: number);
  86487. get blurKernelY(): number;
  86488. private _autoComputeBlurKernel;
  86489. protected _onRatioRescale(): void;
  86490. private _updateGammaSpace;
  86491. private _imageProcessingConfigChangeObserver;
  86492. private _transformMatrix;
  86493. private _mirrorMatrix;
  86494. private _savedViewMatrix;
  86495. private _blurX;
  86496. private _blurY;
  86497. private _adaptiveBlurKernel;
  86498. private _blurKernelX;
  86499. private _blurKernelY;
  86500. private _blurRatio;
  86501. /**
  86502. * Instantiates a Mirror Texture.
  86503. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86504. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86505. * You can then easily use it as a reflectionTexture on a flat surface.
  86506. * In case the surface is not a plane, please consider relying on reflection probes.
  86507. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86508. * @param name
  86509. * @param size
  86510. * @param scene
  86511. * @param generateMipMaps
  86512. * @param type
  86513. * @param samplingMode
  86514. * @param generateDepthBuffer
  86515. */
  86516. constructor(name: string, size: number | {
  86517. width: number;
  86518. height: number;
  86519. } | {
  86520. ratio: number;
  86521. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  86522. private _preparePostProcesses;
  86523. /**
  86524. * Clone the mirror texture.
  86525. * @returns the cloned texture
  86526. */
  86527. clone(): MirrorTexture;
  86528. /**
  86529. * Serialize the texture to a JSON representation you could use in Parse later on
  86530. * @returns the serialized JSON representation
  86531. */
  86532. serialize(): any;
  86533. /**
  86534. * Dispose the texture and release its associated resources.
  86535. */
  86536. dispose(): void;
  86537. }
  86538. }
  86539. declare module BABYLON {
  86540. /**
  86541. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86542. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86543. */
  86544. export class Texture extends BaseTexture {
  86545. /**
  86546. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  86547. */
  86548. static SerializeBuffers: boolean;
  86549. /** @hidden */
  86550. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  86551. /** @hidden */
  86552. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  86553. /** @hidden */
  86554. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  86555. /** nearest is mag = nearest and min = nearest and mip = linear */
  86556. static readonly NEAREST_SAMPLINGMODE: number;
  86557. /** nearest is mag = nearest and min = nearest and mip = linear */
  86558. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  86559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86560. static readonly BILINEAR_SAMPLINGMODE: number;
  86561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86562. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  86563. /** Trilinear is mag = linear and min = linear and mip = linear */
  86564. static readonly TRILINEAR_SAMPLINGMODE: number;
  86565. /** Trilinear is mag = linear and min = linear and mip = linear */
  86566. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  86567. /** mag = nearest and min = nearest and mip = nearest */
  86568. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  86569. /** mag = nearest and min = linear and mip = nearest */
  86570. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  86571. /** mag = nearest and min = linear and mip = linear */
  86572. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  86573. /** mag = nearest and min = linear and mip = none */
  86574. static readonly NEAREST_LINEAR: number;
  86575. /** mag = nearest and min = nearest and mip = none */
  86576. static readonly NEAREST_NEAREST: number;
  86577. /** mag = linear and min = nearest and mip = nearest */
  86578. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  86579. /** mag = linear and min = nearest and mip = linear */
  86580. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  86581. /** mag = linear and min = linear and mip = none */
  86582. static readonly LINEAR_LINEAR: number;
  86583. /** mag = linear and min = nearest and mip = none */
  86584. static readonly LINEAR_NEAREST: number;
  86585. /** Explicit coordinates mode */
  86586. static readonly EXPLICIT_MODE: number;
  86587. /** Spherical coordinates mode */
  86588. static readonly SPHERICAL_MODE: number;
  86589. /** Planar coordinates mode */
  86590. static readonly PLANAR_MODE: number;
  86591. /** Cubic coordinates mode */
  86592. static readonly CUBIC_MODE: number;
  86593. /** Projection coordinates mode */
  86594. static readonly PROJECTION_MODE: number;
  86595. /** Inverse Cubic coordinates mode */
  86596. static readonly SKYBOX_MODE: number;
  86597. /** Inverse Cubic coordinates mode */
  86598. static readonly INVCUBIC_MODE: number;
  86599. /** Equirectangular coordinates mode */
  86600. static readonly EQUIRECTANGULAR_MODE: number;
  86601. /** Equirectangular Fixed coordinates mode */
  86602. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  86603. /** Equirectangular Fixed Mirrored coordinates mode */
  86604. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86605. /** Texture is not repeating outside of 0..1 UVs */
  86606. static readonly CLAMP_ADDRESSMODE: number;
  86607. /** Texture is repeating outside of 0..1 UVs */
  86608. static readonly WRAP_ADDRESSMODE: number;
  86609. /** Texture is repeating and mirrored */
  86610. static readonly MIRROR_ADDRESSMODE: number;
  86611. /**
  86612. * 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
  86613. */
  86614. static UseSerializedUrlIfAny: boolean;
  86615. /**
  86616. * Define the url of the texture.
  86617. */
  86618. url: Nullable<string>;
  86619. /**
  86620. * Define an offset on the texture to offset the u coordinates of the UVs
  86621. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86622. */
  86623. uOffset: number;
  86624. /**
  86625. * Define an offset on the texture to offset the v coordinates of the UVs
  86626. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86627. */
  86628. vOffset: number;
  86629. /**
  86630. * Define an offset on the texture to scale the u coordinates of the UVs
  86631. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86632. */
  86633. uScale: number;
  86634. /**
  86635. * Define an offset on the texture to scale the v coordinates of the UVs
  86636. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86637. */
  86638. vScale: number;
  86639. /**
  86640. * Define an offset on the texture to rotate around the u coordinates of the UVs
  86641. * @see http://doc.babylonjs.com/how_to/more_materials
  86642. */
  86643. uAng: number;
  86644. /**
  86645. * Define an offset on the texture to rotate around the v coordinates of the UVs
  86646. * @see http://doc.babylonjs.com/how_to/more_materials
  86647. */
  86648. vAng: number;
  86649. /**
  86650. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  86651. * @see http://doc.babylonjs.com/how_to/more_materials
  86652. */
  86653. wAng: number;
  86654. /**
  86655. * Defines the center of rotation (U)
  86656. */
  86657. uRotationCenter: number;
  86658. /**
  86659. * Defines the center of rotation (V)
  86660. */
  86661. vRotationCenter: number;
  86662. /**
  86663. * Defines the center of rotation (W)
  86664. */
  86665. wRotationCenter: number;
  86666. /**
  86667. * Are mip maps generated for this texture or not.
  86668. */
  86669. get noMipmap(): boolean;
  86670. /**
  86671. * List of inspectable custom properties (used by the Inspector)
  86672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86673. */
  86674. inspectableCustomProperties: Nullable<IInspectable[]>;
  86675. private _noMipmap;
  86676. /** @hidden */
  86677. _invertY: boolean;
  86678. private _rowGenerationMatrix;
  86679. private _cachedTextureMatrix;
  86680. private _projectionModeMatrix;
  86681. private _t0;
  86682. private _t1;
  86683. private _t2;
  86684. private _cachedUOffset;
  86685. private _cachedVOffset;
  86686. private _cachedUScale;
  86687. private _cachedVScale;
  86688. private _cachedUAng;
  86689. private _cachedVAng;
  86690. private _cachedWAng;
  86691. private _cachedProjectionMatrixId;
  86692. private _cachedCoordinatesMode;
  86693. /** @hidden */
  86694. protected _initialSamplingMode: number;
  86695. /** @hidden */
  86696. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  86697. private _deleteBuffer;
  86698. protected _format: Nullable<number>;
  86699. private _delayedOnLoad;
  86700. private _delayedOnError;
  86701. private _mimeType?;
  86702. /**
  86703. * Observable triggered once the texture has been loaded.
  86704. */
  86705. onLoadObservable: Observable<Texture>;
  86706. protected _isBlocking: boolean;
  86707. /**
  86708. * Is the texture preventing material to render while loading.
  86709. * If false, a default texture will be used instead of the loading one during the preparation step.
  86710. */
  86711. set isBlocking(value: boolean);
  86712. get isBlocking(): boolean;
  86713. /**
  86714. * Get the current sampling mode associated with the texture.
  86715. */
  86716. get samplingMode(): number;
  86717. /**
  86718. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  86719. */
  86720. get invertY(): boolean;
  86721. /**
  86722. * Instantiates a new texture.
  86723. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86724. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86725. * @param url defines the url of the picture to load as a texture
  86726. * @param scene defines the scene or engine the texture will belong to
  86727. * @param noMipmap defines if the texture will require mip maps or not
  86728. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  86729. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86730. * @param onLoad defines a callback triggered when the texture has been loaded
  86731. * @param onError defines a callback triggered when an error occurred during the loading session
  86732. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  86733. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  86734. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86735. * @param mimeType defines an optional mime type information
  86736. */
  86737. 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);
  86738. /**
  86739. * Update the url (and optional buffer) of this texture if url was null during construction.
  86740. * @param url the url of the texture
  86741. * @param buffer the buffer of the texture (defaults to null)
  86742. * @param onLoad callback called when the texture is loaded (defaults to null)
  86743. */
  86744. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  86745. /**
  86746. * Finish the loading sequence of a texture flagged as delayed load.
  86747. * @hidden
  86748. */
  86749. delayLoad(): void;
  86750. private _prepareRowForTextureGeneration;
  86751. /**
  86752. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  86753. * @returns the transform matrix of the texture.
  86754. */
  86755. getTextureMatrix(uBase?: number): Matrix;
  86756. /**
  86757. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  86758. * @returns The reflection texture transform
  86759. */
  86760. getReflectionTextureMatrix(): Matrix;
  86761. /**
  86762. * Clones the texture.
  86763. * @returns the cloned texture
  86764. */
  86765. clone(): Texture;
  86766. /**
  86767. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86768. * @returns The JSON representation of the texture
  86769. */
  86770. serialize(): any;
  86771. /**
  86772. * Get the current class name of the texture useful for serialization or dynamic coding.
  86773. * @returns "Texture"
  86774. */
  86775. getClassName(): string;
  86776. /**
  86777. * Dispose the texture and release its associated resources.
  86778. */
  86779. dispose(): void;
  86780. /**
  86781. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  86782. * @param parsedTexture Define the JSON representation of the texture
  86783. * @param scene Define the scene the parsed texture should be instantiated in
  86784. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  86785. * @returns The parsed texture if successful
  86786. */
  86787. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  86788. /**
  86789. * Creates a texture from its base 64 representation.
  86790. * @param data Define the base64 payload without the data: prefix
  86791. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86792. * @param scene Define the scene the texture should belong to
  86793. * @param noMipmap Forces the texture to not create mip map information if true
  86794. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86795. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86796. * @param onLoad define a callback triggered when the texture has been loaded
  86797. * @param onError define a callback triggered when an error occurred during the loading session
  86798. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86799. * @returns the created texture
  86800. */
  86801. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  86802. /**
  86803. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  86804. * @param data Define the base64 payload without the data: prefix
  86805. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86806. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  86807. * @param scene Define the scene the texture should belong to
  86808. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  86809. * @param noMipmap Forces the texture to not create mip map information if true
  86810. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86811. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86812. * @param onLoad define a callback triggered when the texture has been loaded
  86813. * @param onError define a callback triggered when an error occurred during the loading session
  86814. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86815. * @returns the created texture
  86816. */
  86817. 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;
  86818. }
  86819. }
  86820. declare module BABYLON {
  86821. /**
  86822. * PostProcessManager is used to manage one or more post processes or post process pipelines
  86823. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86824. */
  86825. export class PostProcessManager {
  86826. private _scene;
  86827. private _indexBuffer;
  86828. private _vertexBuffers;
  86829. /**
  86830. * Creates a new instance PostProcess
  86831. * @param scene The scene that the post process is associated with.
  86832. */
  86833. constructor(scene: Scene);
  86834. private _prepareBuffers;
  86835. private _buildIndexBuffer;
  86836. /**
  86837. * Rebuilds the vertex buffers of the manager.
  86838. * @hidden
  86839. */
  86840. _rebuild(): void;
  86841. /**
  86842. * Prepares a frame to be run through a post process.
  86843. * @param sourceTexture The input texture to the post procesess. (default: null)
  86844. * @param postProcesses An array of post processes to be run. (default: null)
  86845. * @returns True if the post processes were able to be run.
  86846. * @hidden
  86847. */
  86848. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  86849. /**
  86850. * Manually render a set of post processes to a texture.
  86851. * @param postProcesses An array of post processes to be run.
  86852. * @param targetTexture The target texture to render to.
  86853. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  86854. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  86855. * @param lodLevel defines which lod of the texture to render to
  86856. */
  86857. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  86858. /**
  86859. * Finalize the result of the output of the postprocesses.
  86860. * @param doNotPresent If true the result will not be displayed to the screen.
  86861. * @param targetTexture The target texture to render to.
  86862. * @param faceIndex The index of the face to bind the target texture to.
  86863. * @param postProcesses The array of post processes to render.
  86864. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  86865. * @hidden
  86866. */
  86867. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  86868. /**
  86869. * Disposes of the post process manager.
  86870. */
  86871. dispose(): void;
  86872. }
  86873. }
  86874. declare module BABYLON {
  86875. /** Interface used by value gradients (color, factor, ...) */
  86876. export interface IValueGradient {
  86877. /**
  86878. * Gets or sets the gradient value (between 0 and 1)
  86879. */
  86880. gradient: number;
  86881. }
  86882. /** Class used to store color4 gradient */
  86883. export class ColorGradient implements IValueGradient {
  86884. /**
  86885. * Gets or sets the gradient value (between 0 and 1)
  86886. */
  86887. gradient: number;
  86888. /**
  86889. * Gets or sets first associated color
  86890. */
  86891. color1: Color4;
  86892. /**
  86893. * Gets or sets second associated color
  86894. */
  86895. color2?: Color4;
  86896. /**
  86897. * Will get a color picked randomly between color1 and color2.
  86898. * If color2 is undefined then color1 will be used
  86899. * @param result defines the target Color4 to store the result in
  86900. */
  86901. getColorToRef(result: Color4): void;
  86902. }
  86903. /** Class used to store color 3 gradient */
  86904. export class Color3Gradient implements IValueGradient {
  86905. /**
  86906. * Gets or sets the gradient value (between 0 and 1)
  86907. */
  86908. gradient: number;
  86909. /**
  86910. * Gets or sets the associated color
  86911. */
  86912. color: Color3;
  86913. }
  86914. /** Class used to store factor gradient */
  86915. export class FactorGradient implements IValueGradient {
  86916. /**
  86917. * Gets or sets the gradient value (between 0 and 1)
  86918. */
  86919. gradient: number;
  86920. /**
  86921. * Gets or sets first associated factor
  86922. */
  86923. factor1: number;
  86924. /**
  86925. * Gets or sets second associated factor
  86926. */
  86927. factor2?: number;
  86928. /**
  86929. * Will get a number picked randomly between factor1 and factor2.
  86930. * If factor2 is undefined then factor1 will be used
  86931. * @returns the picked number
  86932. */
  86933. getFactor(): number;
  86934. }
  86935. /**
  86936. * Helper used to simplify some generic gradient tasks
  86937. */
  86938. export class GradientHelper {
  86939. /**
  86940. * Gets the current gradient from an array of IValueGradient
  86941. * @param ratio defines the current ratio to get
  86942. * @param gradients defines the array of IValueGradient
  86943. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86944. */
  86945. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86946. }
  86947. }
  86948. declare module BABYLON {
  86949. interface ThinEngine {
  86950. /**
  86951. * Creates a dynamic texture
  86952. * @param width defines the width of the texture
  86953. * @param height defines the height of the texture
  86954. * @param generateMipMaps defines if the engine should generate the mip levels
  86955. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86956. * @returns the dynamic texture inside an InternalTexture
  86957. */
  86958. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86959. /**
  86960. * Update the content of a dynamic texture
  86961. * @param texture defines the texture to update
  86962. * @param canvas defines the canvas containing the source
  86963. * @param invertY defines if data must be stored with Y axis inverted
  86964. * @param premulAlpha defines if alpha is stored as premultiplied
  86965. * @param format defines the format of the data
  86966. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86967. */
  86968. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86969. }
  86970. }
  86971. declare module BABYLON {
  86972. /**
  86973. * Helper class used to generate a canvas to manipulate images
  86974. */
  86975. export class CanvasGenerator {
  86976. /**
  86977. * Create a new canvas (or offscreen canvas depending on the context)
  86978. * @param width defines the expected width
  86979. * @param height defines the expected height
  86980. * @return a new canvas or offscreen canvas
  86981. */
  86982. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86983. }
  86984. }
  86985. declare module BABYLON {
  86986. /**
  86987. * A class extending Texture allowing drawing on a texture
  86988. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86989. */
  86990. export class DynamicTexture extends Texture {
  86991. private _generateMipMaps;
  86992. private _canvas;
  86993. private _context;
  86994. private _engine;
  86995. /**
  86996. * Creates a DynamicTexture
  86997. * @param name defines the name of the texture
  86998. * @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
  86999. * @param scene defines the scene where you want the texture
  87000. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  87001. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  87002. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  87003. */
  87004. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  87005. /**
  87006. * Get the current class name of the texture useful for serialization or dynamic coding.
  87007. * @returns "DynamicTexture"
  87008. */
  87009. getClassName(): string;
  87010. /**
  87011. * Gets the current state of canRescale
  87012. */
  87013. get canRescale(): boolean;
  87014. private _recreate;
  87015. /**
  87016. * Scales the texture
  87017. * @param ratio the scale factor to apply to both width and height
  87018. */
  87019. scale(ratio: number): void;
  87020. /**
  87021. * Resizes the texture
  87022. * @param width the new width
  87023. * @param height the new height
  87024. */
  87025. scaleTo(width: number, height: number): void;
  87026. /**
  87027. * Gets the context of the canvas used by the texture
  87028. * @returns the canvas context of the dynamic texture
  87029. */
  87030. getContext(): CanvasRenderingContext2D;
  87031. /**
  87032. * Clears the texture
  87033. */
  87034. clear(): void;
  87035. /**
  87036. * Updates the texture
  87037. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87038. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87039. */
  87040. update(invertY?: boolean, premulAlpha?: boolean): void;
  87041. /**
  87042. * Draws text onto the texture
  87043. * @param text defines the text to be drawn
  87044. * @param x defines the placement of the text from the left
  87045. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87046. * @param font defines the font to be used with font-style, font-size, font-name
  87047. * @param color defines the color used for the text
  87048. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87049. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87050. * @param update defines whether texture is immediately update (default is true)
  87051. */
  87052. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87053. /**
  87054. * Clones the texture
  87055. * @returns the clone of the texture.
  87056. */
  87057. clone(): DynamicTexture;
  87058. /**
  87059. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87060. * @returns a serialized dynamic texture object
  87061. */
  87062. serialize(): any;
  87063. /** @hidden */
  87064. _rebuild(): void;
  87065. }
  87066. }
  87067. declare module BABYLON {
  87068. interface AbstractScene {
  87069. /**
  87070. * The list of procedural textures added to the scene
  87071. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87072. */
  87073. proceduralTextures: Array<ProceduralTexture>;
  87074. }
  87075. /**
  87076. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87077. * in a given scene.
  87078. */
  87079. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87080. /**
  87081. * The component name helpfull to identify the component in the list of scene components.
  87082. */
  87083. readonly name: string;
  87084. /**
  87085. * The scene the component belongs to.
  87086. */
  87087. scene: Scene;
  87088. /**
  87089. * Creates a new instance of the component for the given scene
  87090. * @param scene Defines the scene to register the component in
  87091. */
  87092. constructor(scene: Scene);
  87093. /**
  87094. * Registers the component in a given scene
  87095. */
  87096. register(): void;
  87097. /**
  87098. * Rebuilds the elements related to this component in case of
  87099. * context lost for instance.
  87100. */
  87101. rebuild(): void;
  87102. /**
  87103. * Disposes the component and the associated ressources.
  87104. */
  87105. dispose(): void;
  87106. private _beforeClear;
  87107. }
  87108. }
  87109. declare module BABYLON {
  87110. interface ThinEngine {
  87111. /**
  87112. * Creates a new render target cube texture
  87113. * @param size defines the size of the texture
  87114. * @param options defines the options used to create the texture
  87115. * @returns a new render target cube texture stored in an InternalTexture
  87116. */
  87117. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87118. }
  87119. }
  87120. declare module BABYLON {
  87121. /** @hidden */
  87122. export var proceduralVertexShader: {
  87123. name: string;
  87124. shader: string;
  87125. };
  87126. }
  87127. declare module BABYLON {
  87128. /**
  87129. * 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.
  87130. * This is the base class of any Procedural texture and contains most of the shareable code.
  87131. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87132. */
  87133. export class ProceduralTexture extends Texture {
  87134. isCube: boolean;
  87135. /**
  87136. * Define if the texture is enabled or not (disabled texture will not render)
  87137. */
  87138. isEnabled: boolean;
  87139. /**
  87140. * Define if the texture must be cleared before rendering (default is true)
  87141. */
  87142. autoClear: boolean;
  87143. /**
  87144. * Callback called when the texture is generated
  87145. */
  87146. onGenerated: () => void;
  87147. /**
  87148. * Event raised when the texture is generated
  87149. */
  87150. onGeneratedObservable: Observable<ProceduralTexture>;
  87151. /** @hidden */
  87152. _generateMipMaps: boolean;
  87153. /** @hidden **/
  87154. _effect: Effect;
  87155. /** @hidden */
  87156. _textures: {
  87157. [key: string]: Texture;
  87158. };
  87159. private _size;
  87160. private _currentRefreshId;
  87161. private _frameId;
  87162. private _refreshRate;
  87163. private _vertexBuffers;
  87164. private _indexBuffer;
  87165. private _uniforms;
  87166. private _samplers;
  87167. private _fragment;
  87168. private _floats;
  87169. private _ints;
  87170. private _floatsArrays;
  87171. private _colors3;
  87172. private _colors4;
  87173. private _vectors2;
  87174. private _vectors3;
  87175. private _matrices;
  87176. private _fallbackTexture;
  87177. private _fallbackTextureUsed;
  87178. private _engine;
  87179. private _cachedDefines;
  87180. private _contentUpdateId;
  87181. private _contentData;
  87182. /**
  87183. * Instantiates a new procedural texture.
  87184. * 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.
  87185. * This is the base class of any Procedural texture and contains most of the shareable code.
  87186. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87187. * @param name Define the name of the texture
  87188. * @param size Define the size of the texture to create
  87189. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  87190. * @param scene Define the scene the texture belongs to
  87191. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  87192. * @param generateMipMaps Define if the texture should creates mip maps or not
  87193. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  87194. */
  87195. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  87196. /**
  87197. * The effect that is created when initializing the post process.
  87198. * @returns The created effect corresponding the the postprocess.
  87199. */
  87200. getEffect(): Effect;
  87201. /**
  87202. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  87203. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  87204. */
  87205. getContent(): Nullable<ArrayBufferView>;
  87206. private _createIndexBuffer;
  87207. /** @hidden */
  87208. _rebuild(): void;
  87209. /**
  87210. * Resets the texture in order to recreate its associated resources.
  87211. * This can be called in case of context loss
  87212. */
  87213. reset(): void;
  87214. protected _getDefines(): string;
  87215. /**
  87216. * Is the texture ready to be used ? (rendered at least once)
  87217. * @returns true if ready, otherwise, false.
  87218. */
  87219. isReady(): boolean;
  87220. /**
  87221. * Resets the refresh counter of the texture and start bak from scratch.
  87222. * Could be useful to regenerate the texture if it is setup to render only once.
  87223. */
  87224. resetRefreshCounter(): void;
  87225. /**
  87226. * Set the fragment shader to use in order to render the texture.
  87227. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87228. */
  87229. setFragment(fragment: any): void;
  87230. /**
  87231. * Define the refresh rate of the texture or the rendering frequency.
  87232. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87233. */
  87234. get refreshRate(): number;
  87235. set refreshRate(value: number);
  87236. /** @hidden */
  87237. _shouldRender(): boolean;
  87238. /**
  87239. * Get the size the texture is rendering at.
  87240. * @returns the size (texture is always squared)
  87241. */
  87242. getRenderSize(): number;
  87243. /**
  87244. * Resize the texture to new value.
  87245. * @param size Define the new size the texture should have
  87246. * @param generateMipMaps Define whether the new texture should create mip maps
  87247. */
  87248. resize(size: number, generateMipMaps: boolean): void;
  87249. private _checkUniform;
  87250. /**
  87251. * Set a texture in the shader program used to render.
  87252. * @param name Define the name of the uniform samplers as defined in the shader
  87253. * @param texture Define the texture to bind to this sampler
  87254. * @return the texture itself allowing "fluent" like uniform updates
  87255. */
  87256. setTexture(name: string, texture: Texture): ProceduralTexture;
  87257. /**
  87258. * Set a float in the shader.
  87259. * @param name Define the name of the uniform as defined in the shader
  87260. * @param value Define the value to give to the uniform
  87261. * @return the texture itself allowing "fluent" like uniform updates
  87262. */
  87263. setFloat(name: string, value: number): ProceduralTexture;
  87264. /**
  87265. * Set a int in the shader.
  87266. * @param name Define the name of the uniform as defined in the shader
  87267. * @param value Define the value to give to the uniform
  87268. * @return the texture itself allowing "fluent" like uniform updates
  87269. */
  87270. setInt(name: string, value: number): ProceduralTexture;
  87271. /**
  87272. * Set an array of floats in the shader.
  87273. * @param name Define the name of the uniform as defined in the shader
  87274. * @param value Define the value to give to the uniform
  87275. * @return the texture itself allowing "fluent" like uniform updates
  87276. */
  87277. setFloats(name: string, value: number[]): ProceduralTexture;
  87278. /**
  87279. * Set a vec3 in the shader from a Color3.
  87280. * @param name Define the name of the uniform as defined in the shader
  87281. * @param value Define the value to give to the uniform
  87282. * @return the texture itself allowing "fluent" like uniform updates
  87283. */
  87284. setColor3(name: string, value: Color3): ProceduralTexture;
  87285. /**
  87286. * Set a vec4 in the shader from a Color4.
  87287. * @param name Define the name of the uniform as defined in the shader
  87288. * @param value Define the value to give to the uniform
  87289. * @return the texture itself allowing "fluent" like uniform updates
  87290. */
  87291. setColor4(name: string, value: Color4): ProceduralTexture;
  87292. /**
  87293. * Set a vec2 in the shader from a Vector2.
  87294. * @param name Define the name of the uniform as defined in the shader
  87295. * @param value Define the value to give to the uniform
  87296. * @return the texture itself allowing "fluent" like uniform updates
  87297. */
  87298. setVector2(name: string, value: Vector2): ProceduralTexture;
  87299. /**
  87300. * Set a vec3 in the shader from a Vector3.
  87301. * @param name Define the name of the uniform as defined in the shader
  87302. * @param value Define the value to give to the uniform
  87303. * @return the texture itself allowing "fluent" like uniform updates
  87304. */
  87305. setVector3(name: string, value: Vector3): ProceduralTexture;
  87306. /**
  87307. * Set a mat4 in the shader from a MAtrix.
  87308. * @param name Define the name of the uniform as defined in the shader
  87309. * @param value Define the value to give to the uniform
  87310. * @return the texture itself allowing "fluent" like uniform updates
  87311. */
  87312. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87313. /**
  87314. * Render the texture to its associated render target.
  87315. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87316. */
  87317. render(useCameraPostProcess?: boolean): void;
  87318. /**
  87319. * Clone the texture.
  87320. * @returns the cloned texture
  87321. */
  87322. clone(): ProceduralTexture;
  87323. /**
  87324. * Dispose the texture and release its asoociated resources.
  87325. */
  87326. dispose(): void;
  87327. }
  87328. }
  87329. declare module BABYLON {
  87330. /**
  87331. * This represents the base class for particle system in Babylon.
  87332. * 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.
  87333. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87334. * @example https://doc.babylonjs.com/babylon101/particles
  87335. */
  87336. export class BaseParticleSystem {
  87337. /**
  87338. * Source color is added to the destination color without alpha affecting the result
  87339. */
  87340. static BLENDMODE_ONEONE: number;
  87341. /**
  87342. * Blend current color and particle color using particle’s alpha
  87343. */
  87344. static BLENDMODE_STANDARD: number;
  87345. /**
  87346. * Add current color and particle color multiplied by particle’s alpha
  87347. */
  87348. static BLENDMODE_ADD: number;
  87349. /**
  87350. * Multiply current color with particle color
  87351. */
  87352. static BLENDMODE_MULTIPLY: number;
  87353. /**
  87354. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87355. */
  87356. static BLENDMODE_MULTIPLYADD: number;
  87357. /**
  87358. * List of animations used by the particle system.
  87359. */
  87360. animations: Animation[];
  87361. /**
  87362. * The id of the Particle system.
  87363. */
  87364. id: string;
  87365. /**
  87366. * The friendly name of the Particle system.
  87367. */
  87368. name: string;
  87369. /**
  87370. * The rendering group used by the Particle system to chose when to render.
  87371. */
  87372. renderingGroupId: number;
  87373. /**
  87374. * The emitter represents the Mesh or position we are attaching the particle system to.
  87375. */
  87376. emitter: Nullable<AbstractMesh | Vector3>;
  87377. /**
  87378. * The maximum number of particles to emit per frame
  87379. */
  87380. emitRate: number;
  87381. /**
  87382. * If you want to launch only a few particles at once, that can be done, as well.
  87383. */
  87384. manualEmitCount: number;
  87385. /**
  87386. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87387. */
  87388. updateSpeed: number;
  87389. /**
  87390. * The amount of time the particle system is running (depends of the overall update speed).
  87391. */
  87392. targetStopDuration: number;
  87393. /**
  87394. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87395. */
  87396. disposeOnStop: boolean;
  87397. /**
  87398. * Minimum power of emitting particles.
  87399. */
  87400. minEmitPower: number;
  87401. /**
  87402. * Maximum power of emitting particles.
  87403. */
  87404. maxEmitPower: number;
  87405. /**
  87406. * Minimum life time of emitting particles.
  87407. */
  87408. minLifeTime: number;
  87409. /**
  87410. * Maximum life time of emitting particles.
  87411. */
  87412. maxLifeTime: number;
  87413. /**
  87414. * Minimum Size of emitting particles.
  87415. */
  87416. minSize: number;
  87417. /**
  87418. * Maximum Size of emitting particles.
  87419. */
  87420. maxSize: number;
  87421. /**
  87422. * Minimum scale of emitting particles on X axis.
  87423. */
  87424. minScaleX: number;
  87425. /**
  87426. * Maximum scale of emitting particles on X axis.
  87427. */
  87428. maxScaleX: number;
  87429. /**
  87430. * Minimum scale of emitting particles on Y axis.
  87431. */
  87432. minScaleY: number;
  87433. /**
  87434. * Maximum scale of emitting particles on Y axis.
  87435. */
  87436. maxScaleY: number;
  87437. /**
  87438. * Gets or sets the minimal initial rotation in radians.
  87439. */
  87440. minInitialRotation: number;
  87441. /**
  87442. * Gets or sets the maximal initial rotation in radians.
  87443. */
  87444. maxInitialRotation: number;
  87445. /**
  87446. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87447. */
  87448. minAngularSpeed: number;
  87449. /**
  87450. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87451. */
  87452. maxAngularSpeed: number;
  87453. /**
  87454. * The texture used to render each particle. (this can be a spritesheet)
  87455. */
  87456. particleTexture: Nullable<Texture>;
  87457. /**
  87458. * The layer mask we are rendering the particles through.
  87459. */
  87460. layerMask: number;
  87461. /**
  87462. * This can help using your own shader to render the particle system.
  87463. * The according effect will be created
  87464. */
  87465. customShader: any;
  87466. /**
  87467. * By default particle system starts as soon as they are created. This prevents the
  87468. * automatic start to happen and let you decide when to start emitting particles.
  87469. */
  87470. preventAutoStart: boolean;
  87471. private _noiseTexture;
  87472. /**
  87473. * Gets or sets a texture used to add random noise to particle positions
  87474. */
  87475. get noiseTexture(): Nullable<ProceduralTexture>;
  87476. set noiseTexture(value: Nullable<ProceduralTexture>);
  87477. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87478. noiseStrength: Vector3;
  87479. /**
  87480. * Callback triggered when the particle animation is ending.
  87481. */
  87482. onAnimationEnd: Nullable<() => void>;
  87483. /**
  87484. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87485. */
  87486. blendMode: number;
  87487. /**
  87488. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87489. * to override the particles.
  87490. */
  87491. forceDepthWrite: boolean;
  87492. /** 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 */
  87493. preWarmCycles: number;
  87494. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87495. preWarmStepOffset: number;
  87496. /**
  87497. * 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)
  87498. */
  87499. spriteCellChangeSpeed: number;
  87500. /**
  87501. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87502. */
  87503. startSpriteCellID: number;
  87504. /**
  87505. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87506. */
  87507. endSpriteCellID: number;
  87508. /**
  87509. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87510. */
  87511. spriteCellWidth: number;
  87512. /**
  87513. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87514. */
  87515. spriteCellHeight: number;
  87516. /**
  87517. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87518. */
  87519. spriteRandomStartCell: boolean;
  87520. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87521. translationPivot: Vector2;
  87522. /** @hidden */
  87523. protected _isAnimationSheetEnabled: boolean;
  87524. /**
  87525. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87526. */
  87527. beginAnimationOnStart: boolean;
  87528. /**
  87529. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87530. */
  87531. beginAnimationFrom: number;
  87532. /**
  87533. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87534. */
  87535. beginAnimationTo: number;
  87536. /**
  87537. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87538. */
  87539. beginAnimationLoop: boolean;
  87540. /**
  87541. * Gets or sets a world offset applied to all particles
  87542. */
  87543. worldOffset: Vector3;
  87544. /**
  87545. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87546. */
  87547. get isAnimationSheetEnabled(): boolean;
  87548. set isAnimationSheetEnabled(value: boolean);
  87549. /**
  87550. * Get hosting scene
  87551. * @returns the scene
  87552. */
  87553. getScene(): Scene;
  87554. /**
  87555. * You can use gravity if you want to give an orientation to your particles.
  87556. */
  87557. gravity: Vector3;
  87558. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87559. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87560. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87561. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87562. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87563. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87564. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87565. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87566. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87567. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87568. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87569. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87570. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87571. /**
  87572. * Defines the delay in milliseconds before starting the system (0 by default)
  87573. */
  87574. startDelay: number;
  87575. /**
  87576. * Gets the current list of drag gradients.
  87577. * You must use addDragGradient and removeDragGradient to udpate this list
  87578. * @returns the list of drag gradients
  87579. */
  87580. getDragGradients(): Nullable<Array<FactorGradient>>;
  87581. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87582. limitVelocityDamping: number;
  87583. /**
  87584. * Gets the current list of limit velocity gradients.
  87585. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87586. * @returns the list of limit velocity gradients
  87587. */
  87588. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87589. /**
  87590. * Gets the current list of color gradients.
  87591. * You must use addColorGradient and removeColorGradient to udpate this list
  87592. * @returns the list of color gradients
  87593. */
  87594. getColorGradients(): Nullable<Array<ColorGradient>>;
  87595. /**
  87596. * Gets the current list of size gradients.
  87597. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87598. * @returns the list of size gradients
  87599. */
  87600. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87601. /**
  87602. * Gets the current list of color remap gradients.
  87603. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87604. * @returns the list of color remap gradients
  87605. */
  87606. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87607. /**
  87608. * Gets the current list of alpha remap gradients.
  87609. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87610. * @returns the list of alpha remap gradients
  87611. */
  87612. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87613. /**
  87614. * Gets the current list of life time gradients.
  87615. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87616. * @returns the list of life time gradients
  87617. */
  87618. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87619. /**
  87620. * Gets the current list of angular speed gradients.
  87621. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87622. * @returns the list of angular speed gradients
  87623. */
  87624. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87625. /**
  87626. * Gets the current list of velocity gradients.
  87627. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87628. * @returns the list of velocity gradients
  87629. */
  87630. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87631. /**
  87632. * Gets the current list of start size gradients.
  87633. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87634. * @returns the list of start size gradients
  87635. */
  87636. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87637. /**
  87638. * Gets the current list of emit rate gradients.
  87639. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87640. * @returns the list of emit rate gradients
  87641. */
  87642. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87643. /**
  87644. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87645. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87646. */
  87647. get direction1(): Vector3;
  87648. set direction1(value: Vector3);
  87649. /**
  87650. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87651. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87652. */
  87653. get direction2(): Vector3;
  87654. set direction2(value: Vector3);
  87655. /**
  87656. * 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.
  87657. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87658. */
  87659. get minEmitBox(): Vector3;
  87660. set minEmitBox(value: Vector3);
  87661. /**
  87662. * 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.
  87663. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87664. */
  87665. get maxEmitBox(): Vector3;
  87666. set maxEmitBox(value: Vector3);
  87667. /**
  87668. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87669. */
  87670. color1: Color4;
  87671. /**
  87672. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87673. */
  87674. color2: Color4;
  87675. /**
  87676. * Color the particle will have at the end of its lifetime
  87677. */
  87678. colorDead: Color4;
  87679. /**
  87680. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87681. */
  87682. textureMask: Color4;
  87683. /**
  87684. * The particle emitter type defines the emitter used by the particle system.
  87685. * It can be for example box, sphere, or cone...
  87686. */
  87687. particleEmitterType: IParticleEmitterType;
  87688. /** @hidden */
  87689. _isSubEmitter: boolean;
  87690. /**
  87691. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87692. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87693. */
  87694. billboardMode: number;
  87695. protected _isBillboardBased: boolean;
  87696. /**
  87697. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87698. */
  87699. get isBillboardBased(): boolean;
  87700. set isBillboardBased(value: boolean);
  87701. /**
  87702. * The scene the particle system belongs to.
  87703. */
  87704. protected _scene: Scene;
  87705. /**
  87706. * Local cache of defines for image processing.
  87707. */
  87708. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87709. /**
  87710. * Default configuration related to image processing available in the standard Material.
  87711. */
  87712. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87713. /**
  87714. * Gets the image processing configuration used either in this material.
  87715. */
  87716. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87717. /**
  87718. * Sets the Default image processing configuration used either in the this material.
  87719. *
  87720. * If sets to null, the scene one is in use.
  87721. */
  87722. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87723. /**
  87724. * Attaches a new image processing configuration to the Standard Material.
  87725. * @param configuration
  87726. */
  87727. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87728. /** @hidden */
  87729. protected _reset(): void;
  87730. /** @hidden */
  87731. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87732. /**
  87733. * Instantiates a particle system.
  87734. * 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.
  87735. * @param name The name of the particle system
  87736. */
  87737. constructor(name: string);
  87738. /**
  87739. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87740. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87741. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87742. * @returns the emitter
  87743. */
  87744. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87745. /**
  87746. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87747. * @param radius The radius of the hemisphere to emit from
  87748. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87749. * @returns the emitter
  87750. */
  87751. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87752. /**
  87753. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87754. * @param radius The radius of the sphere to emit from
  87755. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87756. * @returns the emitter
  87757. */
  87758. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87759. /**
  87760. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87761. * @param radius The radius of the sphere to emit from
  87762. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87763. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87764. * @returns the emitter
  87765. */
  87766. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87767. /**
  87768. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87769. * @param radius The radius of the emission cylinder
  87770. * @param height The height of the emission cylinder
  87771. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87772. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87773. * @returns the emitter
  87774. */
  87775. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87776. /**
  87777. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87778. * @param radius The radius of the cylinder to emit from
  87779. * @param height The height of the emission cylinder
  87780. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87781. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87782. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87783. * @returns the emitter
  87784. */
  87785. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87786. /**
  87787. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87788. * @param radius The radius of the cone to emit from
  87789. * @param angle The base angle of the cone
  87790. * @returns the emitter
  87791. */
  87792. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87793. /**
  87794. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87795. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87796. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87797. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87798. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87799. * @returns the emitter
  87800. */
  87801. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87802. }
  87803. }
  87804. declare module BABYLON {
  87805. /**
  87806. * Type of sub emitter
  87807. */
  87808. export enum SubEmitterType {
  87809. /**
  87810. * Attached to the particle over it's lifetime
  87811. */
  87812. ATTACHED = 0,
  87813. /**
  87814. * Created when the particle dies
  87815. */
  87816. END = 1
  87817. }
  87818. /**
  87819. * Sub emitter class used to emit particles from an existing particle
  87820. */
  87821. export class SubEmitter {
  87822. /**
  87823. * the particle system to be used by the sub emitter
  87824. */
  87825. particleSystem: ParticleSystem;
  87826. /**
  87827. * Type of the submitter (Default: END)
  87828. */
  87829. type: SubEmitterType;
  87830. /**
  87831. * 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)
  87832. * Note: This only is supported when using an emitter of type Mesh
  87833. */
  87834. inheritDirection: boolean;
  87835. /**
  87836. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87837. */
  87838. inheritedVelocityAmount: number;
  87839. /**
  87840. * Creates a sub emitter
  87841. * @param particleSystem the particle system to be used by the sub emitter
  87842. */
  87843. constructor(
  87844. /**
  87845. * the particle system to be used by the sub emitter
  87846. */
  87847. particleSystem: ParticleSystem);
  87848. /**
  87849. * Clones the sub emitter
  87850. * @returns the cloned sub emitter
  87851. */
  87852. clone(): SubEmitter;
  87853. /**
  87854. * Serialize current object to a JSON object
  87855. * @returns the serialized object
  87856. */
  87857. serialize(): any;
  87858. /** @hidden */
  87859. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87860. /**
  87861. * Creates a new SubEmitter from a serialized JSON version
  87862. * @param serializationObject defines the JSON object to read from
  87863. * @param scene defines the hosting scene
  87864. * @param rootUrl defines the rootUrl for data loading
  87865. * @returns a new SubEmitter
  87866. */
  87867. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87868. /** Release associated resources */
  87869. dispose(): void;
  87870. }
  87871. }
  87872. declare module BABYLON {
  87873. /** @hidden */
  87874. export var clipPlaneFragmentDeclaration: {
  87875. name: string;
  87876. shader: string;
  87877. };
  87878. }
  87879. declare module BABYLON {
  87880. /** @hidden */
  87881. export var imageProcessingDeclaration: {
  87882. name: string;
  87883. shader: string;
  87884. };
  87885. }
  87886. declare module BABYLON {
  87887. /** @hidden */
  87888. export var imageProcessingFunctions: {
  87889. name: string;
  87890. shader: string;
  87891. };
  87892. }
  87893. declare module BABYLON {
  87894. /** @hidden */
  87895. export var clipPlaneFragment: {
  87896. name: string;
  87897. shader: string;
  87898. };
  87899. }
  87900. declare module BABYLON {
  87901. /** @hidden */
  87902. export var particlesPixelShader: {
  87903. name: string;
  87904. shader: string;
  87905. };
  87906. }
  87907. declare module BABYLON {
  87908. /** @hidden */
  87909. export var clipPlaneVertexDeclaration: {
  87910. name: string;
  87911. shader: string;
  87912. };
  87913. }
  87914. declare module BABYLON {
  87915. /** @hidden */
  87916. export var clipPlaneVertex: {
  87917. name: string;
  87918. shader: string;
  87919. };
  87920. }
  87921. declare module BABYLON {
  87922. /** @hidden */
  87923. export var particlesVertexShader: {
  87924. name: string;
  87925. shader: string;
  87926. };
  87927. }
  87928. declare module BABYLON {
  87929. /**
  87930. * This represents a particle system in Babylon.
  87931. * 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.
  87932. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87933. * @example https://doc.babylonjs.com/babylon101/particles
  87934. */
  87935. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87936. /**
  87937. * Billboard mode will only apply to Y axis
  87938. */
  87939. static readonly BILLBOARDMODE_Y: number;
  87940. /**
  87941. * Billboard mode will apply to all axes
  87942. */
  87943. static readonly BILLBOARDMODE_ALL: number;
  87944. /**
  87945. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87946. */
  87947. static readonly BILLBOARDMODE_STRETCHED: number;
  87948. /**
  87949. * This function can be defined to provide custom update for active particles.
  87950. * This function will be called instead of regular update (age, position, color, etc.).
  87951. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87952. */
  87953. updateFunction: (particles: Particle[]) => void;
  87954. private _emitterWorldMatrix;
  87955. /**
  87956. * This function can be defined to specify initial direction for every new particle.
  87957. * It by default use the emitterType defined function
  87958. */
  87959. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  87960. /**
  87961. * This function can be defined to specify initial position for every new particle.
  87962. * It by default use the emitterType defined function
  87963. */
  87964. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  87965. /**
  87966. * @hidden
  87967. */
  87968. _inheritedVelocityOffset: Vector3;
  87969. /**
  87970. * An event triggered when the system is disposed
  87971. */
  87972. onDisposeObservable: Observable<ParticleSystem>;
  87973. private _onDisposeObserver;
  87974. /**
  87975. * Sets a callback that will be triggered when the system is disposed
  87976. */
  87977. set onDispose(callback: () => void);
  87978. private _particles;
  87979. private _epsilon;
  87980. private _capacity;
  87981. private _stockParticles;
  87982. private _newPartsExcess;
  87983. private _vertexData;
  87984. private _vertexBuffer;
  87985. private _vertexBuffers;
  87986. private _spriteBuffer;
  87987. private _indexBuffer;
  87988. private _effect;
  87989. private _customEffect;
  87990. private _cachedDefines;
  87991. private _scaledColorStep;
  87992. private _colorDiff;
  87993. private _scaledDirection;
  87994. private _scaledGravity;
  87995. private _currentRenderId;
  87996. private _alive;
  87997. private _useInstancing;
  87998. private _started;
  87999. private _stopped;
  88000. private _actualFrame;
  88001. private _scaledUpdateSpeed;
  88002. private _vertexBufferSize;
  88003. /** @hidden */
  88004. _currentEmitRateGradient: Nullable<FactorGradient>;
  88005. /** @hidden */
  88006. _currentEmitRate1: number;
  88007. /** @hidden */
  88008. _currentEmitRate2: number;
  88009. /** @hidden */
  88010. _currentStartSizeGradient: Nullable<FactorGradient>;
  88011. /** @hidden */
  88012. _currentStartSize1: number;
  88013. /** @hidden */
  88014. _currentStartSize2: number;
  88015. private readonly _rawTextureWidth;
  88016. private _rampGradientsTexture;
  88017. private _useRampGradients;
  88018. /** Gets or sets a boolean indicating that ramp gradients must be used
  88019. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88020. */
  88021. get useRampGradients(): boolean;
  88022. set useRampGradients(value: boolean);
  88023. /**
  88024. * 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.
  88025. * 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: [])
  88026. */
  88027. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88028. private _subEmitters;
  88029. /**
  88030. * @hidden
  88031. * If the particle systems emitter should be disposed when the particle system is disposed
  88032. */
  88033. _disposeEmitterOnDispose: boolean;
  88034. /**
  88035. * The current active Sub-systems, this property is used by the root particle system only.
  88036. */
  88037. activeSubSystems: Array<ParticleSystem>;
  88038. private _rootParticleSystem;
  88039. /**
  88040. * Gets the current list of active particles
  88041. */
  88042. get particles(): Particle[];
  88043. /**
  88044. * Returns the string "ParticleSystem"
  88045. * @returns a string containing the class name
  88046. */
  88047. getClassName(): string;
  88048. /**
  88049. * Instantiates a particle system.
  88050. * 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.
  88051. * @param name The name of the particle system
  88052. * @param capacity The max number of particles alive at the same time
  88053. * @param scene The scene the particle system belongs to
  88054. * @param customEffect a custom effect used to change the way particles are rendered by default
  88055. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88056. * @param epsilon Offset used to render the particles
  88057. */
  88058. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88059. private _addFactorGradient;
  88060. private _removeFactorGradient;
  88061. /**
  88062. * Adds a new life time gradient
  88063. * @param gradient defines the gradient to use (between 0 and 1)
  88064. * @param factor defines the life time factor to affect to the specified gradient
  88065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88066. * @returns the current particle system
  88067. */
  88068. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88069. /**
  88070. * Remove a specific life time gradient
  88071. * @param gradient defines the gradient to remove
  88072. * @returns the current particle system
  88073. */
  88074. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88075. /**
  88076. * Adds a new size gradient
  88077. * @param gradient defines the gradient to use (between 0 and 1)
  88078. * @param factor defines the size factor to affect to the specified gradient
  88079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88080. * @returns the current particle system
  88081. */
  88082. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88083. /**
  88084. * Remove a specific size gradient
  88085. * @param gradient defines the gradient to remove
  88086. * @returns the current particle system
  88087. */
  88088. removeSizeGradient(gradient: number): IParticleSystem;
  88089. /**
  88090. * Adds a new color remap gradient
  88091. * @param gradient defines the gradient to use (between 0 and 1)
  88092. * @param min defines the color remap minimal range
  88093. * @param max defines the color remap maximal range
  88094. * @returns the current particle system
  88095. */
  88096. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88097. /**
  88098. * Remove a specific color remap gradient
  88099. * @param gradient defines the gradient to remove
  88100. * @returns the current particle system
  88101. */
  88102. removeColorRemapGradient(gradient: number): IParticleSystem;
  88103. /**
  88104. * Adds a new alpha remap gradient
  88105. * @param gradient defines the gradient to use (between 0 and 1)
  88106. * @param min defines the alpha remap minimal range
  88107. * @param max defines the alpha remap maximal range
  88108. * @returns the current particle system
  88109. */
  88110. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88111. /**
  88112. * Remove a specific alpha remap gradient
  88113. * @param gradient defines the gradient to remove
  88114. * @returns the current particle system
  88115. */
  88116. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88117. /**
  88118. * Adds a new angular speed gradient
  88119. * @param gradient defines the gradient to use (between 0 and 1)
  88120. * @param factor defines the angular speed to affect to the specified gradient
  88121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88122. * @returns the current particle system
  88123. */
  88124. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88125. /**
  88126. * Remove a specific angular speed gradient
  88127. * @param gradient defines the gradient to remove
  88128. * @returns the current particle system
  88129. */
  88130. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88131. /**
  88132. * Adds a new velocity gradient
  88133. * @param gradient defines the gradient to use (between 0 and 1)
  88134. * @param factor defines the velocity to affect to the specified gradient
  88135. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88136. * @returns the current particle system
  88137. */
  88138. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88139. /**
  88140. * Remove a specific velocity gradient
  88141. * @param gradient defines the gradient to remove
  88142. * @returns the current particle system
  88143. */
  88144. removeVelocityGradient(gradient: number): IParticleSystem;
  88145. /**
  88146. * Adds a new limit velocity gradient
  88147. * @param gradient defines the gradient to use (between 0 and 1)
  88148. * @param factor defines the limit velocity value to affect to the specified gradient
  88149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88150. * @returns the current particle system
  88151. */
  88152. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88153. /**
  88154. * Remove a specific limit velocity gradient
  88155. * @param gradient defines the gradient to remove
  88156. * @returns the current particle system
  88157. */
  88158. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88159. /**
  88160. * Adds a new drag gradient
  88161. * @param gradient defines the gradient to use (between 0 and 1)
  88162. * @param factor defines the drag value to affect to the specified gradient
  88163. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88164. * @returns the current particle system
  88165. */
  88166. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88167. /**
  88168. * Remove a specific drag gradient
  88169. * @param gradient defines the gradient to remove
  88170. * @returns the current particle system
  88171. */
  88172. removeDragGradient(gradient: number): IParticleSystem;
  88173. /**
  88174. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88175. * @param gradient defines the gradient to use (between 0 and 1)
  88176. * @param factor defines the emit rate value to affect to the specified gradient
  88177. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88178. * @returns the current particle system
  88179. */
  88180. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88181. /**
  88182. * Remove a specific emit rate gradient
  88183. * @param gradient defines the gradient to remove
  88184. * @returns the current particle system
  88185. */
  88186. removeEmitRateGradient(gradient: number): IParticleSystem;
  88187. /**
  88188. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88189. * @param gradient defines the gradient to use (between 0 and 1)
  88190. * @param factor defines the start size value to affect to the specified gradient
  88191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88192. * @returns the current particle system
  88193. */
  88194. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88195. /**
  88196. * Remove a specific start size gradient
  88197. * @param gradient defines the gradient to remove
  88198. * @returns the current particle system
  88199. */
  88200. removeStartSizeGradient(gradient: number): IParticleSystem;
  88201. private _createRampGradientTexture;
  88202. /**
  88203. * Gets the current list of ramp gradients.
  88204. * You must use addRampGradient and removeRampGradient to udpate this list
  88205. * @returns the list of ramp gradients
  88206. */
  88207. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88208. /**
  88209. * Adds a new ramp gradient used to remap particle colors
  88210. * @param gradient defines the gradient to use (between 0 and 1)
  88211. * @param color defines the color to affect to the specified gradient
  88212. * @returns the current particle system
  88213. */
  88214. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88215. /**
  88216. * Remove a specific ramp gradient
  88217. * @param gradient defines the gradient to remove
  88218. * @returns the current particle system
  88219. */
  88220. removeRampGradient(gradient: number): ParticleSystem;
  88221. /**
  88222. * Adds a new color gradient
  88223. * @param gradient defines the gradient to use (between 0 and 1)
  88224. * @param color1 defines the color to affect to the specified gradient
  88225. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88226. * @returns this particle system
  88227. */
  88228. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88229. /**
  88230. * Remove a specific color gradient
  88231. * @param gradient defines the gradient to remove
  88232. * @returns this particle system
  88233. */
  88234. removeColorGradient(gradient: number): IParticleSystem;
  88235. private _fetchR;
  88236. protected _reset(): void;
  88237. private _resetEffect;
  88238. private _createVertexBuffers;
  88239. private _createIndexBuffer;
  88240. /**
  88241. * Gets the maximum number of particles active at the same time.
  88242. * @returns The max number of active particles.
  88243. */
  88244. getCapacity(): number;
  88245. /**
  88246. * Gets whether there are still active particles in the system.
  88247. * @returns True if it is alive, otherwise false.
  88248. */
  88249. isAlive(): boolean;
  88250. /**
  88251. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88252. * @returns True if it has been started, otherwise false.
  88253. */
  88254. isStarted(): boolean;
  88255. private _prepareSubEmitterInternalArray;
  88256. /**
  88257. * Starts the particle system and begins to emit
  88258. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88259. */
  88260. start(delay?: number): void;
  88261. /**
  88262. * Stops the particle system.
  88263. * @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.
  88264. */
  88265. stop(stopSubEmitters?: boolean): void;
  88266. /**
  88267. * Remove all active particles
  88268. */
  88269. reset(): void;
  88270. /**
  88271. * @hidden (for internal use only)
  88272. */
  88273. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88274. /**
  88275. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88276. * Its lifetime will start back at 0.
  88277. */
  88278. recycleParticle: (particle: Particle) => void;
  88279. private _stopSubEmitters;
  88280. private _createParticle;
  88281. private _removeFromRoot;
  88282. private _emitFromParticle;
  88283. private _update;
  88284. /** @hidden */
  88285. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88286. /** @hidden */
  88287. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88288. /** @hidden */
  88289. private _getEffect;
  88290. /**
  88291. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88292. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88293. */
  88294. animate(preWarmOnly?: boolean): void;
  88295. private _appendParticleVertices;
  88296. /**
  88297. * Rebuilds the particle system.
  88298. */
  88299. rebuild(): void;
  88300. /**
  88301. * Is this system ready to be used/rendered
  88302. * @return true if the system is ready
  88303. */
  88304. isReady(): boolean;
  88305. private _render;
  88306. /**
  88307. * Renders the particle system in its current state.
  88308. * @returns the current number of particles
  88309. */
  88310. render(): number;
  88311. /**
  88312. * Disposes the particle system and free the associated resources
  88313. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88314. */
  88315. dispose(disposeTexture?: boolean): void;
  88316. /**
  88317. * Clones the particle system.
  88318. * @param name The name of the cloned object
  88319. * @param newEmitter The new emitter to use
  88320. * @returns the cloned particle system
  88321. */
  88322. clone(name: string, newEmitter: any): ParticleSystem;
  88323. /**
  88324. * Serializes the particle system to a JSON object.
  88325. * @returns the JSON object
  88326. */
  88327. serialize(): any;
  88328. /** @hidden */
  88329. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  88330. /** @hidden */
  88331. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88332. /**
  88333. * Parses a JSON object to create a particle system.
  88334. * @param parsedParticleSystem The JSON object to parse
  88335. * @param scene The scene to create the particle system in
  88336. * @param rootUrl The root url to use to load external dependencies like texture
  88337. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88338. * @returns the Parsed particle system
  88339. */
  88340. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88341. }
  88342. }
  88343. declare module BABYLON {
  88344. /**
  88345. * A particle represents one of the element emitted by a particle system.
  88346. * This is mainly define by its coordinates, direction, velocity and age.
  88347. */
  88348. export class Particle {
  88349. /**
  88350. * The particle system the particle belongs to.
  88351. */
  88352. particleSystem: ParticleSystem;
  88353. private static _Count;
  88354. /**
  88355. * Unique ID of the particle
  88356. */
  88357. id: number;
  88358. /**
  88359. * The world position of the particle in the scene.
  88360. */
  88361. position: Vector3;
  88362. /**
  88363. * The world direction of the particle in the scene.
  88364. */
  88365. direction: Vector3;
  88366. /**
  88367. * The color of the particle.
  88368. */
  88369. color: Color4;
  88370. /**
  88371. * The color change of the particle per step.
  88372. */
  88373. colorStep: Color4;
  88374. /**
  88375. * Defines how long will the life of the particle be.
  88376. */
  88377. lifeTime: number;
  88378. /**
  88379. * The current age of the particle.
  88380. */
  88381. age: number;
  88382. /**
  88383. * The current size of the particle.
  88384. */
  88385. size: number;
  88386. /**
  88387. * The current scale of the particle.
  88388. */
  88389. scale: Vector2;
  88390. /**
  88391. * The current angle of the particle.
  88392. */
  88393. angle: number;
  88394. /**
  88395. * Defines how fast is the angle changing.
  88396. */
  88397. angularSpeed: number;
  88398. /**
  88399. * Defines the cell index used by the particle to be rendered from a sprite.
  88400. */
  88401. cellIndex: number;
  88402. /**
  88403. * The information required to support color remapping
  88404. */
  88405. remapData: Vector4;
  88406. /** @hidden */
  88407. _randomCellOffset?: number;
  88408. /** @hidden */
  88409. _initialDirection: Nullable<Vector3>;
  88410. /** @hidden */
  88411. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88412. /** @hidden */
  88413. _initialStartSpriteCellID: number;
  88414. /** @hidden */
  88415. _initialEndSpriteCellID: number;
  88416. /** @hidden */
  88417. _currentColorGradient: Nullable<ColorGradient>;
  88418. /** @hidden */
  88419. _currentColor1: Color4;
  88420. /** @hidden */
  88421. _currentColor2: Color4;
  88422. /** @hidden */
  88423. _currentSizeGradient: Nullable<FactorGradient>;
  88424. /** @hidden */
  88425. _currentSize1: number;
  88426. /** @hidden */
  88427. _currentSize2: number;
  88428. /** @hidden */
  88429. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88430. /** @hidden */
  88431. _currentAngularSpeed1: number;
  88432. /** @hidden */
  88433. _currentAngularSpeed2: number;
  88434. /** @hidden */
  88435. _currentVelocityGradient: Nullable<FactorGradient>;
  88436. /** @hidden */
  88437. _currentVelocity1: number;
  88438. /** @hidden */
  88439. _currentVelocity2: number;
  88440. /** @hidden */
  88441. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88442. /** @hidden */
  88443. _currentLimitVelocity1: number;
  88444. /** @hidden */
  88445. _currentLimitVelocity2: number;
  88446. /** @hidden */
  88447. _currentDragGradient: Nullable<FactorGradient>;
  88448. /** @hidden */
  88449. _currentDrag1: number;
  88450. /** @hidden */
  88451. _currentDrag2: number;
  88452. /** @hidden */
  88453. _randomNoiseCoordinates1: Vector3;
  88454. /** @hidden */
  88455. _randomNoiseCoordinates2: Vector3;
  88456. /**
  88457. * Creates a new instance Particle
  88458. * @param particleSystem the particle system the particle belongs to
  88459. */
  88460. constructor(
  88461. /**
  88462. * The particle system the particle belongs to.
  88463. */
  88464. particleSystem: ParticleSystem);
  88465. private updateCellInfoFromSystem;
  88466. /**
  88467. * Defines how the sprite cell index is updated for the particle
  88468. */
  88469. updateCellIndex(): void;
  88470. /** @hidden */
  88471. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88472. /** @hidden */
  88473. _inheritParticleInfoToSubEmitters(): void;
  88474. /** @hidden */
  88475. _reset(): void;
  88476. /**
  88477. * Copy the properties of particle to another one.
  88478. * @param other the particle to copy the information to.
  88479. */
  88480. copyTo(other: Particle): void;
  88481. }
  88482. }
  88483. declare module BABYLON {
  88484. /**
  88485. * Particle emitter represents a volume emitting particles.
  88486. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88487. */
  88488. export interface IParticleEmitterType {
  88489. /**
  88490. * Called by the particle System when the direction is computed for the created particle.
  88491. * @param worldMatrix is the world matrix of the particle system
  88492. * @param directionToUpdate is the direction vector to update with the result
  88493. * @param particle is the particle we are computed the direction for
  88494. */
  88495. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88496. /**
  88497. * Called by the particle System when the position is computed for the created particle.
  88498. * @param worldMatrix is the world matrix of the particle system
  88499. * @param positionToUpdate is the position vector to update with the result
  88500. * @param particle is the particle we are computed the position for
  88501. */
  88502. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88503. /**
  88504. * Clones the current emitter and returns a copy of it
  88505. * @returns the new emitter
  88506. */
  88507. clone(): IParticleEmitterType;
  88508. /**
  88509. * Called by the GPUParticleSystem to setup the update shader
  88510. * @param effect defines the update shader
  88511. */
  88512. applyToShader(effect: Effect): void;
  88513. /**
  88514. * Returns a string to use to update the GPU particles update shader
  88515. * @returns the effect defines string
  88516. */
  88517. getEffectDefines(): string;
  88518. /**
  88519. * Returns a string representing the class name
  88520. * @returns a string containing the class name
  88521. */
  88522. getClassName(): string;
  88523. /**
  88524. * Serializes the particle system to a JSON object.
  88525. * @returns the JSON object
  88526. */
  88527. serialize(): any;
  88528. /**
  88529. * Parse properties from a JSON object
  88530. * @param serializationObject defines the JSON object
  88531. */
  88532. parse(serializationObject: any): void;
  88533. }
  88534. }
  88535. declare module BABYLON {
  88536. /**
  88537. * Particle emitter emitting particles from the inside of a box.
  88538. * It emits the particles randomly between 2 given directions.
  88539. */
  88540. export class BoxParticleEmitter implements IParticleEmitterType {
  88541. /**
  88542. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88543. */
  88544. direction1: Vector3;
  88545. /**
  88546. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88547. */
  88548. direction2: Vector3;
  88549. /**
  88550. * 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.
  88551. */
  88552. minEmitBox: Vector3;
  88553. /**
  88554. * 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.
  88555. */
  88556. maxEmitBox: Vector3;
  88557. /**
  88558. * Creates a new instance BoxParticleEmitter
  88559. */
  88560. constructor();
  88561. /**
  88562. * Called by the particle System when the direction is computed for the created particle.
  88563. * @param worldMatrix is the world matrix of the particle system
  88564. * @param directionToUpdate is the direction vector to update with the result
  88565. * @param particle is the particle we are computed the direction for
  88566. */
  88567. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88568. /**
  88569. * Called by the particle System when the position is computed for the created particle.
  88570. * @param worldMatrix is the world matrix of the particle system
  88571. * @param positionToUpdate is the position vector to update with the result
  88572. * @param particle is the particle we are computed the position for
  88573. */
  88574. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88575. /**
  88576. * Clones the current emitter and returns a copy of it
  88577. * @returns the new emitter
  88578. */
  88579. clone(): BoxParticleEmitter;
  88580. /**
  88581. * Called by the GPUParticleSystem to setup the update shader
  88582. * @param effect defines the update shader
  88583. */
  88584. applyToShader(effect: Effect): void;
  88585. /**
  88586. * Returns a string to use to update the GPU particles update shader
  88587. * @returns a string containng the defines string
  88588. */
  88589. getEffectDefines(): string;
  88590. /**
  88591. * Returns the string "BoxParticleEmitter"
  88592. * @returns a string containing the class name
  88593. */
  88594. getClassName(): string;
  88595. /**
  88596. * Serializes the particle system to a JSON object.
  88597. * @returns the JSON object
  88598. */
  88599. serialize(): any;
  88600. /**
  88601. * Parse properties from a JSON object
  88602. * @param serializationObject defines the JSON object
  88603. */
  88604. parse(serializationObject: any): void;
  88605. }
  88606. }
  88607. declare module BABYLON {
  88608. /**
  88609. * Particle emitter emitting particles from the inside of a cone.
  88610. * It emits the particles alongside the cone volume from the base to the particle.
  88611. * The emission direction might be randomized.
  88612. */
  88613. export class ConeParticleEmitter implements IParticleEmitterType {
  88614. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88615. directionRandomizer: number;
  88616. private _radius;
  88617. private _angle;
  88618. private _height;
  88619. /**
  88620. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88621. */
  88622. radiusRange: number;
  88623. /**
  88624. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88625. */
  88626. heightRange: number;
  88627. /**
  88628. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88629. */
  88630. emitFromSpawnPointOnly: boolean;
  88631. /**
  88632. * Gets or sets the radius of the emission cone
  88633. */
  88634. get radius(): number;
  88635. set radius(value: number);
  88636. /**
  88637. * Gets or sets the angle of the emission cone
  88638. */
  88639. get angle(): number;
  88640. set angle(value: number);
  88641. private _buildHeight;
  88642. /**
  88643. * Creates a new instance ConeParticleEmitter
  88644. * @param radius the radius of the emission cone (1 by default)
  88645. * @param angle the cone base angle (PI by default)
  88646. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88647. */
  88648. constructor(radius?: number, angle?: number,
  88649. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88650. directionRandomizer?: number);
  88651. /**
  88652. * Called by the particle System when the direction is computed for the created particle.
  88653. * @param worldMatrix is the world matrix of the particle system
  88654. * @param directionToUpdate is the direction vector to update with the result
  88655. * @param particle is the particle we are computed the direction for
  88656. */
  88657. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88658. /**
  88659. * Called by the particle System when the position is computed for the created particle.
  88660. * @param worldMatrix is the world matrix of the particle system
  88661. * @param positionToUpdate is the position vector to update with the result
  88662. * @param particle is the particle we are computed the position for
  88663. */
  88664. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88665. /**
  88666. * Clones the current emitter and returns a copy of it
  88667. * @returns the new emitter
  88668. */
  88669. clone(): ConeParticleEmitter;
  88670. /**
  88671. * Called by the GPUParticleSystem to setup the update shader
  88672. * @param effect defines the update shader
  88673. */
  88674. applyToShader(effect: Effect): void;
  88675. /**
  88676. * Returns a string to use to update the GPU particles update shader
  88677. * @returns a string containng the defines string
  88678. */
  88679. getEffectDefines(): string;
  88680. /**
  88681. * Returns the string "ConeParticleEmitter"
  88682. * @returns a string containing the class name
  88683. */
  88684. getClassName(): string;
  88685. /**
  88686. * Serializes the particle system to a JSON object.
  88687. * @returns the JSON object
  88688. */
  88689. serialize(): any;
  88690. /**
  88691. * Parse properties from a JSON object
  88692. * @param serializationObject defines the JSON object
  88693. */
  88694. parse(serializationObject: any): void;
  88695. }
  88696. }
  88697. declare module BABYLON {
  88698. /**
  88699. * Particle emitter emitting particles from the inside of a cylinder.
  88700. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88701. */
  88702. export class CylinderParticleEmitter implements IParticleEmitterType {
  88703. /**
  88704. * The radius of the emission cylinder.
  88705. */
  88706. radius: number;
  88707. /**
  88708. * The height of the emission cylinder.
  88709. */
  88710. height: number;
  88711. /**
  88712. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88713. */
  88714. radiusRange: number;
  88715. /**
  88716. * How much to randomize the particle direction [0-1].
  88717. */
  88718. directionRandomizer: number;
  88719. /**
  88720. * Creates a new instance CylinderParticleEmitter
  88721. * @param radius the radius of the emission cylinder (1 by default)
  88722. * @param height the height of the emission cylinder (1 by default)
  88723. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88724. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88725. */
  88726. constructor(
  88727. /**
  88728. * The radius of the emission cylinder.
  88729. */
  88730. radius?: number,
  88731. /**
  88732. * The height of the emission cylinder.
  88733. */
  88734. height?: number,
  88735. /**
  88736. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88737. */
  88738. radiusRange?: number,
  88739. /**
  88740. * How much to randomize the particle direction [0-1].
  88741. */
  88742. directionRandomizer?: number);
  88743. /**
  88744. * Called by the particle System when the direction is computed for the created particle.
  88745. * @param worldMatrix is the world matrix of the particle system
  88746. * @param directionToUpdate is the direction vector to update with the result
  88747. * @param particle is the particle we are computed the direction for
  88748. */
  88749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88750. /**
  88751. * Called by the particle System when the position is computed for the created particle.
  88752. * @param worldMatrix is the world matrix of the particle system
  88753. * @param positionToUpdate is the position vector to update with the result
  88754. * @param particle is the particle we are computed the position for
  88755. */
  88756. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88757. /**
  88758. * Clones the current emitter and returns a copy of it
  88759. * @returns the new emitter
  88760. */
  88761. clone(): CylinderParticleEmitter;
  88762. /**
  88763. * Called by the GPUParticleSystem to setup the update shader
  88764. * @param effect defines the update shader
  88765. */
  88766. applyToShader(effect: Effect): void;
  88767. /**
  88768. * Returns a string to use to update the GPU particles update shader
  88769. * @returns a string containng the defines string
  88770. */
  88771. getEffectDefines(): string;
  88772. /**
  88773. * Returns the string "CylinderParticleEmitter"
  88774. * @returns a string containing the class name
  88775. */
  88776. getClassName(): string;
  88777. /**
  88778. * Serializes the particle system to a JSON object.
  88779. * @returns the JSON object
  88780. */
  88781. serialize(): any;
  88782. /**
  88783. * Parse properties from a JSON object
  88784. * @param serializationObject defines the JSON object
  88785. */
  88786. parse(serializationObject: any): void;
  88787. }
  88788. /**
  88789. * Particle emitter emitting particles from the inside of a cylinder.
  88790. * It emits the particles randomly between two vectors.
  88791. */
  88792. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88793. /**
  88794. * The min limit of the emission direction.
  88795. */
  88796. direction1: Vector3;
  88797. /**
  88798. * The max limit of the emission direction.
  88799. */
  88800. direction2: Vector3;
  88801. /**
  88802. * Creates a new instance CylinderDirectedParticleEmitter
  88803. * @param radius the radius of the emission cylinder (1 by default)
  88804. * @param height the height of the emission cylinder (1 by default)
  88805. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88806. * @param direction1 the min limit of the emission direction (up vector by default)
  88807. * @param direction2 the max limit of the emission direction (up vector by default)
  88808. */
  88809. constructor(radius?: number, height?: number, radiusRange?: number,
  88810. /**
  88811. * The min limit of the emission direction.
  88812. */
  88813. direction1?: Vector3,
  88814. /**
  88815. * The max limit of the emission direction.
  88816. */
  88817. direction2?: Vector3);
  88818. /**
  88819. * Called by the particle System when the direction is computed for the created particle.
  88820. * @param worldMatrix is the world matrix of the particle system
  88821. * @param directionToUpdate is the direction vector to update with the result
  88822. * @param particle is the particle we are computed the direction for
  88823. */
  88824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88825. /**
  88826. * Clones the current emitter and returns a copy of it
  88827. * @returns the new emitter
  88828. */
  88829. clone(): CylinderDirectedParticleEmitter;
  88830. /**
  88831. * Called by the GPUParticleSystem to setup the update shader
  88832. * @param effect defines the update shader
  88833. */
  88834. applyToShader(effect: Effect): void;
  88835. /**
  88836. * Returns a string to use to update the GPU particles update shader
  88837. * @returns a string containng the defines string
  88838. */
  88839. getEffectDefines(): string;
  88840. /**
  88841. * Returns the string "CylinderDirectedParticleEmitter"
  88842. * @returns a string containing the class name
  88843. */
  88844. getClassName(): string;
  88845. /**
  88846. * Serializes the particle system to a JSON object.
  88847. * @returns the JSON object
  88848. */
  88849. serialize(): any;
  88850. /**
  88851. * Parse properties from a JSON object
  88852. * @param serializationObject defines the JSON object
  88853. */
  88854. parse(serializationObject: any): void;
  88855. }
  88856. }
  88857. declare module BABYLON {
  88858. /**
  88859. * Particle emitter emitting particles from the inside of a hemisphere.
  88860. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88861. */
  88862. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88863. /**
  88864. * The radius of the emission hemisphere.
  88865. */
  88866. radius: number;
  88867. /**
  88868. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88869. */
  88870. radiusRange: number;
  88871. /**
  88872. * How much to randomize the particle direction [0-1].
  88873. */
  88874. directionRandomizer: number;
  88875. /**
  88876. * Creates a new instance HemisphericParticleEmitter
  88877. * @param radius the radius of the emission hemisphere (1 by default)
  88878. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88879. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88880. */
  88881. constructor(
  88882. /**
  88883. * The radius of the emission hemisphere.
  88884. */
  88885. radius?: number,
  88886. /**
  88887. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88888. */
  88889. radiusRange?: number,
  88890. /**
  88891. * How much to randomize the particle direction [0-1].
  88892. */
  88893. directionRandomizer?: number);
  88894. /**
  88895. * Called by the particle System when the direction is computed for the created particle.
  88896. * @param worldMatrix is the world matrix of the particle system
  88897. * @param directionToUpdate is the direction vector to update with the result
  88898. * @param particle is the particle we are computed the direction for
  88899. */
  88900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88901. /**
  88902. * Called by the particle System when the position is computed for the created particle.
  88903. * @param worldMatrix is the world matrix of the particle system
  88904. * @param positionToUpdate is the position vector to update with the result
  88905. * @param particle is the particle we are computed the position for
  88906. */
  88907. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88908. /**
  88909. * Clones the current emitter and returns a copy of it
  88910. * @returns the new emitter
  88911. */
  88912. clone(): HemisphericParticleEmitter;
  88913. /**
  88914. * Called by the GPUParticleSystem to setup the update shader
  88915. * @param effect defines the update shader
  88916. */
  88917. applyToShader(effect: Effect): void;
  88918. /**
  88919. * Returns a string to use to update the GPU particles update shader
  88920. * @returns a string containng the defines string
  88921. */
  88922. getEffectDefines(): string;
  88923. /**
  88924. * Returns the string "HemisphericParticleEmitter"
  88925. * @returns a string containing the class name
  88926. */
  88927. getClassName(): string;
  88928. /**
  88929. * Serializes the particle system to a JSON object.
  88930. * @returns the JSON object
  88931. */
  88932. serialize(): any;
  88933. /**
  88934. * Parse properties from a JSON object
  88935. * @param serializationObject defines the JSON object
  88936. */
  88937. parse(serializationObject: any): void;
  88938. }
  88939. }
  88940. declare module BABYLON {
  88941. /**
  88942. * Particle emitter emitting particles from a point.
  88943. * It emits the particles randomly between 2 given directions.
  88944. */
  88945. export class PointParticleEmitter implements IParticleEmitterType {
  88946. /**
  88947. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88948. */
  88949. direction1: Vector3;
  88950. /**
  88951. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88952. */
  88953. direction2: Vector3;
  88954. /**
  88955. * Creates a new instance PointParticleEmitter
  88956. */
  88957. constructor();
  88958. /**
  88959. * Called by the particle System when the direction is computed for the created particle.
  88960. * @param worldMatrix is the world matrix of the particle system
  88961. * @param directionToUpdate is the direction vector to update with the result
  88962. * @param particle is the particle we are computed the direction for
  88963. */
  88964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88965. /**
  88966. * Called by the particle System when the position is computed for the created particle.
  88967. * @param worldMatrix is the world matrix of the particle system
  88968. * @param positionToUpdate is the position vector to update with the result
  88969. * @param particle is the particle we are computed the position for
  88970. */
  88971. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88972. /**
  88973. * Clones the current emitter and returns a copy of it
  88974. * @returns the new emitter
  88975. */
  88976. clone(): PointParticleEmitter;
  88977. /**
  88978. * Called by the GPUParticleSystem to setup the update shader
  88979. * @param effect defines the update shader
  88980. */
  88981. applyToShader(effect: Effect): void;
  88982. /**
  88983. * Returns a string to use to update the GPU particles update shader
  88984. * @returns a string containng the defines string
  88985. */
  88986. getEffectDefines(): string;
  88987. /**
  88988. * Returns the string "PointParticleEmitter"
  88989. * @returns a string containing the class name
  88990. */
  88991. getClassName(): string;
  88992. /**
  88993. * Serializes the particle system to a JSON object.
  88994. * @returns the JSON object
  88995. */
  88996. serialize(): any;
  88997. /**
  88998. * Parse properties from a JSON object
  88999. * @param serializationObject defines the JSON object
  89000. */
  89001. parse(serializationObject: any): void;
  89002. }
  89003. }
  89004. declare module BABYLON {
  89005. /**
  89006. * Particle emitter emitting particles from the inside of a sphere.
  89007. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  89008. */
  89009. export class SphereParticleEmitter implements IParticleEmitterType {
  89010. /**
  89011. * The radius of the emission sphere.
  89012. */
  89013. radius: number;
  89014. /**
  89015. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89016. */
  89017. radiusRange: number;
  89018. /**
  89019. * How much to randomize the particle direction [0-1].
  89020. */
  89021. directionRandomizer: number;
  89022. /**
  89023. * Creates a new instance SphereParticleEmitter
  89024. * @param radius the radius of the emission sphere (1 by default)
  89025. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89026. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89027. */
  89028. constructor(
  89029. /**
  89030. * The radius of the emission sphere.
  89031. */
  89032. radius?: number,
  89033. /**
  89034. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89035. */
  89036. radiusRange?: number,
  89037. /**
  89038. * How much to randomize the particle direction [0-1].
  89039. */
  89040. directionRandomizer?: number);
  89041. /**
  89042. * Called by the particle System when the direction is computed for the created particle.
  89043. * @param worldMatrix is the world matrix of the particle system
  89044. * @param directionToUpdate is the direction vector to update with the result
  89045. * @param particle is the particle we are computed the direction for
  89046. */
  89047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89048. /**
  89049. * Called by the particle System when the position is computed for the created particle.
  89050. * @param worldMatrix is the world matrix of the particle system
  89051. * @param positionToUpdate is the position vector to update with the result
  89052. * @param particle is the particle we are computed the position for
  89053. */
  89054. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89055. /**
  89056. * Clones the current emitter and returns a copy of it
  89057. * @returns the new emitter
  89058. */
  89059. clone(): SphereParticleEmitter;
  89060. /**
  89061. * Called by the GPUParticleSystem to setup the update shader
  89062. * @param effect defines the update shader
  89063. */
  89064. applyToShader(effect: Effect): void;
  89065. /**
  89066. * Returns a string to use to update the GPU particles update shader
  89067. * @returns a string containng the defines string
  89068. */
  89069. getEffectDefines(): string;
  89070. /**
  89071. * Returns the string "SphereParticleEmitter"
  89072. * @returns a string containing the class name
  89073. */
  89074. getClassName(): string;
  89075. /**
  89076. * Serializes the particle system to a JSON object.
  89077. * @returns the JSON object
  89078. */
  89079. serialize(): any;
  89080. /**
  89081. * Parse properties from a JSON object
  89082. * @param serializationObject defines the JSON object
  89083. */
  89084. parse(serializationObject: any): void;
  89085. }
  89086. /**
  89087. * Particle emitter emitting particles from the inside of a sphere.
  89088. * It emits the particles randomly between two vectors.
  89089. */
  89090. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89091. /**
  89092. * The min limit of the emission direction.
  89093. */
  89094. direction1: Vector3;
  89095. /**
  89096. * The max limit of the emission direction.
  89097. */
  89098. direction2: Vector3;
  89099. /**
  89100. * Creates a new instance SphereDirectedParticleEmitter
  89101. * @param radius the radius of the emission sphere (1 by default)
  89102. * @param direction1 the min limit of the emission direction (up vector by default)
  89103. * @param direction2 the max limit of the emission direction (up vector by default)
  89104. */
  89105. constructor(radius?: number,
  89106. /**
  89107. * The min limit of the emission direction.
  89108. */
  89109. direction1?: Vector3,
  89110. /**
  89111. * The max limit of the emission direction.
  89112. */
  89113. direction2?: Vector3);
  89114. /**
  89115. * Called by the particle System when the direction is computed for the created particle.
  89116. * @param worldMatrix is the world matrix of the particle system
  89117. * @param directionToUpdate is the direction vector to update with the result
  89118. * @param particle is the particle we are computed the direction for
  89119. */
  89120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89121. /**
  89122. * Clones the current emitter and returns a copy of it
  89123. * @returns the new emitter
  89124. */
  89125. clone(): SphereDirectedParticleEmitter;
  89126. /**
  89127. * Called by the GPUParticleSystem to setup the update shader
  89128. * @param effect defines the update shader
  89129. */
  89130. applyToShader(effect: Effect): void;
  89131. /**
  89132. * Returns a string to use to update the GPU particles update shader
  89133. * @returns a string containng the defines string
  89134. */
  89135. getEffectDefines(): string;
  89136. /**
  89137. * Returns the string "SphereDirectedParticleEmitter"
  89138. * @returns a string containing the class name
  89139. */
  89140. getClassName(): string;
  89141. /**
  89142. * Serializes the particle system to a JSON object.
  89143. * @returns the JSON object
  89144. */
  89145. serialize(): any;
  89146. /**
  89147. * Parse properties from a JSON object
  89148. * @param serializationObject defines the JSON object
  89149. */
  89150. parse(serializationObject: any): void;
  89151. }
  89152. }
  89153. declare module BABYLON {
  89154. /**
  89155. * Interface representing a particle system in Babylon.js.
  89156. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89157. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89158. */
  89159. export interface IParticleSystem {
  89160. /**
  89161. * List of animations used by the particle system.
  89162. */
  89163. animations: Animation[];
  89164. /**
  89165. * The id of the Particle system.
  89166. */
  89167. id: string;
  89168. /**
  89169. * The name of the Particle system.
  89170. */
  89171. name: string;
  89172. /**
  89173. * The emitter represents the Mesh or position we are attaching the particle system to.
  89174. */
  89175. emitter: Nullable<AbstractMesh | Vector3>;
  89176. /**
  89177. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89178. */
  89179. isBillboardBased: boolean;
  89180. /**
  89181. * The rendering group used by the Particle system to chose when to render.
  89182. */
  89183. renderingGroupId: number;
  89184. /**
  89185. * The layer mask we are rendering the particles through.
  89186. */
  89187. layerMask: number;
  89188. /**
  89189. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89190. */
  89191. updateSpeed: number;
  89192. /**
  89193. * The amount of time the particle system is running (depends of the overall update speed).
  89194. */
  89195. targetStopDuration: number;
  89196. /**
  89197. * The texture used to render each particle. (this can be a spritesheet)
  89198. */
  89199. particleTexture: Nullable<Texture>;
  89200. /**
  89201. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89202. */
  89203. blendMode: number;
  89204. /**
  89205. * Minimum life time of emitting particles.
  89206. */
  89207. minLifeTime: number;
  89208. /**
  89209. * Maximum life time of emitting particles.
  89210. */
  89211. maxLifeTime: number;
  89212. /**
  89213. * Minimum Size of emitting particles.
  89214. */
  89215. minSize: number;
  89216. /**
  89217. * Maximum Size of emitting particles.
  89218. */
  89219. maxSize: number;
  89220. /**
  89221. * Minimum scale of emitting particles on X axis.
  89222. */
  89223. minScaleX: number;
  89224. /**
  89225. * Maximum scale of emitting particles on X axis.
  89226. */
  89227. maxScaleX: number;
  89228. /**
  89229. * Minimum scale of emitting particles on Y axis.
  89230. */
  89231. minScaleY: number;
  89232. /**
  89233. * Maximum scale of emitting particles on Y axis.
  89234. */
  89235. maxScaleY: number;
  89236. /**
  89237. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89238. */
  89239. color1: Color4;
  89240. /**
  89241. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89242. */
  89243. color2: Color4;
  89244. /**
  89245. * Color the particle will have at the end of its lifetime.
  89246. */
  89247. colorDead: Color4;
  89248. /**
  89249. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89250. */
  89251. emitRate: number;
  89252. /**
  89253. * You can use gravity if you want to give an orientation to your particles.
  89254. */
  89255. gravity: Vector3;
  89256. /**
  89257. * Minimum power of emitting particles.
  89258. */
  89259. minEmitPower: number;
  89260. /**
  89261. * Maximum power of emitting particles.
  89262. */
  89263. maxEmitPower: number;
  89264. /**
  89265. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89266. */
  89267. minAngularSpeed: number;
  89268. /**
  89269. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89270. */
  89271. maxAngularSpeed: number;
  89272. /**
  89273. * Gets or sets the minimal initial rotation in radians.
  89274. */
  89275. minInitialRotation: number;
  89276. /**
  89277. * Gets or sets the maximal initial rotation in radians.
  89278. */
  89279. maxInitialRotation: number;
  89280. /**
  89281. * The particle emitter type defines the emitter used by the particle system.
  89282. * It can be for example box, sphere, or cone...
  89283. */
  89284. particleEmitterType: Nullable<IParticleEmitterType>;
  89285. /**
  89286. * Defines the delay in milliseconds before starting the system (0 by default)
  89287. */
  89288. startDelay: number;
  89289. /**
  89290. * 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
  89291. */
  89292. preWarmCycles: number;
  89293. /**
  89294. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89295. */
  89296. preWarmStepOffset: number;
  89297. /**
  89298. * 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)
  89299. */
  89300. spriteCellChangeSpeed: number;
  89301. /**
  89302. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89303. */
  89304. startSpriteCellID: number;
  89305. /**
  89306. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89307. */
  89308. endSpriteCellID: number;
  89309. /**
  89310. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89311. */
  89312. spriteCellWidth: number;
  89313. /**
  89314. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89315. */
  89316. spriteCellHeight: number;
  89317. /**
  89318. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89319. */
  89320. spriteRandomStartCell: boolean;
  89321. /**
  89322. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89323. */
  89324. isAnimationSheetEnabled: boolean;
  89325. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89326. translationPivot: Vector2;
  89327. /**
  89328. * Gets or sets a texture used to add random noise to particle positions
  89329. */
  89330. noiseTexture: Nullable<BaseTexture>;
  89331. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89332. noiseStrength: Vector3;
  89333. /**
  89334. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89335. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89336. */
  89337. billboardMode: number;
  89338. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89339. limitVelocityDamping: number;
  89340. /**
  89341. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89342. */
  89343. beginAnimationOnStart: boolean;
  89344. /**
  89345. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89346. */
  89347. beginAnimationFrom: number;
  89348. /**
  89349. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89350. */
  89351. beginAnimationTo: number;
  89352. /**
  89353. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89354. */
  89355. beginAnimationLoop: boolean;
  89356. /**
  89357. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89358. */
  89359. disposeOnStop: boolean;
  89360. /**
  89361. * Gets the maximum number of particles active at the same time.
  89362. * @returns The max number of active particles.
  89363. */
  89364. getCapacity(): number;
  89365. /**
  89366. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89367. * @returns True if it has been started, otherwise false.
  89368. */
  89369. isStarted(): boolean;
  89370. /**
  89371. * Animates the particle system for this frame.
  89372. */
  89373. animate(): void;
  89374. /**
  89375. * Renders the particle system in its current state.
  89376. * @returns the current number of particles
  89377. */
  89378. render(): number;
  89379. /**
  89380. * Dispose the particle system and frees its associated resources.
  89381. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89382. */
  89383. dispose(disposeTexture?: boolean): void;
  89384. /**
  89385. * Clones the particle system.
  89386. * @param name The name of the cloned object
  89387. * @param newEmitter The new emitter to use
  89388. * @returns the cloned particle system
  89389. */
  89390. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89391. /**
  89392. * Serializes the particle system to a JSON object.
  89393. * @returns the JSON object
  89394. */
  89395. serialize(): any;
  89396. /**
  89397. * Rebuild the particle system
  89398. */
  89399. rebuild(): void;
  89400. /**
  89401. * Starts the particle system and begins to emit
  89402. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89403. */
  89404. start(delay?: number): void;
  89405. /**
  89406. * Stops the particle system.
  89407. */
  89408. stop(): void;
  89409. /**
  89410. * Remove all active particles
  89411. */
  89412. reset(): void;
  89413. /**
  89414. * Is this system ready to be used/rendered
  89415. * @return true if the system is ready
  89416. */
  89417. isReady(): boolean;
  89418. /**
  89419. * Adds a new color gradient
  89420. * @param gradient defines the gradient to use (between 0 and 1)
  89421. * @param color1 defines the color to affect to the specified gradient
  89422. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89423. * @returns the current particle system
  89424. */
  89425. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89426. /**
  89427. * Remove a specific color gradient
  89428. * @param gradient defines the gradient to remove
  89429. * @returns the current particle system
  89430. */
  89431. removeColorGradient(gradient: number): IParticleSystem;
  89432. /**
  89433. * Adds a new size gradient
  89434. * @param gradient defines the gradient to use (between 0 and 1)
  89435. * @param factor defines the size factor to affect to the specified gradient
  89436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89437. * @returns the current particle system
  89438. */
  89439. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89440. /**
  89441. * Remove a specific size gradient
  89442. * @param gradient defines the gradient to remove
  89443. * @returns the current particle system
  89444. */
  89445. removeSizeGradient(gradient: number): IParticleSystem;
  89446. /**
  89447. * Gets the current list of color gradients.
  89448. * You must use addColorGradient and removeColorGradient to udpate this list
  89449. * @returns the list of color gradients
  89450. */
  89451. getColorGradients(): Nullable<Array<ColorGradient>>;
  89452. /**
  89453. * Gets the current list of size gradients.
  89454. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89455. * @returns the list of size gradients
  89456. */
  89457. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89458. /**
  89459. * Gets the current list of angular speed gradients.
  89460. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89461. * @returns the list of angular speed gradients
  89462. */
  89463. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89464. /**
  89465. * Adds a new angular speed gradient
  89466. * @param gradient defines the gradient to use (between 0 and 1)
  89467. * @param factor defines the angular speed to affect to the specified gradient
  89468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89469. * @returns the current particle system
  89470. */
  89471. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89472. /**
  89473. * Remove a specific angular speed gradient
  89474. * @param gradient defines the gradient to remove
  89475. * @returns the current particle system
  89476. */
  89477. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89478. /**
  89479. * Gets the current list of velocity gradients.
  89480. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89481. * @returns the list of velocity gradients
  89482. */
  89483. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89484. /**
  89485. * Adds a new velocity gradient
  89486. * @param gradient defines the gradient to use (between 0 and 1)
  89487. * @param factor defines the velocity to affect to the specified gradient
  89488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89489. * @returns the current particle system
  89490. */
  89491. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89492. /**
  89493. * Remove a specific velocity gradient
  89494. * @param gradient defines the gradient to remove
  89495. * @returns the current particle system
  89496. */
  89497. removeVelocityGradient(gradient: number): IParticleSystem;
  89498. /**
  89499. * Gets the current list of limit velocity gradients.
  89500. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89501. * @returns the list of limit velocity gradients
  89502. */
  89503. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89504. /**
  89505. * Adds a new limit velocity gradient
  89506. * @param gradient defines the gradient to use (between 0 and 1)
  89507. * @param factor defines the limit velocity to affect to the specified gradient
  89508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89509. * @returns the current particle system
  89510. */
  89511. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89512. /**
  89513. * Remove a specific limit velocity gradient
  89514. * @param gradient defines the gradient to remove
  89515. * @returns the current particle system
  89516. */
  89517. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89518. /**
  89519. * Adds a new drag gradient
  89520. * @param gradient defines the gradient to use (between 0 and 1)
  89521. * @param factor defines the drag to affect to the specified gradient
  89522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89523. * @returns the current particle system
  89524. */
  89525. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89526. /**
  89527. * Remove a specific drag gradient
  89528. * @param gradient defines the gradient to remove
  89529. * @returns the current particle system
  89530. */
  89531. removeDragGradient(gradient: number): IParticleSystem;
  89532. /**
  89533. * Gets the current list of drag gradients.
  89534. * You must use addDragGradient and removeDragGradient to udpate this list
  89535. * @returns the list of drag gradients
  89536. */
  89537. getDragGradients(): Nullable<Array<FactorGradient>>;
  89538. /**
  89539. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89540. * @param gradient defines the gradient to use (between 0 and 1)
  89541. * @param factor defines the emit rate to affect to the specified gradient
  89542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89543. * @returns the current particle system
  89544. */
  89545. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89546. /**
  89547. * Remove a specific emit rate gradient
  89548. * @param gradient defines the gradient to remove
  89549. * @returns the current particle system
  89550. */
  89551. removeEmitRateGradient(gradient: number): IParticleSystem;
  89552. /**
  89553. * Gets the current list of emit rate gradients.
  89554. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89555. * @returns the list of emit rate gradients
  89556. */
  89557. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89558. /**
  89559. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89560. * @param gradient defines the gradient to use (between 0 and 1)
  89561. * @param factor defines the start size to affect to the specified gradient
  89562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89563. * @returns the current particle system
  89564. */
  89565. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89566. /**
  89567. * Remove a specific start size gradient
  89568. * @param gradient defines the gradient to remove
  89569. * @returns the current particle system
  89570. */
  89571. removeStartSizeGradient(gradient: number): IParticleSystem;
  89572. /**
  89573. * Gets the current list of start size gradients.
  89574. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89575. * @returns the list of start size gradients
  89576. */
  89577. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89578. /**
  89579. * Adds a new life time gradient
  89580. * @param gradient defines the gradient to use (between 0 and 1)
  89581. * @param factor defines the life time factor to affect to the specified gradient
  89582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89583. * @returns the current particle system
  89584. */
  89585. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89586. /**
  89587. * Remove a specific life time gradient
  89588. * @param gradient defines the gradient to remove
  89589. * @returns the current particle system
  89590. */
  89591. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89592. /**
  89593. * Gets the current list of life time gradients.
  89594. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89595. * @returns the list of life time gradients
  89596. */
  89597. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89598. /**
  89599. * Gets the current list of color gradients.
  89600. * You must use addColorGradient and removeColorGradient to udpate this list
  89601. * @returns the list of color gradients
  89602. */
  89603. getColorGradients(): Nullable<Array<ColorGradient>>;
  89604. /**
  89605. * Adds a new ramp gradient used to remap particle colors
  89606. * @param gradient defines the gradient to use (between 0 and 1)
  89607. * @param color defines the color to affect to the specified gradient
  89608. * @returns the current particle system
  89609. */
  89610. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89611. /**
  89612. * Gets the current list of ramp gradients.
  89613. * You must use addRampGradient and removeRampGradient to udpate this list
  89614. * @returns the list of ramp gradients
  89615. */
  89616. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89617. /** Gets or sets a boolean indicating that ramp gradients must be used
  89618. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89619. */
  89620. useRampGradients: boolean;
  89621. /**
  89622. * Adds a new color remap gradient
  89623. * @param gradient defines the gradient to use (between 0 and 1)
  89624. * @param min defines the color remap minimal range
  89625. * @param max defines the color remap maximal range
  89626. * @returns the current particle system
  89627. */
  89628. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89629. /**
  89630. * Gets the current list of color remap gradients.
  89631. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89632. * @returns the list of color remap gradients
  89633. */
  89634. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89635. /**
  89636. * Adds a new alpha remap gradient
  89637. * @param gradient defines the gradient to use (between 0 and 1)
  89638. * @param min defines the alpha remap minimal range
  89639. * @param max defines the alpha remap maximal range
  89640. * @returns the current particle system
  89641. */
  89642. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89643. /**
  89644. * Gets the current list of alpha remap gradients.
  89645. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89646. * @returns the list of alpha remap gradients
  89647. */
  89648. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89649. /**
  89650. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89651. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89652. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89653. * @returns the emitter
  89654. */
  89655. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89656. /**
  89657. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89658. * @param radius The radius of the hemisphere to emit from
  89659. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89660. * @returns the emitter
  89661. */
  89662. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89663. /**
  89664. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89665. * @param radius The radius of the sphere to emit from
  89666. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89667. * @returns the emitter
  89668. */
  89669. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89670. /**
  89671. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89672. * @param radius The radius of the sphere to emit from
  89673. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89674. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89675. * @returns the emitter
  89676. */
  89677. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89678. /**
  89679. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89680. * @param radius The radius of the emission cylinder
  89681. * @param height The height of the emission cylinder
  89682. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89683. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89684. * @returns the emitter
  89685. */
  89686. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89687. /**
  89688. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89689. * @param radius The radius of the cylinder to emit from
  89690. * @param height The height of the emission cylinder
  89691. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89692. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89693. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89694. * @returns the emitter
  89695. */
  89696. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89697. /**
  89698. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89699. * @param radius The radius of the cone to emit from
  89700. * @param angle The base angle of the cone
  89701. * @returns the emitter
  89702. */
  89703. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89704. /**
  89705. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89706. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89707. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89708. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89709. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89710. * @returns the emitter
  89711. */
  89712. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89713. /**
  89714. * Get hosting scene
  89715. * @returns the scene
  89716. */
  89717. getScene(): Scene;
  89718. }
  89719. }
  89720. declare module BABYLON {
  89721. /**
  89722. * Creates an instance based on a source mesh.
  89723. */
  89724. export class InstancedMesh extends AbstractMesh {
  89725. private _sourceMesh;
  89726. private _currentLOD;
  89727. /** @hidden */
  89728. _indexInSourceMeshInstanceArray: number;
  89729. constructor(name: string, source: Mesh);
  89730. /**
  89731. * Returns the string "InstancedMesh".
  89732. */
  89733. getClassName(): string;
  89734. /** Gets the list of lights affecting that mesh */
  89735. get lightSources(): Light[];
  89736. _resyncLightSources(): void;
  89737. _resyncLightSource(light: Light): void;
  89738. _removeLightSource(light: Light, dispose: boolean): void;
  89739. /**
  89740. * If the source mesh receives shadows
  89741. */
  89742. get receiveShadows(): boolean;
  89743. /**
  89744. * The material of the source mesh
  89745. */
  89746. get material(): Nullable<Material>;
  89747. /**
  89748. * Visibility of the source mesh
  89749. */
  89750. get visibility(): number;
  89751. /**
  89752. * Skeleton of the source mesh
  89753. */
  89754. get skeleton(): Nullable<Skeleton>;
  89755. /**
  89756. * Rendering ground id of the source mesh
  89757. */
  89758. get renderingGroupId(): number;
  89759. set renderingGroupId(value: number);
  89760. /**
  89761. * Returns the total number of vertices (integer).
  89762. */
  89763. getTotalVertices(): number;
  89764. /**
  89765. * Returns a positive integer : the total number of indices in this mesh geometry.
  89766. * @returns the numner of indices or zero if the mesh has no geometry.
  89767. */
  89768. getTotalIndices(): number;
  89769. /**
  89770. * The source mesh of the instance
  89771. */
  89772. get sourceMesh(): Mesh;
  89773. /**
  89774. * Is this node ready to be used/rendered
  89775. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89776. * @return {boolean} is it ready
  89777. */
  89778. isReady(completeCheck?: boolean): boolean;
  89779. /**
  89780. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89781. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89782. * @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.
  89783. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89784. */
  89785. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89786. /**
  89787. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89788. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89789. * The `data` are either a numeric array either a Float32Array.
  89790. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89791. * 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).
  89792. * Note that a new underlying VertexBuffer object is created each call.
  89793. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89794. *
  89795. * Possible `kind` values :
  89796. * - VertexBuffer.PositionKind
  89797. * - VertexBuffer.UVKind
  89798. * - VertexBuffer.UV2Kind
  89799. * - VertexBuffer.UV3Kind
  89800. * - VertexBuffer.UV4Kind
  89801. * - VertexBuffer.UV5Kind
  89802. * - VertexBuffer.UV6Kind
  89803. * - VertexBuffer.ColorKind
  89804. * - VertexBuffer.MatricesIndicesKind
  89805. * - VertexBuffer.MatricesIndicesExtraKind
  89806. * - VertexBuffer.MatricesWeightsKind
  89807. * - VertexBuffer.MatricesWeightsExtraKind
  89808. *
  89809. * Returns the Mesh.
  89810. */
  89811. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89812. /**
  89813. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89814. * If the mesh has no geometry, it is simply returned as it is.
  89815. * The `data` are either a numeric array either a Float32Array.
  89816. * No new underlying VertexBuffer object is created.
  89817. * 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.
  89818. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89819. *
  89820. * Possible `kind` values :
  89821. * - VertexBuffer.PositionKind
  89822. * - VertexBuffer.UVKind
  89823. * - VertexBuffer.UV2Kind
  89824. * - VertexBuffer.UV3Kind
  89825. * - VertexBuffer.UV4Kind
  89826. * - VertexBuffer.UV5Kind
  89827. * - VertexBuffer.UV6Kind
  89828. * - VertexBuffer.ColorKind
  89829. * - VertexBuffer.MatricesIndicesKind
  89830. * - VertexBuffer.MatricesIndicesExtraKind
  89831. * - VertexBuffer.MatricesWeightsKind
  89832. * - VertexBuffer.MatricesWeightsExtraKind
  89833. *
  89834. * Returns the Mesh.
  89835. */
  89836. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89837. /**
  89838. * Sets the mesh indices.
  89839. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89840. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89841. * This method creates a new index buffer each call.
  89842. * Returns the Mesh.
  89843. */
  89844. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89845. /**
  89846. * Boolean : True if the mesh owns the requested kind of data.
  89847. */
  89848. isVerticesDataPresent(kind: string): boolean;
  89849. /**
  89850. * Returns an array of indices (IndicesArray).
  89851. */
  89852. getIndices(): Nullable<IndicesArray>;
  89853. get _positions(): Nullable<Vector3[]>;
  89854. /**
  89855. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89856. * This means the mesh underlying bounding box and sphere are recomputed.
  89857. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89858. * @returns the current mesh
  89859. */
  89860. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89861. /** @hidden */
  89862. _preActivate(): InstancedMesh;
  89863. /** @hidden */
  89864. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89865. /** @hidden */
  89866. _postActivate(): void;
  89867. getWorldMatrix(): Matrix;
  89868. get isAnInstance(): boolean;
  89869. /**
  89870. * Returns the current associated LOD AbstractMesh.
  89871. */
  89872. getLOD(camera: Camera): AbstractMesh;
  89873. /** @hidden */
  89874. _syncSubMeshes(): InstancedMesh;
  89875. /** @hidden */
  89876. _generatePointsArray(): boolean;
  89877. /**
  89878. * Creates a new InstancedMesh from the current mesh.
  89879. * - name (string) : the cloned mesh name
  89880. * - newParent (optional Node) : the optional Node to parent the clone to.
  89881. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89882. *
  89883. * Returns the clone.
  89884. */
  89885. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89886. /**
  89887. * Disposes the InstancedMesh.
  89888. * Returns nothing.
  89889. */
  89890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89891. }
  89892. interface Mesh {
  89893. /**
  89894. * Register a custom buffer that will be instanced
  89895. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89896. * @param kind defines the buffer kind
  89897. * @param stride defines the stride in floats
  89898. */
  89899. registerInstancedBuffer(kind: string, stride: number): void;
  89900. /** @hidden */
  89901. _userInstancedBuffersStorage: {
  89902. data: {
  89903. [key: string]: Float32Array;
  89904. };
  89905. sizes: {
  89906. [key: string]: number;
  89907. };
  89908. vertexBuffers: {
  89909. [key: string]: Nullable<VertexBuffer>;
  89910. };
  89911. strides: {
  89912. [key: string]: number;
  89913. };
  89914. };
  89915. }
  89916. interface AbstractMesh {
  89917. /**
  89918. * Object used to store instanced buffers defined by user
  89919. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89920. */
  89921. instancedBuffers: {
  89922. [key: string]: any;
  89923. };
  89924. }
  89925. }
  89926. declare module BABYLON {
  89927. /**
  89928. * Defines the options associated with the creation of a shader material.
  89929. */
  89930. export interface IShaderMaterialOptions {
  89931. /**
  89932. * Does the material work in alpha blend mode
  89933. */
  89934. needAlphaBlending: boolean;
  89935. /**
  89936. * Does the material work in alpha test mode
  89937. */
  89938. needAlphaTesting: boolean;
  89939. /**
  89940. * The list of attribute names used in the shader
  89941. */
  89942. attributes: string[];
  89943. /**
  89944. * The list of unifrom names used in the shader
  89945. */
  89946. uniforms: string[];
  89947. /**
  89948. * The list of UBO names used in the shader
  89949. */
  89950. uniformBuffers: string[];
  89951. /**
  89952. * The list of sampler names used in the shader
  89953. */
  89954. samplers: string[];
  89955. /**
  89956. * The list of defines used in the shader
  89957. */
  89958. defines: string[];
  89959. }
  89960. /**
  89961. * 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.
  89962. *
  89963. * This returned material effects how the mesh will look based on the code in the shaders.
  89964. *
  89965. * @see http://doc.babylonjs.com/how_to/shader_material
  89966. */
  89967. export class ShaderMaterial extends Material {
  89968. private _shaderPath;
  89969. private _options;
  89970. private _textures;
  89971. private _textureArrays;
  89972. private _floats;
  89973. private _ints;
  89974. private _floatsArrays;
  89975. private _colors3;
  89976. private _colors3Arrays;
  89977. private _colors4;
  89978. private _colors4Arrays;
  89979. private _vectors2;
  89980. private _vectors3;
  89981. private _vectors4;
  89982. private _matrices;
  89983. private _matrixArrays;
  89984. private _matrices3x3;
  89985. private _matrices2x2;
  89986. private _vectors2Arrays;
  89987. private _vectors3Arrays;
  89988. private _vectors4Arrays;
  89989. private _cachedWorldViewMatrix;
  89990. private _cachedWorldViewProjectionMatrix;
  89991. private _renderId;
  89992. private _multiview;
  89993. /**
  89994. * Instantiate a new shader material.
  89995. * 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.
  89996. * This returned material effects how the mesh will look based on the code in the shaders.
  89997. * @see http://doc.babylonjs.com/how_to/shader_material
  89998. * @param name Define the name of the material in the scene
  89999. * @param scene Define the scene the material belongs to
  90000. * @param shaderPath Defines the route to the shader code in one of three ways:
  90001. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90002. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90003. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90004. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90005. * @param options Define the options used to create the shader
  90006. */
  90007. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90008. /**
  90009. * Gets the shader path used to define the shader code
  90010. * It can be modified to trigger a new compilation
  90011. */
  90012. get shaderPath(): any;
  90013. /**
  90014. * Sets the shader path used to define the shader code
  90015. * It can be modified to trigger a new compilation
  90016. */
  90017. set shaderPath(shaderPath: any);
  90018. /**
  90019. * Gets the options used to compile the shader.
  90020. * They can be modified to trigger a new compilation
  90021. */
  90022. get options(): IShaderMaterialOptions;
  90023. /**
  90024. * Gets the current class name of the material e.g. "ShaderMaterial"
  90025. * Mainly use in serialization.
  90026. * @returns the class name
  90027. */
  90028. getClassName(): string;
  90029. /**
  90030. * Specifies if the material will require alpha blending
  90031. * @returns a boolean specifying if alpha blending is needed
  90032. */
  90033. needAlphaBlending(): boolean;
  90034. /**
  90035. * Specifies if this material should be rendered in alpha test mode
  90036. * @returns a boolean specifying if an alpha test is needed.
  90037. */
  90038. needAlphaTesting(): boolean;
  90039. private _checkUniform;
  90040. /**
  90041. * Set a texture in the shader.
  90042. * @param name Define the name of the uniform samplers as defined in the shader
  90043. * @param texture Define the texture to bind to this sampler
  90044. * @return the material itself allowing "fluent" like uniform updates
  90045. */
  90046. setTexture(name: string, texture: Texture): ShaderMaterial;
  90047. /**
  90048. * Set a texture array in the shader.
  90049. * @param name Define the name of the uniform sampler array as defined in the shader
  90050. * @param textures Define the list of textures to bind to this sampler
  90051. * @return the material itself allowing "fluent" like uniform updates
  90052. */
  90053. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90054. /**
  90055. * Set a float in the shader.
  90056. * @param name Define the name of the uniform as defined in the shader
  90057. * @param value Define the value to give to the uniform
  90058. * @return the material itself allowing "fluent" like uniform updates
  90059. */
  90060. setFloat(name: string, value: number): ShaderMaterial;
  90061. /**
  90062. * Set a int in the shader.
  90063. * @param name Define the name of the uniform as defined in the shader
  90064. * @param value Define the value to give to the uniform
  90065. * @return the material itself allowing "fluent" like uniform updates
  90066. */
  90067. setInt(name: string, value: number): ShaderMaterial;
  90068. /**
  90069. * Set an array of floats in the shader.
  90070. * @param name Define the name of the uniform as defined in the shader
  90071. * @param value Define the value to give to the uniform
  90072. * @return the material itself allowing "fluent" like uniform updates
  90073. */
  90074. setFloats(name: string, value: number[]): ShaderMaterial;
  90075. /**
  90076. * Set a vec3 in the shader from a Color3.
  90077. * @param name Define the name of the uniform as defined in the shader
  90078. * @param value Define the value to give to the uniform
  90079. * @return the material itself allowing "fluent" like uniform updates
  90080. */
  90081. setColor3(name: string, value: Color3): ShaderMaterial;
  90082. /**
  90083. * Set a vec3 array in the shader from a Color3 array.
  90084. * @param name Define the name of the uniform as defined in the shader
  90085. * @param value Define the value to give to the uniform
  90086. * @return the material itself allowing "fluent" like uniform updates
  90087. */
  90088. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90089. /**
  90090. * Set a vec4 in the shader from a Color4.
  90091. * @param name Define the name of the uniform as defined in the shader
  90092. * @param value Define the value to give to the uniform
  90093. * @return the material itself allowing "fluent" like uniform updates
  90094. */
  90095. setColor4(name: string, value: Color4): ShaderMaterial;
  90096. /**
  90097. * Set a vec4 array in the shader from a Color4 array.
  90098. * @param name Define the name of the uniform as defined in the shader
  90099. * @param value Define the value to give to the uniform
  90100. * @return the material itself allowing "fluent" like uniform updates
  90101. */
  90102. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90103. /**
  90104. * Set a vec2 in the shader from a Vector2.
  90105. * @param name Define the name of the uniform as defined in the shader
  90106. * @param value Define the value to give to the uniform
  90107. * @return the material itself allowing "fluent" like uniform updates
  90108. */
  90109. setVector2(name: string, value: Vector2): ShaderMaterial;
  90110. /**
  90111. * Set a vec3 in the shader from a Vector3.
  90112. * @param name Define the name of the uniform as defined in the shader
  90113. * @param value Define the value to give to the uniform
  90114. * @return the material itself allowing "fluent" like uniform updates
  90115. */
  90116. setVector3(name: string, value: Vector3): ShaderMaterial;
  90117. /**
  90118. * Set a vec4 in the shader from a Vector4.
  90119. * @param name Define the name of the uniform as defined in the shader
  90120. * @param value Define the value to give to the uniform
  90121. * @return the material itself allowing "fluent" like uniform updates
  90122. */
  90123. setVector4(name: string, value: Vector4): ShaderMaterial;
  90124. /**
  90125. * Set a mat4 in the shader from a Matrix.
  90126. * @param name Define the name of the uniform as defined in the shader
  90127. * @param value Define the value to give to the uniform
  90128. * @return the material itself allowing "fluent" like uniform updates
  90129. */
  90130. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90131. /**
  90132. * Set a float32Array in the shader from a matrix array.
  90133. * @param name Define the name of the uniform as defined in the shader
  90134. * @param value Define the value to give to the uniform
  90135. * @return the material itself allowing "fluent" like uniform updates
  90136. */
  90137. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90138. /**
  90139. * Set a mat3 in the shader from a Float32Array.
  90140. * @param name Define the name of the uniform as defined in the shader
  90141. * @param value Define the value to give to the uniform
  90142. * @return the material itself allowing "fluent" like uniform updates
  90143. */
  90144. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90145. /**
  90146. * Set a mat2 in the shader from a Float32Array.
  90147. * @param name Define the name of the uniform as defined in the shader
  90148. * @param value Define the value to give to the uniform
  90149. * @return the material itself allowing "fluent" like uniform updates
  90150. */
  90151. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90152. /**
  90153. * Set a vec2 array in the shader from a number array.
  90154. * @param name Define the name of the uniform as defined in the shader
  90155. * @param value Define the value to give to the uniform
  90156. * @return the material itself allowing "fluent" like uniform updates
  90157. */
  90158. setArray2(name: string, value: number[]): ShaderMaterial;
  90159. /**
  90160. * Set a vec3 array in the shader from a number array.
  90161. * @param name Define the name of the uniform as defined in the shader
  90162. * @param value Define the value to give to the uniform
  90163. * @return the material itself allowing "fluent" like uniform updates
  90164. */
  90165. setArray3(name: string, value: number[]): ShaderMaterial;
  90166. /**
  90167. * Set a vec4 array in the shader from a number array.
  90168. * @param name Define the name of the uniform as defined in the shader
  90169. * @param value Define the value to give to the uniform
  90170. * @return the material itself allowing "fluent" like uniform updates
  90171. */
  90172. setArray4(name: string, value: number[]): ShaderMaterial;
  90173. private _checkCache;
  90174. /**
  90175. * Specifies that the submesh is ready to be used
  90176. * @param mesh defines the mesh to check
  90177. * @param subMesh defines which submesh to check
  90178. * @param useInstances specifies that instances should be used
  90179. * @returns a boolean indicating that the submesh is ready or not
  90180. */
  90181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90182. /**
  90183. * Checks if the material is ready to render the requested mesh
  90184. * @param mesh Define the mesh to render
  90185. * @param useInstances Define whether or not the material is used with instances
  90186. * @returns true if ready, otherwise false
  90187. */
  90188. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90189. /**
  90190. * Binds the world matrix to the material
  90191. * @param world defines the world transformation matrix
  90192. */
  90193. bindOnlyWorldMatrix(world: Matrix): void;
  90194. /**
  90195. * Binds the material to the mesh
  90196. * @param world defines the world transformation matrix
  90197. * @param mesh defines the mesh to bind the material to
  90198. */
  90199. bind(world: Matrix, mesh?: Mesh): void;
  90200. /**
  90201. * Gets the active textures from the material
  90202. * @returns an array of textures
  90203. */
  90204. getActiveTextures(): BaseTexture[];
  90205. /**
  90206. * Specifies if the material uses a texture
  90207. * @param texture defines the texture to check against the material
  90208. * @returns a boolean specifying if the material uses the texture
  90209. */
  90210. hasTexture(texture: BaseTexture): boolean;
  90211. /**
  90212. * Makes a duplicate of the material, and gives it a new name
  90213. * @param name defines the new name for the duplicated material
  90214. * @returns the cloned material
  90215. */
  90216. clone(name: string): ShaderMaterial;
  90217. /**
  90218. * Disposes the material
  90219. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90220. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90221. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90222. */
  90223. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90224. /**
  90225. * Serializes this material in a JSON representation
  90226. * @returns the serialized material object
  90227. */
  90228. serialize(): any;
  90229. /**
  90230. * Creates a shader material from parsed shader material data
  90231. * @param source defines the JSON represnetation of the material
  90232. * @param scene defines the hosting scene
  90233. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90234. * @returns a new material
  90235. */
  90236. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90237. }
  90238. }
  90239. declare module BABYLON {
  90240. /** @hidden */
  90241. export var colorPixelShader: {
  90242. name: string;
  90243. shader: string;
  90244. };
  90245. }
  90246. declare module BABYLON {
  90247. /** @hidden */
  90248. export var colorVertexShader: {
  90249. name: string;
  90250. shader: string;
  90251. };
  90252. }
  90253. declare module BABYLON {
  90254. /**
  90255. * Line mesh
  90256. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90257. */
  90258. export class LinesMesh extends Mesh {
  90259. /**
  90260. * If vertex color should be applied to the mesh
  90261. */
  90262. readonly useVertexColor?: boolean | undefined;
  90263. /**
  90264. * If vertex alpha should be applied to the mesh
  90265. */
  90266. readonly useVertexAlpha?: boolean | undefined;
  90267. /**
  90268. * Color of the line (Default: White)
  90269. */
  90270. color: Color3;
  90271. /**
  90272. * Alpha of the line (Default: 1)
  90273. */
  90274. alpha: number;
  90275. /**
  90276. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90277. * This margin is expressed in world space coordinates, so its value may vary.
  90278. * Default value is 0.1
  90279. */
  90280. intersectionThreshold: number;
  90281. private _colorShader;
  90282. private color4;
  90283. /**
  90284. * Creates a new LinesMesh
  90285. * @param name defines the name
  90286. * @param scene defines the hosting scene
  90287. * @param parent defines the parent mesh if any
  90288. * @param source defines the optional source LinesMesh used to clone data from
  90289. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90290. * When false, achieved by calling a clone(), also passing False.
  90291. * This will make creation of children, recursive.
  90292. * @param useVertexColor defines if this LinesMesh supports vertex color
  90293. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90294. */
  90295. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90296. /**
  90297. * If vertex color should be applied to the mesh
  90298. */
  90299. useVertexColor?: boolean | undefined,
  90300. /**
  90301. * If vertex alpha should be applied to the mesh
  90302. */
  90303. useVertexAlpha?: boolean | undefined);
  90304. private _addClipPlaneDefine;
  90305. private _removeClipPlaneDefine;
  90306. isReady(): boolean;
  90307. /**
  90308. * Returns the string "LineMesh"
  90309. */
  90310. getClassName(): string;
  90311. /**
  90312. * @hidden
  90313. */
  90314. get material(): Material;
  90315. /**
  90316. * @hidden
  90317. */
  90318. set material(value: Material);
  90319. /**
  90320. * @hidden
  90321. */
  90322. get checkCollisions(): boolean;
  90323. /** @hidden */
  90324. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90325. /** @hidden */
  90326. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90327. /**
  90328. * Disposes of the line mesh
  90329. * @param doNotRecurse If children should be disposed
  90330. */
  90331. dispose(doNotRecurse?: boolean): void;
  90332. /**
  90333. * Returns a new LineMesh object cloned from the current one.
  90334. */
  90335. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90336. /**
  90337. * Creates a new InstancedLinesMesh object from the mesh model.
  90338. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90339. * @param name defines the name of the new instance
  90340. * @returns a new InstancedLinesMesh
  90341. */
  90342. createInstance(name: string): InstancedLinesMesh;
  90343. }
  90344. /**
  90345. * Creates an instance based on a source LinesMesh
  90346. */
  90347. export class InstancedLinesMesh extends InstancedMesh {
  90348. /**
  90349. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90350. * This margin is expressed in world space coordinates, so its value may vary.
  90351. * Initilized with the intersectionThreshold value of the source LinesMesh
  90352. */
  90353. intersectionThreshold: number;
  90354. constructor(name: string, source: LinesMesh);
  90355. /**
  90356. * Returns the string "InstancedLinesMesh".
  90357. */
  90358. getClassName(): string;
  90359. }
  90360. }
  90361. declare module BABYLON {
  90362. /** @hidden */
  90363. export var linePixelShader: {
  90364. name: string;
  90365. shader: string;
  90366. };
  90367. }
  90368. declare module BABYLON {
  90369. /** @hidden */
  90370. export var lineVertexShader: {
  90371. name: string;
  90372. shader: string;
  90373. };
  90374. }
  90375. declare module BABYLON {
  90376. interface AbstractMesh {
  90377. /**
  90378. * Gets the edgesRenderer associated with the mesh
  90379. */
  90380. edgesRenderer: Nullable<EdgesRenderer>;
  90381. }
  90382. interface LinesMesh {
  90383. /**
  90384. * Enables the edge rendering mode on the mesh.
  90385. * This mode makes the mesh edges visible
  90386. * @param epsilon defines the maximal distance between two angles to detect a face
  90387. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90388. * @returns the currentAbstractMesh
  90389. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90390. */
  90391. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90392. }
  90393. interface InstancedLinesMesh {
  90394. /**
  90395. * Enables the edge rendering mode on the mesh.
  90396. * This mode makes the mesh edges visible
  90397. * @param epsilon defines the maximal distance between two angles to detect a face
  90398. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90399. * @returns the current InstancedLinesMesh
  90400. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90401. */
  90402. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90403. }
  90404. /**
  90405. * Defines the minimum contract an Edges renderer should follow.
  90406. */
  90407. export interface IEdgesRenderer extends IDisposable {
  90408. /**
  90409. * Gets or sets a boolean indicating if the edgesRenderer is active
  90410. */
  90411. isEnabled: boolean;
  90412. /**
  90413. * Renders the edges of the attached mesh,
  90414. */
  90415. render(): void;
  90416. /**
  90417. * Checks wether or not the edges renderer is ready to render.
  90418. * @return true if ready, otherwise false.
  90419. */
  90420. isReady(): boolean;
  90421. }
  90422. /**
  90423. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90424. */
  90425. export class EdgesRenderer implements IEdgesRenderer {
  90426. /**
  90427. * Define the size of the edges with an orthographic camera
  90428. */
  90429. edgesWidthScalerForOrthographic: number;
  90430. /**
  90431. * Define the size of the edges with a perspective camera
  90432. */
  90433. edgesWidthScalerForPerspective: number;
  90434. protected _source: AbstractMesh;
  90435. protected _linesPositions: number[];
  90436. protected _linesNormals: number[];
  90437. protected _linesIndices: number[];
  90438. protected _epsilon: number;
  90439. protected _indicesCount: number;
  90440. protected _lineShader: ShaderMaterial;
  90441. protected _ib: DataBuffer;
  90442. protected _buffers: {
  90443. [key: string]: Nullable<VertexBuffer>;
  90444. };
  90445. protected _checkVerticesInsteadOfIndices: boolean;
  90446. private _meshRebuildObserver;
  90447. private _meshDisposeObserver;
  90448. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90449. isEnabled: boolean;
  90450. /**
  90451. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90452. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90453. * @param source Mesh used to create edges
  90454. * @param epsilon sum of angles in adjacency to check for edge
  90455. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90456. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90457. */
  90458. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90459. protected _prepareRessources(): void;
  90460. /** @hidden */
  90461. _rebuild(): void;
  90462. /**
  90463. * Releases the required resources for the edges renderer
  90464. */
  90465. dispose(): void;
  90466. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90467. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90468. /**
  90469. * Checks if the pair of p0 and p1 is en edge
  90470. * @param faceIndex
  90471. * @param edge
  90472. * @param faceNormals
  90473. * @param p0
  90474. * @param p1
  90475. * @private
  90476. */
  90477. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90478. /**
  90479. * push line into the position, normal and index buffer
  90480. * @protected
  90481. */
  90482. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90483. /**
  90484. * Generates lines edges from adjacencjes
  90485. * @private
  90486. */
  90487. _generateEdgesLines(): void;
  90488. /**
  90489. * Checks wether or not the edges renderer is ready to render.
  90490. * @return true if ready, otherwise false.
  90491. */
  90492. isReady(): boolean;
  90493. /**
  90494. * Renders the edges of the attached mesh,
  90495. */
  90496. render(): void;
  90497. }
  90498. /**
  90499. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90500. */
  90501. export class LineEdgesRenderer extends EdgesRenderer {
  90502. /**
  90503. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90504. * @param source LineMesh used to generate edges
  90505. * @param epsilon not important (specified angle for edge detection)
  90506. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90507. */
  90508. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90509. /**
  90510. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90511. */
  90512. _generateEdgesLines(): void;
  90513. }
  90514. }
  90515. declare module BABYLON {
  90516. /**
  90517. * This represents the object necessary to create a rendering group.
  90518. * This is exclusively used and created by the rendering manager.
  90519. * To modify the behavior, you use the available helpers in your scene or meshes.
  90520. * @hidden
  90521. */
  90522. export class RenderingGroup {
  90523. index: number;
  90524. private static _zeroVector;
  90525. private _scene;
  90526. private _opaqueSubMeshes;
  90527. private _transparentSubMeshes;
  90528. private _alphaTestSubMeshes;
  90529. private _depthOnlySubMeshes;
  90530. private _particleSystems;
  90531. private _spriteManagers;
  90532. private _opaqueSortCompareFn;
  90533. private _alphaTestSortCompareFn;
  90534. private _transparentSortCompareFn;
  90535. private _renderOpaque;
  90536. private _renderAlphaTest;
  90537. private _renderTransparent;
  90538. /** @hidden */
  90539. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90540. onBeforeTransparentRendering: () => void;
  90541. /**
  90542. * Set the opaque sort comparison function.
  90543. * If null the sub meshes will be render in the order they were created
  90544. */
  90545. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90546. /**
  90547. * Set the alpha test sort comparison function.
  90548. * If null the sub meshes will be render in the order they were created
  90549. */
  90550. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90551. /**
  90552. * Set the transparent sort comparison function.
  90553. * If null the sub meshes will be render in the order they were created
  90554. */
  90555. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90556. /**
  90557. * Creates a new rendering group.
  90558. * @param index The rendering group index
  90559. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90560. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90561. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90562. */
  90563. 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>);
  90564. /**
  90565. * Render all the sub meshes contained in the group.
  90566. * @param customRenderFunction Used to override the default render behaviour of the group.
  90567. * @returns true if rendered some submeshes.
  90568. */
  90569. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90570. /**
  90571. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90572. * @param subMeshes The submeshes to render
  90573. */
  90574. private renderOpaqueSorted;
  90575. /**
  90576. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90577. * @param subMeshes The submeshes to render
  90578. */
  90579. private renderAlphaTestSorted;
  90580. /**
  90581. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90582. * @param subMeshes The submeshes to render
  90583. */
  90584. private renderTransparentSorted;
  90585. /**
  90586. * Renders the submeshes in a specified order.
  90587. * @param subMeshes The submeshes to sort before render
  90588. * @param sortCompareFn The comparison function use to sort
  90589. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90590. * @param transparent Specifies to activate blending if true
  90591. */
  90592. private static renderSorted;
  90593. /**
  90594. * Renders the submeshes in the order they were dispatched (no sort applied).
  90595. * @param subMeshes The submeshes to render
  90596. */
  90597. private static renderUnsorted;
  90598. /**
  90599. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90600. * are rendered back to front if in the same alpha index.
  90601. *
  90602. * @param a The first submesh
  90603. * @param b The second submesh
  90604. * @returns The result of the comparison
  90605. */
  90606. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90607. /**
  90608. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90609. * are rendered back to front.
  90610. *
  90611. * @param a The first submesh
  90612. * @param b The second submesh
  90613. * @returns The result of the comparison
  90614. */
  90615. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90616. /**
  90617. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90618. * are rendered front to back (prevent overdraw).
  90619. *
  90620. * @param a The first submesh
  90621. * @param b The second submesh
  90622. * @returns The result of the comparison
  90623. */
  90624. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90625. /**
  90626. * Resets the different lists of submeshes to prepare a new frame.
  90627. */
  90628. prepare(): void;
  90629. dispose(): void;
  90630. /**
  90631. * Inserts the submesh in its correct queue depending on its material.
  90632. * @param subMesh The submesh to dispatch
  90633. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90634. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90635. */
  90636. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90637. dispatchSprites(spriteManager: ISpriteManager): void;
  90638. dispatchParticles(particleSystem: IParticleSystem): void;
  90639. private _renderParticles;
  90640. private _renderSprites;
  90641. }
  90642. }
  90643. declare module BABYLON {
  90644. /**
  90645. * Interface describing the different options available in the rendering manager
  90646. * regarding Auto Clear between groups.
  90647. */
  90648. export interface IRenderingManagerAutoClearSetup {
  90649. /**
  90650. * Defines whether or not autoclear is enable.
  90651. */
  90652. autoClear: boolean;
  90653. /**
  90654. * Defines whether or not to autoclear the depth buffer.
  90655. */
  90656. depth: boolean;
  90657. /**
  90658. * Defines whether or not to autoclear the stencil buffer.
  90659. */
  90660. stencil: boolean;
  90661. }
  90662. /**
  90663. * This class is used by the onRenderingGroupObservable
  90664. */
  90665. export class RenderingGroupInfo {
  90666. /**
  90667. * The Scene that being rendered
  90668. */
  90669. scene: Scene;
  90670. /**
  90671. * The camera currently used for the rendering pass
  90672. */
  90673. camera: Nullable<Camera>;
  90674. /**
  90675. * The ID of the renderingGroup being processed
  90676. */
  90677. renderingGroupId: number;
  90678. }
  90679. /**
  90680. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90681. * It is enable to manage the different groups as well as the different necessary sort functions.
  90682. * This should not be used directly aside of the few static configurations
  90683. */
  90684. export class RenderingManager {
  90685. /**
  90686. * The max id used for rendering groups (not included)
  90687. */
  90688. static MAX_RENDERINGGROUPS: number;
  90689. /**
  90690. * The min id used for rendering groups (included)
  90691. */
  90692. static MIN_RENDERINGGROUPS: number;
  90693. /**
  90694. * Used to globally prevent autoclearing scenes.
  90695. */
  90696. static AUTOCLEAR: boolean;
  90697. /**
  90698. * @hidden
  90699. */
  90700. _useSceneAutoClearSetup: boolean;
  90701. private _scene;
  90702. private _renderingGroups;
  90703. private _depthStencilBufferAlreadyCleaned;
  90704. private _autoClearDepthStencil;
  90705. private _customOpaqueSortCompareFn;
  90706. private _customAlphaTestSortCompareFn;
  90707. private _customTransparentSortCompareFn;
  90708. private _renderingGroupInfo;
  90709. /**
  90710. * Instantiates a new rendering group for a particular scene
  90711. * @param scene Defines the scene the groups belongs to
  90712. */
  90713. constructor(scene: Scene);
  90714. private _clearDepthStencilBuffer;
  90715. /**
  90716. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90717. * @hidden
  90718. */
  90719. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90720. /**
  90721. * Resets the different information of the group to prepare a new frame
  90722. * @hidden
  90723. */
  90724. reset(): void;
  90725. /**
  90726. * Dispose and release the group and its associated resources.
  90727. * @hidden
  90728. */
  90729. dispose(): void;
  90730. /**
  90731. * Clear the info related to rendering groups preventing retention points during dispose.
  90732. */
  90733. freeRenderingGroups(): void;
  90734. private _prepareRenderingGroup;
  90735. /**
  90736. * Add a sprite manager to the rendering manager in order to render it this frame.
  90737. * @param spriteManager Define the sprite manager to render
  90738. */
  90739. dispatchSprites(spriteManager: ISpriteManager): void;
  90740. /**
  90741. * Add a particle system to the rendering manager in order to render it this frame.
  90742. * @param particleSystem Define the particle system to render
  90743. */
  90744. dispatchParticles(particleSystem: IParticleSystem): void;
  90745. /**
  90746. * Add a submesh to the manager in order to render it this frame
  90747. * @param subMesh The submesh to dispatch
  90748. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90749. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90750. */
  90751. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90752. /**
  90753. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90754. * This allowed control for front to back rendering or reversly depending of the special needs.
  90755. *
  90756. * @param renderingGroupId The rendering group id corresponding to its index
  90757. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90758. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90759. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90760. */
  90761. 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;
  90762. /**
  90763. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90764. *
  90765. * @param renderingGroupId The rendering group id corresponding to its index
  90766. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90767. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90768. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90769. */
  90770. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90771. /**
  90772. * Gets the current auto clear configuration for one rendering group of the rendering
  90773. * manager.
  90774. * @param index the rendering group index to get the information for
  90775. * @returns The auto clear setup for the requested rendering group
  90776. */
  90777. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90778. }
  90779. }
  90780. declare module BABYLON {
  90781. /**
  90782. * This Helps creating a texture that will be created from a camera in your scene.
  90783. * It is basically a dynamic texture that could be used to create special effects for instance.
  90784. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  90785. */
  90786. export class RenderTargetTexture extends Texture {
  90787. isCube: boolean;
  90788. /**
  90789. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  90790. */
  90791. static readonly REFRESHRATE_RENDER_ONCE: number;
  90792. /**
  90793. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  90794. */
  90795. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  90796. /**
  90797. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  90798. * the central point of your effect and can save a lot of performances.
  90799. */
  90800. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  90801. /**
  90802. * Use this predicate to dynamically define the list of mesh you want to render.
  90803. * If set, the renderList property will be overwritten.
  90804. */
  90805. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  90806. private _renderList;
  90807. /**
  90808. * Use this list to define the list of mesh you want to render.
  90809. */
  90810. get renderList(): Nullable<Array<AbstractMesh>>;
  90811. set renderList(value: Nullable<Array<AbstractMesh>>);
  90812. private _hookArray;
  90813. /**
  90814. * Define if particles should be rendered in your texture.
  90815. */
  90816. renderParticles: boolean;
  90817. /**
  90818. * Define if sprites should be rendered in your texture.
  90819. */
  90820. renderSprites: boolean;
  90821. /**
  90822. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  90823. */
  90824. coordinatesMode: number;
  90825. /**
  90826. * Define the camera used to render the texture.
  90827. */
  90828. activeCamera: Nullable<Camera>;
  90829. /**
  90830. * Override the render function of the texture with your own one.
  90831. */
  90832. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  90833. /**
  90834. * Define if camera post processes should be use while rendering the texture.
  90835. */
  90836. useCameraPostProcesses: boolean;
  90837. /**
  90838. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  90839. */
  90840. ignoreCameraViewport: boolean;
  90841. private _postProcessManager;
  90842. private _postProcesses;
  90843. private _resizeObserver;
  90844. /**
  90845. * An event triggered when the texture is unbind.
  90846. */
  90847. onBeforeBindObservable: Observable<RenderTargetTexture>;
  90848. /**
  90849. * An event triggered when the texture is unbind.
  90850. */
  90851. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  90852. private _onAfterUnbindObserver;
  90853. /**
  90854. * Set a after unbind callback in the texture.
  90855. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  90856. */
  90857. set onAfterUnbind(callback: () => void);
  90858. /**
  90859. * An event triggered before rendering the texture
  90860. */
  90861. onBeforeRenderObservable: Observable<number>;
  90862. private _onBeforeRenderObserver;
  90863. /**
  90864. * Set a before render callback in the texture.
  90865. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  90866. */
  90867. set onBeforeRender(callback: (faceIndex: number) => void);
  90868. /**
  90869. * An event triggered after rendering the texture
  90870. */
  90871. onAfterRenderObservable: Observable<number>;
  90872. private _onAfterRenderObserver;
  90873. /**
  90874. * Set a after render callback in the texture.
  90875. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  90876. */
  90877. set onAfterRender(callback: (faceIndex: number) => void);
  90878. /**
  90879. * An event triggered after the texture clear
  90880. */
  90881. onClearObservable: Observable<Engine>;
  90882. private _onClearObserver;
  90883. /**
  90884. * Set a clear callback in the texture.
  90885. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  90886. */
  90887. set onClear(callback: (Engine: Engine) => void);
  90888. /**
  90889. * An event triggered when the texture is resized.
  90890. */
  90891. onResizeObservable: Observable<RenderTargetTexture>;
  90892. /**
  90893. * Define the clear color of the Render Target if it should be different from the scene.
  90894. */
  90895. clearColor: Color4;
  90896. protected _size: number | {
  90897. width: number;
  90898. height: number;
  90899. };
  90900. protected _initialSizeParameter: number | {
  90901. width: number;
  90902. height: number;
  90903. } | {
  90904. ratio: number;
  90905. };
  90906. protected _sizeRatio: Nullable<number>;
  90907. /** @hidden */
  90908. _generateMipMaps: boolean;
  90909. protected _renderingManager: RenderingManager;
  90910. /** @hidden */
  90911. _waitingRenderList: string[];
  90912. protected _doNotChangeAspectRatio: boolean;
  90913. protected _currentRefreshId: number;
  90914. protected _refreshRate: number;
  90915. protected _textureMatrix: Matrix;
  90916. protected _samples: number;
  90917. protected _renderTargetOptions: RenderTargetCreationOptions;
  90918. /**
  90919. * Gets render target creation options that were used.
  90920. */
  90921. get renderTargetOptions(): RenderTargetCreationOptions;
  90922. protected _engine: Engine;
  90923. protected _onRatioRescale(): void;
  90924. /**
  90925. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  90926. * It must define where the camera used to render the texture is set
  90927. */
  90928. boundingBoxPosition: Vector3;
  90929. private _boundingBoxSize;
  90930. /**
  90931. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  90932. * When defined, the cubemap will switch to local mode
  90933. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  90934. * @example https://www.babylonjs-playground.com/#RNASML
  90935. */
  90936. set boundingBoxSize(value: Vector3);
  90937. get boundingBoxSize(): Vector3;
  90938. /**
  90939. * In case the RTT has been created with a depth texture, get the associated
  90940. * depth texture.
  90941. * Otherwise, return null.
  90942. */
  90943. depthStencilTexture: Nullable<InternalTexture>;
  90944. /**
  90945. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  90946. * or used a shadow, depth texture...
  90947. * @param name The friendly name of the texture
  90948. * @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)
  90949. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  90950. * @param generateMipMaps True if mip maps need to be generated after render.
  90951. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  90952. * @param type The type of the buffer in the RTT (int, half float, float...)
  90953. * @param isCube True if a cube texture needs to be created
  90954. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  90955. * @param generateDepthBuffer True to generate a depth buffer
  90956. * @param generateStencilBuffer True to generate a stencil buffer
  90957. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  90958. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  90959. * @param delayAllocation if the texture allocation should be delayed (default: false)
  90960. */
  90961. constructor(name: string, size: number | {
  90962. width: number;
  90963. height: number;
  90964. } | {
  90965. ratio: number;
  90966. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  90967. /**
  90968. * Creates a depth stencil texture.
  90969. * This is only available in WebGL 2 or with the depth texture extension available.
  90970. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  90971. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  90972. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  90973. */
  90974. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  90975. private _processSizeParameter;
  90976. /**
  90977. * Define the number of samples to use in case of MSAA.
  90978. * It defaults to one meaning no MSAA has been enabled.
  90979. */
  90980. get samples(): number;
  90981. set samples(value: number);
  90982. /**
  90983. * Resets the refresh counter of the texture and start bak from scratch.
  90984. * Could be useful to regenerate the texture if it is setup to render only once.
  90985. */
  90986. resetRefreshCounter(): void;
  90987. /**
  90988. * Define the refresh rate of the texture or the rendering frequency.
  90989. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90990. */
  90991. get refreshRate(): number;
  90992. set refreshRate(value: number);
  90993. /**
  90994. * Adds a post process to the render target rendering passes.
  90995. * @param postProcess define the post process to add
  90996. */
  90997. addPostProcess(postProcess: PostProcess): void;
  90998. /**
  90999. * Clear all the post processes attached to the render target
  91000. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  91001. */
  91002. clearPostProcesses(dispose?: boolean): void;
  91003. /**
  91004. * Remove one of the post process from the list of attached post processes to the texture
  91005. * @param postProcess define the post process to remove from the list
  91006. */
  91007. removePostProcess(postProcess: PostProcess): void;
  91008. /** @hidden */
  91009. _shouldRender(): boolean;
  91010. /**
  91011. * Gets the actual render size of the texture.
  91012. * @returns the width of the render size
  91013. */
  91014. getRenderSize(): number;
  91015. /**
  91016. * Gets the actual render width of the texture.
  91017. * @returns the width of the render size
  91018. */
  91019. getRenderWidth(): number;
  91020. /**
  91021. * Gets the actual render height of the texture.
  91022. * @returns the height of the render size
  91023. */
  91024. getRenderHeight(): number;
  91025. /**
  91026. * Get if the texture can be rescaled or not.
  91027. */
  91028. get canRescale(): boolean;
  91029. /**
  91030. * Resize the texture using a ratio.
  91031. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91032. */
  91033. scale(ratio: number): void;
  91034. /**
  91035. * Get the texture reflection matrix used to rotate/transform the reflection.
  91036. * @returns the reflection matrix
  91037. */
  91038. getReflectionTextureMatrix(): Matrix;
  91039. /**
  91040. * Resize the texture to a new desired size.
  91041. * Be carrefull as it will recreate all the data in the new texture.
  91042. * @param size Define the new size. It can be:
  91043. * - a number for squared texture,
  91044. * - an object containing { width: number, height: number }
  91045. * - or an object containing a ratio { ratio: number }
  91046. */
  91047. resize(size: number | {
  91048. width: number;
  91049. height: number;
  91050. } | {
  91051. ratio: number;
  91052. }): void;
  91053. /**
  91054. * Renders all the objects from the render list into the texture.
  91055. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91056. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91057. */
  91058. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91059. private _bestReflectionRenderTargetDimension;
  91060. /**
  91061. * @hidden
  91062. * @param faceIndex face index to bind to if this is a cubetexture
  91063. */
  91064. _bindFrameBuffer(faceIndex?: number): void;
  91065. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91066. private renderToTarget;
  91067. /**
  91068. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91069. * This allowed control for front to back rendering or reversly depending of the special needs.
  91070. *
  91071. * @param renderingGroupId The rendering group id corresponding to its index
  91072. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91073. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91074. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91075. */
  91076. 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;
  91077. /**
  91078. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91079. *
  91080. * @param renderingGroupId The rendering group id corresponding to its index
  91081. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91082. */
  91083. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91084. /**
  91085. * Clones the texture.
  91086. * @returns the cloned texture
  91087. */
  91088. clone(): RenderTargetTexture;
  91089. /**
  91090. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91091. * @returns The JSON representation of the texture
  91092. */
  91093. serialize(): any;
  91094. /**
  91095. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91096. */
  91097. disposeFramebufferObjects(): void;
  91098. /**
  91099. * Dispose the texture and release its associated resources.
  91100. */
  91101. dispose(): void;
  91102. /** @hidden */
  91103. _rebuild(): void;
  91104. /**
  91105. * Clear the info related to rendering groups preventing retention point in material dispose.
  91106. */
  91107. freeRenderingGroups(): void;
  91108. /**
  91109. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91110. * @returns the view count
  91111. */
  91112. getViewCount(): number;
  91113. }
  91114. }
  91115. declare module BABYLON {
  91116. /**
  91117. * Options for compiling materials.
  91118. */
  91119. export interface IMaterialCompilationOptions {
  91120. /**
  91121. * Defines whether clip planes are enabled.
  91122. */
  91123. clipPlane: boolean;
  91124. /**
  91125. * Defines whether instances are enabled.
  91126. */
  91127. useInstances: boolean;
  91128. }
  91129. /**
  91130. * Base class for the main features of a material in Babylon.js
  91131. */
  91132. export class Material implements IAnimatable {
  91133. /**
  91134. * Returns the triangle fill mode
  91135. */
  91136. static readonly TriangleFillMode: number;
  91137. /**
  91138. * Returns the wireframe mode
  91139. */
  91140. static readonly WireFrameFillMode: number;
  91141. /**
  91142. * Returns the point fill mode
  91143. */
  91144. static readonly PointFillMode: number;
  91145. /**
  91146. * Returns the point list draw mode
  91147. */
  91148. static readonly PointListDrawMode: number;
  91149. /**
  91150. * Returns the line list draw mode
  91151. */
  91152. static readonly LineListDrawMode: number;
  91153. /**
  91154. * Returns the line loop draw mode
  91155. */
  91156. static readonly LineLoopDrawMode: number;
  91157. /**
  91158. * Returns the line strip draw mode
  91159. */
  91160. static readonly LineStripDrawMode: number;
  91161. /**
  91162. * Returns the triangle strip draw mode
  91163. */
  91164. static readonly TriangleStripDrawMode: number;
  91165. /**
  91166. * Returns the triangle fan draw mode
  91167. */
  91168. static readonly TriangleFanDrawMode: number;
  91169. /**
  91170. * Stores the clock-wise side orientation
  91171. */
  91172. static readonly ClockWiseSideOrientation: number;
  91173. /**
  91174. * Stores the counter clock-wise side orientation
  91175. */
  91176. static readonly CounterClockWiseSideOrientation: number;
  91177. /**
  91178. * The dirty texture flag value
  91179. */
  91180. static readonly TextureDirtyFlag: number;
  91181. /**
  91182. * The dirty light flag value
  91183. */
  91184. static readonly LightDirtyFlag: number;
  91185. /**
  91186. * The dirty fresnel flag value
  91187. */
  91188. static readonly FresnelDirtyFlag: number;
  91189. /**
  91190. * The dirty attribute flag value
  91191. */
  91192. static readonly AttributesDirtyFlag: number;
  91193. /**
  91194. * The dirty misc flag value
  91195. */
  91196. static readonly MiscDirtyFlag: number;
  91197. /**
  91198. * The all dirty flag value
  91199. */
  91200. static readonly AllDirtyFlag: number;
  91201. /**
  91202. * The ID of the material
  91203. */
  91204. id: string;
  91205. /**
  91206. * Gets or sets the unique id of the material
  91207. */
  91208. uniqueId: number;
  91209. /**
  91210. * The name of the material
  91211. */
  91212. name: string;
  91213. /**
  91214. * Gets or sets user defined metadata
  91215. */
  91216. metadata: any;
  91217. /**
  91218. * For internal use only. Please do not use.
  91219. */
  91220. reservedDataStore: any;
  91221. /**
  91222. * Specifies if the ready state should be checked on each call
  91223. */
  91224. checkReadyOnEveryCall: boolean;
  91225. /**
  91226. * Specifies if the ready state should be checked once
  91227. */
  91228. checkReadyOnlyOnce: boolean;
  91229. /**
  91230. * The state of the material
  91231. */
  91232. state: string;
  91233. /**
  91234. * The alpha value of the material
  91235. */
  91236. protected _alpha: number;
  91237. /**
  91238. * List of inspectable custom properties (used by the Inspector)
  91239. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91240. */
  91241. inspectableCustomProperties: IInspectable[];
  91242. /**
  91243. * Sets the alpha value of the material
  91244. */
  91245. set alpha(value: number);
  91246. /**
  91247. * Gets the alpha value of the material
  91248. */
  91249. get alpha(): number;
  91250. /**
  91251. * Specifies if back face culling is enabled
  91252. */
  91253. protected _backFaceCulling: boolean;
  91254. /**
  91255. * Sets the back-face culling state
  91256. */
  91257. set backFaceCulling(value: boolean);
  91258. /**
  91259. * Gets the back-face culling state
  91260. */
  91261. get backFaceCulling(): boolean;
  91262. /**
  91263. * Stores the value for side orientation
  91264. */
  91265. sideOrientation: number;
  91266. /**
  91267. * Callback triggered when the material is compiled
  91268. */
  91269. onCompiled: Nullable<(effect: Effect) => void>;
  91270. /**
  91271. * Callback triggered when an error occurs
  91272. */
  91273. onError: Nullable<(effect: Effect, errors: string) => void>;
  91274. /**
  91275. * Callback triggered to get the render target textures
  91276. */
  91277. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  91278. /**
  91279. * Gets a boolean indicating that current material needs to register RTT
  91280. */
  91281. get hasRenderTargetTextures(): boolean;
  91282. /**
  91283. * Specifies if the material should be serialized
  91284. */
  91285. doNotSerialize: boolean;
  91286. /**
  91287. * @hidden
  91288. */
  91289. _storeEffectOnSubMeshes: boolean;
  91290. /**
  91291. * Stores the animations for the material
  91292. */
  91293. animations: Nullable<Array<Animation>>;
  91294. /**
  91295. * An event triggered when the material is disposed
  91296. */
  91297. onDisposeObservable: Observable<Material>;
  91298. /**
  91299. * An observer which watches for dispose events
  91300. */
  91301. private _onDisposeObserver;
  91302. private _onUnBindObservable;
  91303. /**
  91304. * Called during a dispose event
  91305. */
  91306. set onDispose(callback: () => void);
  91307. private _onBindObservable;
  91308. /**
  91309. * An event triggered when the material is bound
  91310. */
  91311. get onBindObservable(): Observable<AbstractMesh>;
  91312. /**
  91313. * An observer which watches for bind events
  91314. */
  91315. private _onBindObserver;
  91316. /**
  91317. * Called during a bind event
  91318. */
  91319. set onBind(callback: (Mesh: AbstractMesh) => void);
  91320. /**
  91321. * An event triggered when the material is unbound
  91322. */
  91323. get onUnBindObservable(): Observable<Material>;
  91324. /**
  91325. * Stores the value of the alpha mode
  91326. */
  91327. private _alphaMode;
  91328. /**
  91329. * Sets the value of the alpha mode.
  91330. *
  91331. * | Value | Type | Description |
  91332. * | --- | --- | --- |
  91333. * | 0 | ALPHA_DISABLE | |
  91334. * | 1 | ALPHA_ADD | |
  91335. * | 2 | ALPHA_COMBINE | |
  91336. * | 3 | ALPHA_SUBTRACT | |
  91337. * | 4 | ALPHA_MULTIPLY | |
  91338. * | 5 | ALPHA_MAXIMIZED | |
  91339. * | 6 | ALPHA_ONEONE | |
  91340. * | 7 | ALPHA_PREMULTIPLIED | |
  91341. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  91342. * | 9 | ALPHA_INTERPOLATE | |
  91343. * | 10 | ALPHA_SCREENMODE | |
  91344. *
  91345. */
  91346. set alphaMode(value: number);
  91347. /**
  91348. * Gets the value of the alpha mode
  91349. */
  91350. get alphaMode(): number;
  91351. /**
  91352. * Stores the state of the need depth pre-pass value
  91353. */
  91354. private _needDepthPrePass;
  91355. /**
  91356. * Sets the need depth pre-pass value
  91357. */
  91358. set needDepthPrePass(value: boolean);
  91359. /**
  91360. * Gets the depth pre-pass value
  91361. */
  91362. get needDepthPrePass(): boolean;
  91363. /**
  91364. * Specifies if depth writing should be disabled
  91365. */
  91366. disableDepthWrite: boolean;
  91367. /**
  91368. * Specifies if depth writing should be forced
  91369. */
  91370. forceDepthWrite: boolean;
  91371. /**
  91372. * Specifies the depth function that should be used. 0 means the default engine function
  91373. */
  91374. depthFunction: number;
  91375. /**
  91376. * Specifies if there should be a separate pass for culling
  91377. */
  91378. separateCullingPass: boolean;
  91379. /**
  91380. * Stores the state specifing if fog should be enabled
  91381. */
  91382. private _fogEnabled;
  91383. /**
  91384. * Sets the state for enabling fog
  91385. */
  91386. set fogEnabled(value: boolean);
  91387. /**
  91388. * Gets the value of the fog enabled state
  91389. */
  91390. get fogEnabled(): boolean;
  91391. /**
  91392. * Stores the size of points
  91393. */
  91394. pointSize: number;
  91395. /**
  91396. * Stores the z offset value
  91397. */
  91398. zOffset: number;
  91399. /**
  91400. * Gets a value specifying if wireframe mode is enabled
  91401. */
  91402. get wireframe(): boolean;
  91403. /**
  91404. * Sets the state of wireframe mode
  91405. */
  91406. set wireframe(value: boolean);
  91407. /**
  91408. * Gets the value specifying if point clouds are enabled
  91409. */
  91410. get pointsCloud(): boolean;
  91411. /**
  91412. * Sets the state of point cloud mode
  91413. */
  91414. set pointsCloud(value: boolean);
  91415. /**
  91416. * Gets the material fill mode
  91417. */
  91418. get fillMode(): number;
  91419. /**
  91420. * Sets the material fill mode
  91421. */
  91422. set fillMode(value: number);
  91423. /**
  91424. * @hidden
  91425. * Stores the effects for the material
  91426. */
  91427. _effect: Nullable<Effect>;
  91428. /**
  91429. * @hidden
  91430. * Specifies if the material was previously ready
  91431. */
  91432. _wasPreviouslyReady: boolean;
  91433. /**
  91434. * Specifies if uniform buffers should be used
  91435. */
  91436. private _useUBO;
  91437. /**
  91438. * Stores a reference to the scene
  91439. */
  91440. private _scene;
  91441. /**
  91442. * Stores the fill mode state
  91443. */
  91444. private _fillMode;
  91445. /**
  91446. * Specifies if the depth write state should be cached
  91447. */
  91448. private _cachedDepthWriteState;
  91449. /**
  91450. * Specifies if the depth function state should be cached
  91451. */
  91452. private _cachedDepthFunctionState;
  91453. /**
  91454. * Stores the uniform buffer
  91455. */
  91456. protected _uniformBuffer: UniformBuffer;
  91457. /** @hidden */
  91458. _indexInSceneMaterialArray: number;
  91459. /** @hidden */
  91460. meshMap: Nullable<{
  91461. [id: string]: AbstractMesh | undefined;
  91462. }>;
  91463. /**
  91464. * Creates a material instance
  91465. * @param name defines the name of the material
  91466. * @param scene defines the scene to reference
  91467. * @param doNotAdd specifies if the material should be added to the scene
  91468. */
  91469. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  91470. /**
  91471. * Returns a string representation of the current material
  91472. * @param fullDetails defines a boolean indicating which levels of logging is desired
  91473. * @returns a string with material information
  91474. */
  91475. toString(fullDetails?: boolean): string;
  91476. /**
  91477. * Gets the class name of the material
  91478. * @returns a string with the class name of the material
  91479. */
  91480. getClassName(): string;
  91481. /**
  91482. * Specifies if updates for the material been locked
  91483. */
  91484. get isFrozen(): boolean;
  91485. /**
  91486. * Locks updates for the material
  91487. */
  91488. freeze(): void;
  91489. /**
  91490. * Unlocks updates for the material
  91491. */
  91492. unfreeze(): void;
  91493. /**
  91494. * Specifies if the material is ready to be used
  91495. * @param mesh defines the mesh to check
  91496. * @param useInstances specifies if instances should be used
  91497. * @returns a boolean indicating if the material is ready to be used
  91498. */
  91499. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91500. /**
  91501. * Specifies that the submesh is ready to be used
  91502. * @param mesh defines the mesh to check
  91503. * @param subMesh defines which submesh to check
  91504. * @param useInstances specifies that instances should be used
  91505. * @returns a boolean indicating that the submesh is ready or not
  91506. */
  91507. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91508. /**
  91509. * Returns the material effect
  91510. * @returns the effect associated with the material
  91511. */
  91512. getEffect(): Nullable<Effect>;
  91513. /**
  91514. * Returns the current scene
  91515. * @returns a Scene
  91516. */
  91517. getScene(): Scene;
  91518. /**
  91519. * Specifies if the material will require alpha blending
  91520. * @returns a boolean specifying if alpha blending is needed
  91521. */
  91522. needAlphaBlending(): boolean;
  91523. /**
  91524. * Specifies if the mesh will require alpha blending
  91525. * @param mesh defines the mesh to check
  91526. * @returns a boolean specifying if alpha blending is needed for the mesh
  91527. */
  91528. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  91529. /**
  91530. * Specifies if this material should be rendered in alpha test mode
  91531. * @returns a boolean specifying if an alpha test is needed.
  91532. */
  91533. needAlphaTesting(): boolean;
  91534. /**
  91535. * Gets the texture used for the alpha test
  91536. * @returns the texture to use for alpha testing
  91537. */
  91538. getAlphaTestTexture(): Nullable<BaseTexture>;
  91539. /**
  91540. * Marks the material to indicate that it needs to be re-calculated
  91541. */
  91542. markDirty(): void;
  91543. /** @hidden */
  91544. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  91545. /**
  91546. * Binds the material to the mesh
  91547. * @param world defines the world transformation matrix
  91548. * @param mesh defines the mesh to bind the material to
  91549. */
  91550. bind(world: Matrix, mesh?: Mesh): void;
  91551. /**
  91552. * Binds the submesh to the material
  91553. * @param world defines the world transformation matrix
  91554. * @param mesh defines the mesh containing the submesh
  91555. * @param subMesh defines the submesh to bind the material to
  91556. */
  91557. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91558. /**
  91559. * Binds the world matrix to the material
  91560. * @param world defines the world transformation matrix
  91561. */
  91562. bindOnlyWorldMatrix(world: Matrix): void;
  91563. /**
  91564. * Binds the scene's uniform buffer to the effect.
  91565. * @param effect defines the effect to bind to the scene uniform buffer
  91566. * @param sceneUbo defines the uniform buffer storing scene data
  91567. */
  91568. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  91569. /**
  91570. * Binds the view matrix to the effect
  91571. * @param effect defines the effect to bind the view matrix to
  91572. */
  91573. bindView(effect: Effect): void;
  91574. /**
  91575. * Binds the view projection matrix to the effect
  91576. * @param effect defines the effect to bind the view projection matrix to
  91577. */
  91578. bindViewProjection(effect: Effect): void;
  91579. /**
  91580. * Specifies if material alpha testing should be turned on for the mesh
  91581. * @param mesh defines the mesh to check
  91582. */
  91583. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  91584. /**
  91585. * Processes to execute after binding the material to a mesh
  91586. * @param mesh defines the rendered mesh
  91587. */
  91588. protected _afterBind(mesh?: Mesh): void;
  91589. /**
  91590. * Unbinds the material from the mesh
  91591. */
  91592. unbind(): void;
  91593. /**
  91594. * Gets the active textures from the material
  91595. * @returns an array of textures
  91596. */
  91597. getActiveTextures(): BaseTexture[];
  91598. /**
  91599. * Specifies if the material uses a texture
  91600. * @param texture defines the texture to check against the material
  91601. * @returns a boolean specifying if the material uses the texture
  91602. */
  91603. hasTexture(texture: BaseTexture): boolean;
  91604. /**
  91605. * Makes a duplicate of the material, and gives it a new name
  91606. * @param name defines the new name for the duplicated material
  91607. * @returns the cloned material
  91608. */
  91609. clone(name: string): Nullable<Material>;
  91610. /**
  91611. * Gets the meshes bound to the material
  91612. * @returns an array of meshes bound to the material
  91613. */
  91614. getBindedMeshes(): AbstractMesh[];
  91615. /**
  91616. * Force shader compilation
  91617. * @param mesh defines the mesh associated with this material
  91618. * @param onCompiled defines a function to execute once the material is compiled
  91619. * @param options defines the options to configure the compilation
  91620. * @param onError defines a function to execute if the material fails compiling
  91621. */
  91622. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  91623. /**
  91624. * Force shader compilation
  91625. * @param mesh defines the mesh that will use this material
  91626. * @param options defines additional options for compiling the shaders
  91627. * @returns a promise that resolves when the compilation completes
  91628. */
  91629. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  91630. private static readonly _AllDirtyCallBack;
  91631. private static readonly _ImageProcessingDirtyCallBack;
  91632. private static readonly _TextureDirtyCallBack;
  91633. private static readonly _FresnelDirtyCallBack;
  91634. private static readonly _MiscDirtyCallBack;
  91635. private static readonly _LightsDirtyCallBack;
  91636. private static readonly _AttributeDirtyCallBack;
  91637. private static _FresnelAndMiscDirtyCallBack;
  91638. private static _TextureAndMiscDirtyCallBack;
  91639. private static readonly _DirtyCallbackArray;
  91640. private static readonly _RunDirtyCallBacks;
  91641. /**
  91642. * Marks a define in the material to indicate that it needs to be re-computed
  91643. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  91644. */
  91645. markAsDirty(flag: number): void;
  91646. /**
  91647. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  91648. * @param func defines a function which checks material defines against the submeshes
  91649. */
  91650. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  91651. /**
  91652. * Indicates that we need to re-calculated for all submeshes
  91653. */
  91654. protected _markAllSubMeshesAsAllDirty(): void;
  91655. /**
  91656. * Indicates that image processing needs to be re-calculated for all submeshes
  91657. */
  91658. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  91659. /**
  91660. * Indicates that textures need to be re-calculated for all submeshes
  91661. */
  91662. protected _markAllSubMeshesAsTexturesDirty(): void;
  91663. /**
  91664. * Indicates that fresnel needs to be re-calculated for all submeshes
  91665. */
  91666. protected _markAllSubMeshesAsFresnelDirty(): void;
  91667. /**
  91668. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  91669. */
  91670. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  91671. /**
  91672. * Indicates that lights need to be re-calculated for all submeshes
  91673. */
  91674. protected _markAllSubMeshesAsLightsDirty(): void;
  91675. /**
  91676. * Indicates that attributes need to be re-calculated for all submeshes
  91677. */
  91678. protected _markAllSubMeshesAsAttributesDirty(): void;
  91679. /**
  91680. * Indicates that misc needs to be re-calculated for all submeshes
  91681. */
  91682. protected _markAllSubMeshesAsMiscDirty(): void;
  91683. /**
  91684. * Indicates that textures and misc need to be re-calculated for all submeshes
  91685. */
  91686. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  91687. /**
  91688. * Disposes the material
  91689. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91690. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91691. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91692. */
  91693. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91694. /** @hidden */
  91695. private releaseVertexArrayObject;
  91696. /**
  91697. * Serializes this material
  91698. * @returns the serialized material object
  91699. */
  91700. serialize(): any;
  91701. /**
  91702. * Creates a material from parsed material data
  91703. * @param parsedMaterial defines parsed material data
  91704. * @param scene defines the hosting scene
  91705. * @param rootUrl defines the root URL to use to load textures
  91706. * @returns a new material
  91707. */
  91708. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  91709. }
  91710. }
  91711. declare module BABYLON {
  91712. /**
  91713. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91714. * separate meshes. This can be use to improve performances.
  91715. * @see http://doc.babylonjs.com/how_to/multi_materials
  91716. */
  91717. export class MultiMaterial extends Material {
  91718. private _subMaterials;
  91719. /**
  91720. * Gets or Sets the list of Materials used within the multi material.
  91721. * They need to be ordered according to the submeshes order in the associated mesh
  91722. */
  91723. get subMaterials(): Nullable<Material>[];
  91724. set subMaterials(value: Nullable<Material>[]);
  91725. /**
  91726. * Function used to align with Node.getChildren()
  91727. * @returns the list of Materials used within the multi material
  91728. */
  91729. getChildren(): Nullable<Material>[];
  91730. /**
  91731. * Instantiates a new Multi Material
  91732. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91733. * separate meshes. This can be use to improve performances.
  91734. * @see http://doc.babylonjs.com/how_to/multi_materials
  91735. * @param name Define the name in the scene
  91736. * @param scene Define the scene the material belongs to
  91737. */
  91738. constructor(name: string, scene: Scene);
  91739. private _hookArray;
  91740. /**
  91741. * Get one of the submaterial by its index in the submaterials array
  91742. * @param index The index to look the sub material at
  91743. * @returns The Material if the index has been defined
  91744. */
  91745. getSubMaterial(index: number): Nullable<Material>;
  91746. /**
  91747. * Get the list of active textures for the whole sub materials list.
  91748. * @returns All the textures that will be used during the rendering
  91749. */
  91750. getActiveTextures(): BaseTexture[];
  91751. /**
  91752. * Gets the current class name of the material e.g. "MultiMaterial"
  91753. * Mainly use in serialization.
  91754. * @returns the class name
  91755. */
  91756. getClassName(): string;
  91757. /**
  91758. * Checks if the material is ready to render the requested sub mesh
  91759. * @param mesh Define the mesh the submesh belongs to
  91760. * @param subMesh Define the sub mesh to look readyness for
  91761. * @param useInstances Define whether or not the material is used with instances
  91762. * @returns true if ready, otherwise false
  91763. */
  91764. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91765. /**
  91766. * Clones the current material and its related sub materials
  91767. * @param name Define the name of the newly cloned material
  91768. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  91769. * @returns the cloned material
  91770. */
  91771. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  91772. /**
  91773. * Serializes the materials into a JSON representation.
  91774. * @returns the JSON representation
  91775. */
  91776. serialize(): any;
  91777. /**
  91778. * Dispose the material and release its associated resources
  91779. * @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)
  91780. * @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)
  91781. * @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)
  91782. */
  91783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  91784. /**
  91785. * Creates a MultiMaterial from parsed MultiMaterial data.
  91786. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  91787. * @param scene defines the hosting scene
  91788. * @returns a new MultiMaterial
  91789. */
  91790. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  91791. }
  91792. }
  91793. declare module BABYLON {
  91794. /**
  91795. * Base class for submeshes
  91796. */
  91797. export class BaseSubMesh {
  91798. /** @hidden */
  91799. _materialDefines: Nullable<MaterialDefines>;
  91800. /** @hidden */
  91801. _materialEffect: Nullable<Effect>;
  91802. /**
  91803. * Gets material defines used by the effect associated to the sub mesh
  91804. */
  91805. get materialDefines(): Nullable<MaterialDefines>;
  91806. /**
  91807. * Sets material defines used by the effect associated to the sub mesh
  91808. */
  91809. set materialDefines(defines: Nullable<MaterialDefines>);
  91810. /**
  91811. * Gets associated effect
  91812. */
  91813. get effect(): Nullable<Effect>;
  91814. /**
  91815. * Sets associated effect (effect used to render this submesh)
  91816. * @param effect defines the effect to associate with
  91817. * @param defines defines the set of defines used to compile this effect
  91818. */
  91819. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  91820. }
  91821. /**
  91822. * Defines a subdivision inside a mesh
  91823. */
  91824. export class SubMesh extends BaseSubMesh implements ICullable {
  91825. /** the material index to use */
  91826. materialIndex: number;
  91827. /** vertex index start */
  91828. verticesStart: number;
  91829. /** vertices count */
  91830. verticesCount: number;
  91831. /** index start */
  91832. indexStart: number;
  91833. /** indices count */
  91834. indexCount: number;
  91835. /** @hidden */
  91836. _linesIndexCount: number;
  91837. private _mesh;
  91838. private _renderingMesh;
  91839. private _boundingInfo;
  91840. private _linesIndexBuffer;
  91841. /** @hidden */
  91842. _lastColliderWorldVertices: Nullable<Vector3[]>;
  91843. /** @hidden */
  91844. _trianglePlanes: Plane[];
  91845. /** @hidden */
  91846. _lastColliderTransformMatrix: Nullable<Matrix>;
  91847. /** @hidden */
  91848. _renderId: number;
  91849. /** @hidden */
  91850. _alphaIndex: number;
  91851. /** @hidden */
  91852. _distanceToCamera: number;
  91853. /** @hidden */
  91854. _id: number;
  91855. private _currentMaterial;
  91856. /**
  91857. * Add a new submesh to a mesh
  91858. * @param materialIndex defines the material index to use
  91859. * @param verticesStart defines vertex index start
  91860. * @param verticesCount defines vertices count
  91861. * @param indexStart defines index start
  91862. * @param indexCount defines indices count
  91863. * @param mesh defines the parent mesh
  91864. * @param renderingMesh defines an optional rendering mesh
  91865. * @param createBoundingBox defines if bounding box should be created for this submesh
  91866. * @returns the new submesh
  91867. */
  91868. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  91869. /**
  91870. * Creates a new submesh
  91871. * @param materialIndex defines the material index to use
  91872. * @param verticesStart defines vertex index start
  91873. * @param verticesCount defines vertices count
  91874. * @param indexStart defines index start
  91875. * @param indexCount defines indices count
  91876. * @param mesh defines the parent mesh
  91877. * @param renderingMesh defines an optional rendering mesh
  91878. * @param createBoundingBox defines if bounding box should be created for this submesh
  91879. */
  91880. constructor(
  91881. /** the material index to use */
  91882. materialIndex: number,
  91883. /** vertex index start */
  91884. verticesStart: number,
  91885. /** vertices count */
  91886. verticesCount: number,
  91887. /** index start */
  91888. indexStart: number,
  91889. /** indices count */
  91890. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  91891. /**
  91892. * Returns true if this submesh covers the entire parent mesh
  91893. * @ignorenaming
  91894. */
  91895. get IsGlobal(): boolean;
  91896. /**
  91897. * Returns the submesh BoudingInfo object
  91898. * @returns current bounding info (or mesh's one if the submesh is global)
  91899. */
  91900. getBoundingInfo(): BoundingInfo;
  91901. /**
  91902. * Sets the submesh BoundingInfo
  91903. * @param boundingInfo defines the new bounding info to use
  91904. * @returns the SubMesh
  91905. */
  91906. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  91907. /**
  91908. * Returns the mesh of the current submesh
  91909. * @return the parent mesh
  91910. */
  91911. getMesh(): AbstractMesh;
  91912. /**
  91913. * Returns the rendering mesh of the submesh
  91914. * @returns the rendering mesh (could be different from parent mesh)
  91915. */
  91916. getRenderingMesh(): Mesh;
  91917. /**
  91918. * Returns the submesh material
  91919. * @returns null or the current material
  91920. */
  91921. getMaterial(): Nullable<Material>;
  91922. /**
  91923. * Sets a new updated BoundingInfo object to the submesh
  91924. * @param data defines an optional position array to use to determine the bounding info
  91925. * @returns the SubMesh
  91926. */
  91927. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  91928. /** @hidden */
  91929. _checkCollision(collider: Collider): boolean;
  91930. /**
  91931. * Updates the submesh BoundingInfo
  91932. * @param world defines the world matrix to use to update the bounding info
  91933. * @returns the submesh
  91934. */
  91935. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  91936. /**
  91937. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  91938. * @param frustumPlanes defines the frustum planes
  91939. * @returns true if the submesh is intersecting with the frustum
  91940. */
  91941. isInFrustum(frustumPlanes: Plane[]): boolean;
  91942. /**
  91943. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  91944. * @param frustumPlanes defines the frustum planes
  91945. * @returns true if the submesh is inside the frustum
  91946. */
  91947. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91948. /**
  91949. * Renders the submesh
  91950. * @param enableAlphaMode defines if alpha needs to be used
  91951. * @returns the submesh
  91952. */
  91953. render(enableAlphaMode: boolean): SubMesh;
  91954. /**
  91955. * @hidden
  91956. */
  91957. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  91958. /**
  91959. * Checks if the submesh intersects with a ray
  91960. * @param ray defines the ray to test
  91961. * @returns true is the passed ray intersects the submesh bounding box
  91962. */
  91963. canIntersects(ray: Ray): boolean;
  91964. /**
  91965. * Intersects current submesh with a ray
  91966. * @param ray defines the ray to test
  91967. * @param positions defines mesh's positions array
  91968. * @param indices defines mesh's indices array
  91969. * @param fastCheck defines if only bounding info should be used
  91970. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91971. * @returns intersection info or null if no intersection
  91972. */
  91973. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  91974. /** @hidden */
  91975. private _intersectLines;
  91976. /** @hidden */
  91977. private _intersectUnIndexedLines;
  91978. /** @hidden */
  91979. private _intersectTriangles;
  91980. /** @hidden */
  91981. private _intersectUnIndexedTriangles;
  91982. /** @hidden */
  91983. _rebuild(): void;
  91984. /**
  91985. * Creates a new submesh from the passed mesh
  91986. * @param newMesh defines the new hosting mesh
  91987. * @param newRenderingMesh defines an optional rendering mesh
  91988. * @returns the new submesh
  91989. */
  91990. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  91991. /**
  91992. * Release associated resources
  91993. */
  91994. dispose(): void;
  91995. /**
  91996. * Gets the class name
  91997. * @returns the string "SubMesh".
  91998. */
  91999. getClassName(): string;
  92000. /**
  92001. * Creates a new submesh from indices data
  92002. * @param materialIndex the index of the main mesh material
  92003. * @param startIndex the index where to start the copy in the mesh indices array
  92004. * @param indexCount the number of indices to copy then from the startIndex
  92005. * @param mesh the main mesh to create the submesh from
  92006. * @param renderingMesh the optional rendering mesh
  92007. * @returns a new submesh
  92008. */
  92009. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  92010. }
  92011. }
  92012. declare module BABYLON {
  92013. /**
  92014. * Class used to represent data loading progression
  92015. */
  92016. export class SceneLoaderFlags {
  92017. private static _ForceFullSceneLoadingForIncremental;
  92018. private static _ShowLoadingScreen;
  92019. private static _CleanBoneMatrixWeights;
  92020. private static _loggingLevel;
  92021. /**
  92022. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92023. */
  92024. static get ForceFullSceneLoadingForIncremental(): boolean;
  92025. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92026. /**
  92027. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92028. */
  92029. static get ShowLoadingScreen(): boolean;
  92030. static set ShowLoadingScreen(value: boolean);
  92031. /**
  92032. * Defines the current logging level (while loading the scene)
  92033. * @ignorenaming
  92034. */
  92035. static get loggingLevel(): number;
  92036. static set loggingLevel(value: number);
  92037. /**
  92038. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92039. */
  92040. static get CleanBoneMatrixWeights(): boolean;
  92041. static set CleanBoneMatrixWeights(value: boolean);
  92042. }
  92043. }
  92044. declare module BABYLON {
  92045. /**
  92046. * Class used to store geometry data (vertex buffers + index buffer)
  92047. */
  92048. export class Geometry implements IGetSetVerticesData {
  92049. /**
  92050. * Gets or sets the ID of the geometry
  92051. */
  92052. id: string;
  92053. /**
  92054. * Gets or sets the unique ID of the geometry
  92055. */
  92056. uniqueId: number;
  92057. /**
  92058. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92059. */
  92060. delayLoadState: number;
  92061. /**
  92062. * Gets the file containing the data to load when running in delay load state
  92063. */
  92064. delayLoadingFile: Nullable<string>;
  92065. /**
  92066. * Callback called when the geometry is updated
  92067. */
  92068. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92069. private _scene;
  92070. private _engine;
  92071. private _meshes;
  92072. private _totalVertices;
  92073. /** @hidden */
  92074. _indices: IndicesArray;
  92075. /** @hidden */
  92076. _vertexBuffers: {
  92077. [key: string]: VertexBuffer;
  92078. };
  92079. private _isDisposed;
  92080. private _extend;
  92081. private _boundingBias;
  92082. /** @hidden */
  92083. _delayInfo: Array<string>;
  92084. private _indexBuffer;
  92085. private _indexBufferIsUpdatable;
  92086. /** @hidden */
  92087. _boundingInfo: Nullable<BoundingInfo>;
  92088. /** @hidden */
  92089. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92090. /** @hidden */
  92091. _softwareSkinningFrameId: number;
  92092. private _vertexArrayObjects;
  92093. private _updatable;
  92094. /** @hidden */
  92095. _positions: Nullable<Vector3[]>;
  92096. /**
  92097. * 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
  92098. */
  92099. get boundingBias(): Vector2;
  92100. /**
  92101. * 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
  92102. */
  92103. set boundingBias(value: Vector2);
  92104. /**
  92105. * Static function used to attach a new empty geometry to a mesh
  92106. * @param mesh defines the mesh to attach the geometry to
  92107. * @returns the new Geometry
  92108. */
  92109. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92110. /**
  92111. * Creates a new geometry
  92112. * @param id defines the unique ID
  92113. * @param scene defines the hosting scene
  92114. * @param vertexData defines the VertexData used to get geometry data
  92115. * @param updatable defines if geometry must be updatable (false by default)
  92116. * @param mesh defines the mesh that will be associated with the geometry
  92117. */
  92118. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92119. /**
  92120. * Gets the current extend of the geometry
  92121. */
  92122. get extend(): {
  92123. minimum: Vector3;
  92124. maximum: Vector3;
  92125. };
  92126. /**
  92127. * Gets the hosting scene
  92128. * @returns the hosting Scene
  92129. */
  92130. getScene(): Scene;
  92131. /**
  92132. * Gets the hosting engine
  92133. * @returns the hosting Engine
  92134. */
  92135. getEngine(): Engine;
  92136. /**
  92137. * Defines if the geometry is ready to use
  92138. * @returns true if the geometry is ready to be used
  92139. */
  92140. isReady(): boolean;
  92141. /**
  92142. * Gets a value indicating that the geometry should not be serialized
  92143. */
  92144. get doNotSerialize(): boolean;
  92145. /** @hidden */
  92146. _rebuild(): void;
  92147. /**
  92148. * Affects all geometry data in one call
  92149. * @param vertexData defines the geometry data
  92150. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92151. */
  92152. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92153. /**
  92154. * Set specific vertex data
  92155. * @param kind defines the data kind (Position, normal, etc...)
  92156. * @param data defines the vertex data to use
  92157. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92158. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92159. */
  92160. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92161. /**
  92162. * Removes a specific vertex data
  92163. * @param kind defines the data kind (Position, normal, etc...)
  92164. */
  92165. removeVerticesData(kind: string): void;
  92166. /**
  92167. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92168. * @param buffer defines the vertex buffer to use
  92169. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92170. */
  92171. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92172. /**
  92173. * Update a specific vertex buffer
  92174. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92175. * It will do nothing if the buffer is not updatable
  92176. * @param kind defines the data kind (Position, normal, etc...)
  92177. * @param data defines the data to use
  92178. * @param offset defines the offset in the target buffer where to store the data
  92179. * @param useBytes set to true if the offset is in bytes
  92180. */
  92181. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  92182. /**
  92183. * Update a specific vertex buffer
  92184. * This function will create a new buffer if the current one is not updatable
  92185. * @param kind defines the data kind (Position, normal, etc...)
  92186. * @param data defines the data to use
  92187. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  92188. */
  92189. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  92190. private _updateBoundingInfo;
  92191. /** @hidden */
  92192. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  92193. /**
  92194. * Gets total number of vertices
  92195. * @returns the total number of vertices
  92196. */
  92197. getTotalVertices(): number;
  92198. /**
  92199. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92200. * @param kind defines the data kind (Position, normal, etc...)
  92201. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92202. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92203. * @returns a float array containing vertex data
  92204. */
  92205. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92206. /**
  92207. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  92208. * @param kind defines the data kind (Position, normal, etc...)
  92209. * @returns true if the vertex buffer with the specified kind is updatable
  92210. */
  92211. isVertexBufferUpdatable(kind: string): boolean;
  92212. /**
  92213. * Gets a specific vertex buffer
  92214. * @param kind defines the data kind (Position, normal, etc...)
  92215. * @returns a VertexBuffer
  92216. */
  92217. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92218. /**
  92219. * Returns all vertex buffers
  92220. * @return an object holding all vertex buffers indexed by kind
  92221. */
  92222. getVertexBuffers(): Nullable<{
  92223. [key: string]: VertexBuffer;
  92224. }>;
  92225. /**
  92226. * Gets a boolean indicating if specific vertex buffer is present
  92227. * @param kind defines the data kind (Position, normal, etc...)
  92228. * @returns true if data is present
  92229. */
  92230. isVerticesDataPresent(kind: string): boolean;
  92231. /**
  92232. * Gets a list of all attached data kinds (Position, normal, etc...)
  92233. * @returns a list of string containing all kinds
  92234. */
  92235. getVerticesDataKinds(): string[];
  92236. /**
  92237. * Update index buffer
  92238. * @param indices defines the indices to store in the index buffer
  92239. * @param offset defines the offset in the target buffer where to store the data
  92240. * @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)
  92241. */
  92242. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  92243. /**
  92244. * Creates a new index buffer
  92245. * @param indices defines the indices to store in the index buffer
  92246. * @param totalVertices defines the total number of vertices (could be null)
  92247. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92248. */
  92249. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  92250. /**
  92251. * Return the total number of indices
  92252. * @returns the total number of indices
  92253. */
  92254. getTotalIndices(): number;
  92255. /**
  92256. * Gets the index buffer array
  92257. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92258. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92259. * @returns the index buffer array
  92260. */
  92261. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92262. /**
  92263. * Gets the index buffer
  92264. * @return the index buffer
  92265. */
  92266. getIndexBuffer(): Nullable<DataBuffer>;
  92267. /** @hidden */
  92268. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  92269. /**
  92270. * Release the associated resources for a specific mesh
  92271. * @param mesh defines the source mesh
  92272. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  92273. */
  92274. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  92275. /**
  92276. * Apply current geometry to a given mesh
  92277. * @param mesh defines the mesh to apply geometry to
  92278. */
  92279. applyToMesh(mesh: Mesh): void;
  92280. private _updateExtend;
  92281. private _applyToMesh;
  92282. private notifyUpdate;
  92283. /**
  92284. * Load the geometry if it was flagged as delay loaded
  92285. * @param scene defines the hosting scene
  92286. * @param onLoaded defines a callback called when the geometry is loaded
  92287. */
  92288. load(scene: Scene, onLoaded?: () => void): void;
  92289. private _queueLoad;
  92290. /**
  92291. * Invert the geometry to move from a right handed system to a left handed one.
  92292. */
  92293. toLeftHanded(): void;
  92294. /** @hidden */
  92295. _resetPointsArrayCache(): void;
  92296. /** @hidden */
  92297. _generatePointsArray(): boolean;
  92298. /**
  92299. * Gets a value indicating if the geometry is disposed
  92300. * @returns true if the geometry was disposed
  92301. */
  92302. isDisposed(): boolean;
  92303. private _disposeVertexArrayObjects;
  92304. /**
  92305. * Free all associated resources
  92306. */
  92307. dispose(): void;
  92308. /**
  92309. * Clone the current geometry into a new geometry
  92310. * @param id defines the unique ID of the new geometry
  92311. * @returns a new geometry object
  92312. */
  92313. copy(id: string): Geometry;
  92314. /**
  92315. * Serialize the current geometry info (and not the vertices data) into a JSON object
  92316. * @return a JSON representation of the current geometry data (without the vertices data)
  92317. */
  92318. serialize(): any;
  92319. private toNumberArray;
  92320. /**
  92321. * Serialize all vertices data into a JSON oject
  92322. * @returns a JSON representation of the current geometry data
  92323. */
  92324. serializeVerticeData(): any;
  92325. /**
  92326. * Extracts a clone of a mesh geometry
  92327. * @param mesh defines the source mesh
  92328. * @param id defines the unique ID of the new geometry object
  92329. * @returns the new geometry object
  92330. */
  92331. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  92332. /**
  92333. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  92334. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92335. * Be aware Math.random() could cause collisions, but:
  92336. * "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"
  92337. * @returns a string containing a new GUID
  92338. */
  92339. static RandomId(): string;
  92340. /** @hidden */
  92341. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  92342. private static _CleanMatricesWeights;
  92343. /**
  92344. * Create a new geometry from persisted data (Using .babylon file format)
  92345. * @param parsedVertexData defines the persisted data
  92346. * @param scene defines the hosting scene
  92347. * @param rootUrl defines the root url to use to load assets (like delayed data)
  92348. * @returns the new geometry object
  92349. */
  92350. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  92351. }
  92352. }
  92353. declare module BABYLON {
  92354. /**
  92355. * Define an interface for all classes that will get and set the data on vertices
  92356. */
  92357. export interface IGetSetVerticesData {
  92358. /**
  92359. * Gets a boolean indicating if specific vertex data is present
  92360. * @param kind defines the vertex data kind to use
  92361. * @returns true is data kind is present
  92362. */
  92363. isVerticesDataPresent(kind: string): boolean;
  92364. /**
  92365. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92366. * @param kind defines the data kind (Position, normal, etc...)
  92367. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92368. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92369. * @returns a float array containing vertex data
  92370. */
  92371. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92372. /**
  92373. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92374. * @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.
  92375. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92376. * @returns the indices array or an empty array if the mesh has no geometry
  92377. */
  92378. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92379. /**
  92380. * Set specific vertex data
  92381. * @param kind defines the data kind (Position, normal, etc...)
  92382. * @param data defines the vertex data to use
  92383. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92384. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92385. */
  92386. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  92387. /**
  92388. * Update a specific associated vertex buffer
  92389. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92390. * - VertexBuffer.PositionKind
  92391. * - VertexBuffer.UVKind
  92392. * - VertexBuffer.UV2Kind
  92393. * - VertexBuffer.UV3Kind
  92394. * - VertexBuffer.UV4Kind
  92395. * - VertexBuffer.UV5Kind
  92396. * - VertexBuffer.UV6Kind
  92397. * - VertexBuffer.ColorKind
  92398. * - VertexBuffer.MatricesIndicesKind
  92399. * - VertexBuffer.MatricesIndicesExtraKind
  92400. * - VertexBuffer.MatricesWeightsKind
  92401. * - VertexBuffer.MatricesWeightsExtraKind
  92402. * @param data defines the data source
  92403. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92404. * @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)
  92405. */
  92406. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  92407. /**
  92408. * Creates a new index buffer
  92409. * @param indices defines the indices to store in the index buffer
  92410. * @param totalVertices defines the total number of vertices (could be null)
  92411. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92412. */
  92413. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  92414. }
  92415. /**
  92416. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  92417. */
  92418. export class VertexData {
  92419. /**
  92420. * Mesh side orientation : usually the external or front surface
  92421. */
  92422. static readonly FRONTSIDE: number;
  92423. /**
  92424. * Mesh side orientation : usually the internal or back surface
  92425. */
  92426. static readonly BACKSIDE: number;
  92427. /**
  92428. * Mesh side orientation : both internal and external or front and back surfaces
  92429. */
  92430. static readonly DOUBLESIDE: number;
  92431. /**
  92432. * Mesh side orientation : by default, `FRONTSIDE`
  92433. */
  92434. static readonly DEFAULTSIDE: number;
  92435. /**
  92436. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  92437. */
  92438. positions: Nullable<FloatArray>;
  92439. /**
  92440. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  92441. */
  92442. normals: Nullable<FloatArray>;
  92443. /**
  92444. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  92445. */
  92446. tangents: Nullable<FloatArray>;
  92447. /**
  92448. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92449. */
  92450. uvs: Nullable<FloatArray>;
  92451. /**
  92452. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92453. */
  92454. uvs2: Nullable<FloatArray>;
  92455. /**
  92456. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92457. */
  92458. uvs3: Nullable<FloatArray>;
  92459. /**
  92460. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92461. */
  92462. uvs4: Nullable<FloatArray>;
  92463. /**
  92464. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92465. */
  92466. uvs5: Nullable<FloatArray>;
  92467. /**
  92468. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92469. */
  92470. uvs6: Nullable<FloatArray>;
  92471. /**
  92472. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  92473. */
  92474. colors: Nullable<FloatArray>;
  92475. /**
  92476. * 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).
  92477. */
  92478. matricesIndices: Nullable<FloatArray>;
  92479. /**
  92480. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  92481. */
  92482. matricesWeights: Nullable<FloatArray>;
  92483. /**
  92484. * An array extending the number of possible indices
  92485. */
  92486. matricesIndicesExtra: Nullable<FloatArray>;
  92487. /**
  92488. * An array extending the number of possible weights when the number of indices is extended
  92489. */
  92490. matricesWeightsExtra: Nullable<FloatArray>;
  92491. /**
  92492. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  92493. */
  92494. indices: Nullable<IndicesArray>;
  92495. /**
  92496. * Uses the passed data array to set the set the values for the specified kind of data
  92497. * @param data a linear array of floating numbers
  92498. * @param kind the type of data that is being set, eg positions, colors etc
  92499. */
  92500. set(data: FloatArray, kind: string): void;
  92501. /**
  92502. * Associates the vertexData to the passed Mesh.
  92503. * Sets it as updatable or not (default `false`)
  92504. * @param mesh the mesh the vertexData is applied to
  92505. * @param updatable when used and having the value true allows new data to update the vertexData
  92506. * @returns the VertexData
  92507. */
  92508. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  92509. /**
  92510. * Associates the vertexData to the passed Geometry.
  92511. * Sets it as updatable or not (default `false`)
  92512. * @param geometry the geometry the vertexData is applied to
  92513. * @param updatable when used and having the value true allows new data to update the vertexData
  92514. * @returns VertexData
  92515. */
  92516. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  92517. /**
  92518. * Updates the associated mesh
  92519. * @param mesh the mesh to be updated
  92520. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92521. * @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
  92522. * @returns VertexData
  92523. */
  92524. updateMesh(mesh: Mesh): VertexData;
  92525. /**
  92526. * Updates the associated geometry
  92527. * @param geometry the geometry to be updated
  92528. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92529. * @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
  92530. * @returns VertexData.
  92531. */
  92532. updateGeometry(geometry: Geometry): VertexData;
  92533. private _applyTo;
  92534. private _update;
  92535. /**
  92536. * Transforms each position and each normal of the vertexData according to the passed Matrix
  92537. * @param matrix the transforming matrix
  92538. * @returns the VertexData
  92539. */
  92540. transform(matrix: Matrix): VertexData;
  92541. /**
  92542. * Merges the passed VertexData into the current one
  92543. * @param other the VertexData to be merged into the current one
  92544. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  92545. * @returns the modified VertexData
  92546. */
  92547. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  92548. private _mergeElement;
  92549. private _validate;
  92550. /**
  92551. * Serializes the VertexData
  92552. * @returns a serialized object
  92553. */
  92554. serialize(): any;
  92555. /**
  92556. * Extracts the vertexData from a mesh
  92557. * @param mesh the mesh from which to extract the VertexData
  92558. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  92559. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92560. * @returns the object VertexData associated to the passed mesh
  92561. */
  92562. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92563. /**
  92564. * Extracts the vertexData from the geometry
  92565. * @param geometry the geometry from which to extract the VertexData
  92566. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  92567. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92568. * @returns the object VertexData associated to the passed mesh
  92569. */
  92570. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92571. private static _ExtractFrom;
  92572. /**
  92573. * Creates the VertexData for a Ribbon
  92574. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  92575. * * pathArray array of paths, each of which an array of successive Vector3
  92576. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  92577. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  92578. * * 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
  92579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92580. * * 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)
  92581. * * 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)
  92582. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  92583. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  92584. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  92585. * @returns the VertexData of the ribbon
  92586. */
  92587. static CreateRibbon(options: {
  92588. pathArray: Vector3[][];
  92589. closeArray?: boolean;
  92590. closePath?: boolean;
  92591. offset?: number;
  92592. sideOrientation?: number;
  92593. frontUVs?: Vector4;
  92594. backUVs?: Vector4;
  92595. invertUV?: boolean;
  92596. uvs?: Vector2[];
  92597. colors?: Color4[];
  92598. }): VertexData;
  92599. /**
  92600. * Creates the VertexData for a box
  92601. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92602. * * size sets the width, height and depth of the box to the value of size, optional default 1
  92603. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  92604. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  92605. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  92606. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92607. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92608. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92609. * * 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)
  92610. * * 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)
  92611. * @returns the VertexData of the box
  92612. */
  92613. static CreateBox(options: {
  92614. size?: number;
  92615. width?: number;
  92616. height?: number;
  92617. depth?: number;
  92618. faceUV?: Vector4[];
  92619. faceColors?: Color4[];
  92620. sideOrientation?: number;
  92621. frontUVs?: Vector4;
  92622. backUVs?: Vector4;
  92623. }): VertexData;
  92624. /**
  92625. * Creates the VertexData for a tiled box
  92626. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92627. * * faceTiles sets the pattern, tile size and number of tiles for a face
  92628. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92629. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92631. * @returns the VertexData of the box
  92632. */
  92633. static CreateTiledBox(options: {
  92634. pattern?: number;
  92635. width?: number;
  92636. height?: number;
  92637. depth?: number;
  92638. tileSize?: number;
  92639. tileWidth?: number;
  92640. tileHeight?: number;
  92641. alignHorizontal?: number;
  92642. alignVertical?: number;
  92643. faceUV?: Vector4[];
  92644. faceColors?: Color4[];
  92645. sideOrientation?: number;
  92646. }): VertexData;
  92647. /**
  92648. * Creates the VertexData for a tiled plane
  92649. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92650. * * pattern a limited pattern arrangement depending on the number
  92651. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  92652. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  92653. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  92654. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92655. * * 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)
  92656. * * 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)
  92657. * @returns the VertexData of the tiled plane
  92658. */
  92659. static CreateTiledPlane(options: {
  92660. pattern?: number;
  92661. tileSize?: number;
  92662. tileWidth?: number;
  92663. tileHeight?: number;
  92664. size?: number;
  92665. width?: number;
  92666. height?: number;
  92667. alignHorizontal?: number;
  92668. alignVertical?: number;
  92669. sideOrientation?: number;
  92670. frontUVs?: Vector4;
  92671. backUVs?: Vector4;
  92672. }): VertexData;
  92673. /**
  92674. * Creates the VertexData for an ellipsoid, defaults to a sphere
  92675. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92676. * * segments sets the number of horizontal strips optional, default 32
  92677. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  92678. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  92679. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  92680. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  92681. * * 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
  92682. * * 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
  92683. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92684. * * 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)
  92685. * * 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)
  92686. * @returns the VertexData of the ellipsoid
  92687. */
  92688. static CreateSphere(options: {
  92689. segments?: number;
  92690. diameter?: number;
  92691. diameterX?: number;
  92692. diameterY?: number;
  92693. diameterZ?: number;
  92694. arc?: number;
  92695. slice?: number;
  92696. sideOrientation?: number;
  92697. frontUVs?: Vector4;
  92698. backUVs?: Vector4;
  92699. }): VertexData;
  92700. /**
  92701. * Creates the VertexData for a cylinder, cone or prism
  92702. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92703. * * height sets the height (y direction) of the cylinder, optional, default 2
  92704. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  92705. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  92706. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  92707. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92708. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  92709. * * 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
  92710. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92711. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92712. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  92713. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  92714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92715. * * 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)
  92716. * * 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)
  92717. * @returns the VertexData of the cylinder, cone or prism
  92718. */
  92719. static CreateCylinder(options: {
  92720. height?: number;
  92721. diameterTop?: number;
  92722. diameterBottom?: number;
  92723. diameter?: number;
  92724. tessellation?: number;
  92725. subdivisions?: number;
  92726. arc?: number;
  92727. faceColors?: Color4[];
  92728. faceUV?: Vector4[];
  92729. hasRings?: boolean;
  92730. enclose?: boolean;
  92731. sideOrientation?: number;
  92732. frontUVs?: Vector4;
  92733. backUVs?: Vector4;
  92734. }): VertexData;
  92735. /**
  92736. * Creates the VertexData for a torus
  92737. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92738. * * diameter the diameter of the torus, optional default 1
  92739. * * thickness the diameter of the tube forming the torus, optional default 0.5
  92740. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92742. * * 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)
  92743. * * 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)
  92744. * @returns the VertexData of the torus
  92745. */
  92746. static CreateTorus(options: {
  92747. diameter?: number;
  92748. thickness?: number;
  92749. tessellation?: number;
  92750. sideOrientation?: number;
  92751. frontUVs?: Vector4;
  92752. backUVs?: Vector4;
  92753. }): VertexData;
  92754. /**
  92755. * Creates the VertexData of the LineSystem
  92756. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  92757. * - lines an array of lines, each line being an array of successive Vector3
  92758. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  92759. * @returns the VertexData of the LineSystem
  92760. */
  92761. static CreateLineSystem(options: {
  92762. lines: Vector3[][];
  92763. colors?: Nullable<Color4[][]>;
  92764. }): VertexData;
  92765. /**
  92766. * Create the VertexData for a DashedLines
  92767. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  92768. * - points an array successive Vector3
  92769. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  92770. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  92771. * - dashNb the intended total number of dashes, optional, default 200
  92772. * @returns the VertexData for the DashedLines
  92773. */
  92774. static CreateDashedLines(options: {
  92775. points: Vector3[];
  92776. dashSize?: number;
  92777. gapSize?: number;
  92778. dashNb?: number;
  92779. }): VertexData;
  92780. /**
  92781. * Creates the VertexData for a Ground
  92782. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92783. * - width the width (x direction) of the ground, optional, default 1
  92784. * - height the height (z direction) of the ground, optional, default 1
  92785. * - subdivisions the number of subdivisions per side, optional, default 1
  92786. * @returns the VertexData of the Ground
  92787. */
  92788. static CreateGround(options: {
  92789. width?: number;
  92790. height?: number;
  92791. subdivisions?: number;
  92792. subdivisionsX?: number;
  92793. subdivisionsY?: number;
  92794. }): VertexData;
  92795. /**
  92796. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  92797. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92798. * * xmin the ground minimum X coordinate, optional, default -1
  92799. * * zmin the ground minimum Z coordinate, optional, default -1
  92800. * * xmax the ground maximum X coordinate, optional, default 1
  92801. * * zmax the ground maximum Z coordinate, optional, default 1
  92802. * * 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}
  92803. * * 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}
  92804. * @returns the VertexData of the TiledGround
  92805. */
  92806. static CreateTiledGround(options: {
  92807. xmin: number;
  92808. zmin: number;
  92809. xmax: number;
  92810. zmax: number;
  92811. subdivisions?: {
  92812. w: number;
  92813. h: number;
  92814. };
  92815. precision?: {
  92816. w: number;
  92817. h: number;
  92818. };
  92819. }): VertexData;
  92820. /**
  92821. * Creates the VertexData of the Ground designed from a heightmap
  92822. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  92823. * * width the width (x direction) of the ground
  92824. * * height the height (z direction) of the ground
  92825. * * subdivisions the number of subdivisions per side
  92826. * * minHeight the minimum altitude on the ground, optional, default 0
  92827. * * maxHeight the maximum altitude on the ground, optional default 1
  92828. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  92829. * * buffer the array holding the image color data
  92830. * * bufferWidth the width of image
  92831. * * bufferHeight the height of image
  92832. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  92833. * @returns the VertexData of the Ground designed from a heightmap
  92834. */
  92835. static CreateGroundFromHeightMap(options: {
  92836. width: number;
  92837. height: number;
  92838. subdivisions: number;
  92839. minHeight: number;
  92840. maxHeight: number;
  92841. colorFilter: Color3;
  92842. buffer: Uint8Array;
  92843. bufferWidth: number;
  92844. bufferHeight: number;
  92845. alphaFilter: number;
  92846. }): VertexData;
  92847. /**
  92848. * Creates the VertexData for a Plane
  92849. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  92850. * * size sets the width and height of the plane to the value of size, optional default 1
  92851. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  92852. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  92853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92854. * * 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)
  92855. * * 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)
  92856. * @returns the VertexData of the box
  92857. */
  92858. static CreatePlane(options: {
  92859. size?: number;
  92860. width?: number;
  92861. height?: number;
  92862. sideOrientation?: number;
  92863. frontUVs?: Vector4;
  92864. backUVs?: Vector4;
  92865. }): VertexData;
  92866. /**
  92867. * Creates the VertexData of the Disc or regular Polygon
  92868. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  92869. * * radius the radius of the disc, optional default 0.5
  92870. * * tessellation the number of polygon sides, optional, default 64
  92871. * * 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
  92872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92873. * * 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)
  92874. * * 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)
  92875. * @returns the VertexData of the box
  92876. */
  92877. static CreateDisc(options: {
  92878. radius?: number;
  92879. tessellation?: number;
  92880. arc?: number;
  92881. sideOrientation?: number;
  92882. frontUVs?: Vector4;
  92883. backUVs?: Vector4;
  92884. }): VertexData;
  92885. /**
  92886. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  92887. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  92888. * @param polygon a mesh built from polygonTriangulation.build()
  92889. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92890. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92891. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92892. * @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)
  92893. * @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)
  92894. * @returns the VertexData of the Polygon
  92895. */
  92896. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  92897. /**
  92898. * Creates the VertexData of the IcoSphere
  92899. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  92900. * * radius the radius of the IcoSphere, optional default 1
  92901. * * radiusX allows stretching in the x direction, optional, default radius
  92902. * * radiusY allows stretching in the y direction, optional, default radius
  92903. * * radiusZ allows stretching in the z direction, optional, default radius
  92904. * * flat when true creates a flat shaded mesh, optional, default true
  92905. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92907. * * 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)
  92908. * * 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)
  92909. * @returns the VertexData of the IcoSphere
  92910. */
  92911. static CreateIcoSphere(options: {
  92912. radius?: number;
  92913. radiusX?: number;
  92914. radiusY?: number;
  92915. radiusZ?: number;
  92916. flat?: boolean;
  92917. subdivisions?: number;
  92918. sideOrientation?: number;
  92919. frontUVs?: Vector4;
  92920. backUVs?: Vector4;
  92921. }): VertexData;
  92922. /**
  92923. * Creates the VertexData for a Polyhedron
  92924. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  92925. * * type provided types are:
  92926. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  92927. * * 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)
  92928. * * size the size of the IcoSphere, optional default 1
  92929. * * sizeX allows stretching in the x direction, optional, default size
  92930. * * sizeY allows stretching in the y direction, optional, default size
  92931. * * sizeZ allows stretching in the z direction, optional, default size
  92932. * * 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
  92933. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92934. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92935. * * flat when true creates a flat shaded mesh, optional, default true
  92936. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92938. * * 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)
  92939. * * 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)
  92940. * @returns the VertexData of the Polyhedron
  92941. */
  92942. static CreatePolyhedron(options: {
  92943. type?: number;
  92944. size?: number;
  92945. sizeX?: number;
  92946. sizeY?: number;
  92947. sizeZ?: number;
  92948. custom?: any;
  92949. faceUV?: Vector4[];
  92950. faceColors?: Color4[];
  92951. flat?: boolean;
  92952. sideOrientation?: number;
  92953. frontUVs?: Vector4;
  92954. backUVs?: Vector4;
  92955. }): VertexData;
  92956. /**
  92957. * Creates the VertexData for a TorusKnot
  92958. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  92959. * * radius the radius of the torus knot, optional, default 2
  92960. * * tube the thickness of the tube, optional, default 0.5
  92961. * * radialSegments the number of sides on each tube segments, optional, default 32
  92962. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  92963. * * p the number of windings around the z axis, optional, default 2
  92964. * * q the number of windings around the x axis, optional, default 3
  92965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92966. * * 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)
  92967. * * 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)
  92968. * @returns the VertexData of the Torus Knot
  92969. */
  92970. static CreateTorusKnot(options: {
  92971. radius?: number;
  92972. tube?: number;
  92973. radialSegments?: number;
  92974. tubularSegments?: number;
  92975. p?: number;
  92976. q?: number;
  92977. sideOrientation?: number;
  92978. frontUVs?: Vector4;
  92979. backUVs?: Vector4;
  92980. }): VertexData;
  92981. /**
  92982. * Compute normals for given positions and indices
  92983. * @param positions an array of vertex positions, [...., x, y, z, ......]
  92984. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  92985. * @param normals an array of vertex normals, [...., x, y, z, ......]
  92986. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  92987. * * facetNormals : optional array of facet normals (vector3)
  92988. * * facetPositions : optional array of facet positions (vector3)
  92989. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  92990. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  92991. * * bInfo : optional bounding info, required for facetPartitioning computation
  92992. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  92993. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  92994. * * useRightHandedSystem: optional boolean to for right handed system computation
  92995. * * depthSort : optional boolean to enable the facet depth sort computation
  92996. * * distanceTo : optional Vector3 to compute the facet depth from this location
  92997. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  92998. */
  92999. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  93000. facetNormals?: any;
  93001. facetPositions?: any;
  93002. facetPartitioning?: any;
  93003. ratio?: number;
  93004. bInfo?: any;
  93005. bbSize?: Vector3;
  93006. subDiv?: any;
  93007. useRightHandedSystem?: boolean;
  93008. depthSort?: boolean;
  93009. distanceTo?: Vector3;
  93010. depthSortedFacets?: any;
  93011. }): void;
  93012. /** @hidden */
  93013. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  93014. /**
  93015. * Applies VertexData created from the imported parameters to the geometry
  93016. * @param parsedVertexData the parsed data from an imported file
  93017. * @param geometry the geometry to apply the VertexData to
  93018. */
  93019. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  93020. }
  93021. }
  93022. declare module BABYLON {
  93023. /**
  93024. * Defines a target to use with MorphTargetManager
  93025. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93026. */
  93027. export class MorphTarget implements IAnimatable {
  93028. /** defines the name of the target */
  93029. name: string;
  93030. /**
  93031. * Gets or sets the list of animations
  93032. */
  93033. animations: Animation[];
  93034. private _scene;
  93035. private _positions;
  93036. private _normals;
  93037. private _tangents;
  93038. private _uvs;
  93039. private _influence;
  93040. private _uniqueId;
  93041. /**
  93042. * Observable raised when the influence changes
  93043. */
  93044. onInfluenceChanged: Observable<boolean>;
  93045. /** @hidden */
  93046. _onDataLayoutChanged: Observable<void>;
  93047. /**
  93048. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93049. */
  93050. get influence(): number;
  93051. set influence(influence: number);
  93052. /**
  93053. * Gets or sets the id of the morph Target
  93054. */
  93055. id: string;
  93056. private _animationPropertiesOverride;
  93057. /**
  93058. * Gets or sets the animation properties override
  93059. */
  93060. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93061. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93062. /**
  93063. * Creates a new MorphTarget
  93064. * @param name defines the name of the target
  93065. * @param influence defines the influence to use
  93066. * @param scene defines the scene the morphtarget belongs to
  93067. */
  93068. constructor(
  93069. /** defines the name of the target */
  93070. name: string, influence?: number, scene?: Nullable<Scene>);
  93071. /**
  93072. * Gets the unique ID of this manager
  93073. */
  93074. get uniqueId(): number;
  93075. /**
  93076. * Gets a boolean defining if the target contains position data
  93077. */
  93078. get hasPositions(): boolean;
  93079. /**
  93080. * Gets a boolean defining if the target contains normal data
  93081. */
  93082. get hasNormals(): boolean;
  93083. /**
  93084. * Gets a boolean defining if the target contains tangent data
  93085. */
  93086. get hasTangents(): boolean;
  93087. /**
  93088. * Gets a boolean defining if the target contains texture coordinates data
  93089. */
  93090. get hasUVs(): boolean;
  93091. /**
  93092. * Affects position data to this target
  93093. * @param data defines the position data to use
  93094. */
  93095. setPositions(data: Nullable<FloatArray>): void;
  93096. /**
  93097. * Gets the position data stored in this target
  93098. * @returns a FloatArray containing the position data (or null if not present)
  93099. */
  93100. getPositions(): Nullable<FloatArray>;
  93101. /**
  93102. * Affects normal data to this target
  93103. * @param data defines the normal data to use
  93104. */
  93105. setNormals(data: Nullable<FloatArray>): void;
  93106. /**
  93107. * Gets the normal data stored in this target
  93108. * @returns a FloatArray containing the normal data (or null if not present)
  93109. */
  93110. getNormals(): Nullable<FloatArray>;
  93111. /**
  93112. * Affects tangent data to this target
  93113. * @param data defines the tangent data to use
  93114. */
  93115. setTangents(data: Nullable<FloatArray>): void;
  93116. /**
  93117. * Gets the tangent data stored in this target
  93118. * @returns a FloatArray containing the tangent data (or null if not present)
  93119. */
  93120. getTangents(): Nullable<FloatArray>;
  93121. /**
  93122. * Affects texture coordinates data to this target
  93123. * @param data defines the texture coordinates data to use
  93124. */
  93125. setUVs(data: Nullable<FloatArray>): void;
  93126. /**
  93127. * Gets the texture coordinates data stored in this target
  93128. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93129. */
  93130. getUVs(): Nullable<FloatArray>;
  93131. /**
  93132. * Clone the current target
  93133. * @returns a new MorphTarget
  93134. */
  93135. clone(): MorphTarget;
  93136. /**
  93137. * Serializes the current target into a Serialization object
  93138. * @returns the serialized object
  93139. */
  93140. serialize(): any;
  93141. /**
  93142. * Returns the string "MorphTarget"
  93143. * @returns "MorphTarget"
  93144. */
  93145. getClassName(): string;
  93146. /**
  93147. * Creates a new target from serialized data
  93148. * @param serializationObject defines the serialized data to use
  93149. * @returns a new MorphTarget
  93150. */
  93151. static Parse(serializationObject: any): MorphTarget;
  93152. /**
  93153. * Creates a MorphTarget from mesh data
  93154. * @param mesh defines the source mesh
  93155. * @param name defines the name to use for the new target
  93156. * @param influence defines the influence to attach to the target
  93157. * @returns a new MorphTarget
  93158. */
  93159. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93160. }
  93161. }
  93162. declare module BABYLON {
  93163. /**
  93164. * This class is used to deform meshes using morphing between different targets
  93165. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93166. */
  93167. export class MorphTargetManager {
  93168. private _targets;
  93169. private _targetInfluenceChangedObservers;
  93170. private _targetDataLayoutChangedObservers;
  93171. private _activeTargets;
  93172. private _scene;
  93173. private _influences;
  93174. private _supportsNormals;
  93175. private _supportsTangents;
  93176. private _supportsUVs;
  93177. private _vertexCount;
  93178. private _uniqueId;
  93179. private _tempInfluences;
  93180. /**
  93181. * Gets or sets a boolean indicating if normals must be morphed
  93182. */
  93183. enableNormalMorphing: boolean;
  93184. /**
  93185. * Gets or sets a boolean indicating if tangents must be morphed
  93186. */
  93187. enableTangentMorphing: boolean;
  93188. /**
  93189. * Gets or sets a boolean indicating if UV must be morphed
  93190. */
  93191. enableUVMorphing: boolean;
  93192. /**
  93193. * Creates a new MorphTargetManager
  93194. * @param scene defines the current scene
  93195. */
  93196. constructor(scene?: Nullable<Scene>);
  93197. /**
  93198. * Gets the unique ID of this manager
  93199. */
  93200. get uniqueId(): number;
  93201. /**
  93202. * Gets the number of vertices handled by this manager
  93203. */
  93204. get vertexCount(): number;
  93205. /**
  93206. * Gets a boolean indicating if this manager supports morphing of normals
  93207. */
  93208. get supportsNormals(): boolean;
  93209. /**
  93210. * Gets a boolean indicating if this manager supports morphing of tangents
  93211. */
  93212. get supportsTangents(): boolean;
  93213. /**
  93214. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  93215. */
  93216. get supportsUVs(): boolean;
  93217. /**
  93218. * Gets the number of targets stored in this manager
  93219. */
  93220. get numTargets(): number;
  93221. /**
  93222. * Gets the number of influencers (ie. the number of targets with influences > 0)
  93223. */
  93224. get numInfluencers(): number;
  93225. /**
  93226. * Gets the list of influences (one per target)
  93227. */
  93228. get influences(): Float32Array;
  93229. /**
  93230. * Gets the active target at specified index. An active target is a target with an influence > 0
  93231. * @param index defines the index to check
  93232. * @returns the requested target
  93233. */
  93234. getActiveTarget(index: number): MorphTarget;
  93235. /**
  93236. * Gets the target at specified index
  93237. * @param index defines the index to check
  93238. * @returns the requested target
  93239. */
  93240. getTarget(index: number): MorphTarget;
  93241. /**
  93242. * Add a new target to this manager
  93243. * @param target defines the target to add
  93244. */
  93245. addTarget(target: MorphTarget): void;
  93246. /**
  93247. * Removes a target from the manager
  93248. * @param target defines the target to remove
  93249. */
  93250. removeTarget(target: MorphTarget): void;
  93251. /**
  93252. * Clone the current manager
  93253. * @returns a new MorphTargetManager
  93254. */
  93255. clone(): MorphTargetManager;
  93256. /**
  93257. * Serializes the current manager into a Serialization object
  93258. * @returns the serialized object
  93259. */
  93260. serialize(): any;
  93261. private _syncActiveTargets;
  93262. /**
  93263. * Syncrhonize the targets with all the meshes using this morph target manager
  93264. */
  93265. synchronize(): void;
  93266. /**
  93267. * Creates a new MorphTargetManager from serialized data
  93268. * @param serializationObject defines the serialized data
  93269. * @param scene defines the hosting scene
  93270. * @returns the new MorphTargetManager
  93271. */
  93272. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  93273. }
  93274. }
  93275. declare module BABYLON {
  93276. /**
  93277. * Class used to represent a specific level of detail of a mesh
  93278. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93279. */
  93280. export class MeshLODLevel {
  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. * Creates a new LOD level
  93287. * @param distance defines the distance where this level should star being displayed
  93288. * @param mesh defines the mesh to use to render this level
  93289. */
  93290. constructor(
  93291. /** Defines the distance where this level should start being displayed */
  93292. distance: number,
  93293. /** Defines the mesh to use to render this level */
  93294. mesh: Nullable<Mesh>);
  93295. }
  93296. }
  93297. declare module BABYLON {
  93298. /**
  93299. * Mesh representing the gorund
  93300. */
  93301. export class GroundMesh extends Mesh {
  93302. /** If octree should be generated */
  93303. generateOctree: boolean;
  93304. private _heightQuads;
  93305. /** @hidden */
  93306. _subdivisionsX: number;
  93307. /** @hidden */
  93308. _subdivisionsY: number;
  93309. /** @hidden */
  93310. _width: number;
  93311. /** @hidden */
  93312. _height: number;
  93313. /** @hidden */
  93314. _minX: number;
  93315. /** @hidden */
  93316. _maxX: number;
  93317. /** @hidden */
  93318. _minZ: number;
  93319. /** @hidden */
  93320. _maxZ: number;
  93321. constructor(name: string, scene: Scene);
  93322. /**
  93323. * "GroundMesh"
  93324. * @returns "GroundMesh"
  93325. */
  93326. getClassName(): string;
  93327. /**
  93328. * The minimum of x and y subdivisions
  93329. */
  93330. get subdivisions(): number;
  93331. /**
  93332. * X subdivisions
  93333. */
  93334. get subdivisionsX(): number;
  93335. /**
  93336. * Y subdivisions
  93337. */
  93338. get subdivisionsY(): number;
  93339. /**
  93340. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  93341. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  93342. * @param chunksCount the number of subdivisions for x and y
  93343. * @param octreeBlocksSize (Default: 32)
  93344. */
  93345. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  93346. /**
  93347. * Returns a height (y) value in the Worl system :
  93348. * the ground altitude at the coordinates (x, z) expressed in the World system.
  93349. * @param x x coordinate
  93350. * @param z z coordinate
  93351. * @returns the ground y position if (x, z) are outside the ground surface.
  93352. */
  93353. getHeightAtCoordinates(x: number, z: number): number;
  93354. /**
  93355. * Returns a normalized vector (Vector3) orthogonal to the ground
  93356. * at the ground coordinates (x, z) expressed in the World system.
  93357. * @param x x coordinate
  93358. * @param z z coordinate
  93359. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  93360. */
  93361. getNormalAtCoordinates(x: number, z: number): Vector3;
  93362. /**
  93363. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  93364. * at the ground coordinates (x, z) expressed in the World system.
  93365. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  93366. * @param x x coordinate
  93367. * @param z z coordinate
  93368. * @param ref vector to store the result
  93369. * @returns the GroundMesh.
  93370. */
  93371. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  93372. /**
  93373. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  93374. * if the ground has been updated.
  93375. * This can be used in the render loop.
  93376. * @returns the GroundMesh.
  93377. */
  93378. updateCoordinateHeights(): GroundMesh;
  93379. private _getFacetAt;
  93380. private _initHeightQuads;
  93381. private _computeHeightQuads;
  93382. /**
  93383. * Serializes this ground mesh
  93384. * @param serializationObject object to write serialization to
  93385. */
  93386. serialize(serializationObject: any): void;
  93387. /**
  93388. * Parses a serialized ground mesh
  93389. * @param parsedMesh the serialized mesh
  93390. * @param scene the scene to create the ground mesh in
  93391. * @returns the created ground mesh
  93392. */
  93393. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  93394. }
  93395. }
  93396. declare module BABYLON {
  93397. /**
  93398. * Interface for Physics-Joint data
  93399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93400. */
  93401. export interface PhysicsJointData {
  93402. /**
  93403. * The main pivot of the joint
  93404. */
  93405. mainPivot?: Vector3;
  93406. /**
  93407. * The connected pivot of the joint
  93408. */
  93409. connectedPivot?: Vector3;
  93410. /**
  93411. * The main axis of the joint
  93412. */
  93413. mainAxis?: Vector3;
  93414. /**
  93415. * The connected axis of the joint
  93416. */
  93417. connectedAxis?: Vector3;
  93418. /**
  93419. * The collision of the joint
  93420. */
  93421. collision?: boolean;
  93422. /**
  93423. * Native Oimo/Cannon/Energy data
  93424. */
  93425. nativeParams?: any;
  93426. }
  93427. /**
  93428. * This is a holder class for the physics joint created by the physics plugin
  93429. * It holds a set of functions to control the underlying joint
  93430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93431. */
  93432. export class PhysicsJoint {
  93433. /**
  93434. * The type of the physics joint
  93435. */
  93436. type: number;
  93437. /**
  93438. * The data for the physics joint
  93439. */
  93440. jointData: PhysicsJointData;
  93441. private _physicsJoint;
  93442. protected _physicsPlugin: IPhysicsEnginePlugin;
  93443. /**
  93444. * Initializes the physics joint
  93445. * @param type The type of the physics joint
  93446. * @param jointData The data for the physics joint
  93447. */
  93448. constructor(
  93449. /**
  93450. * The type of the physics joint
  93451. */
  93452. type: number,
  93453. /**
  93454. * The data for the physics joint
  93455. */
  93456. jointData: PhysicsJointData);
  93457. /**
  93458. * Gets the physics joint
  93459. */
  93460. get physicsJoint(): any;
  93461. /**
  93462. * Sets the physics joint
  93463. */
  93464. set physicsJoint(newJoint: any);
  93465. /**
  93466. * Sets the physics plugin
  93467. */
  93468. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  93469. /**
  93470. * Execute a function that is physics-plugin specific.
  93471. * @param {Function} func the function that will be executed.
  93472. * It accepts two parameters: the physics world and the physics joint
  93473. */
  93474. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  93475. /**
  93476. * Distance-Joint type
  93477. */
  93478. static DistanceJoint: number;
  93479. /**
  93480. * Hinge-Joint type
  93481. */
  93482. static HingeJoint: number;
  93483. /**
  93484. * Ball-and-Socket joint type
  93485. */
  93486. static BallAndSocketJoint: number;
  93487. /**
  93488. * Wheel-Joint type
  93489. */
  93490. static WheelJoint: number;
  93491. /**
  93492. * Slider-Joint type
  93493. */
  93494. static SliderJoint: number;
  93495. /**
  93496. * Prismatic-Joint type
  93497. */
  93498. static PrismaticJoint: number;
  93499. /**
  93500. * Universal-Joint type
  93501. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  93502. */
  93503. static UniversalJoint: number;
  93504. /**
  93505. * Hinge-Joint 2 type
  93506. */
  93507. static Hinge2Joint: number;
  93508. /**
  93509. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  93510. */
  93511. static PointToPointJoint: number;
  93512. /**
  93513. * Spring-Joint type
  93514. */
  93515. static SpringJoint: number;
  93516. /**
  93517. * Lock-Joint type
  93518. */
  93519. static LockJoint: number;
  93520. }
  93521. /**
  93522. * A class representing a physics distance joint
  93523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93524. */
  93525. export class DistanceJoint extends PhysicsJoint {
  93526. /**
  93527. *
  93528. * @param jointData The data for the Distance-Joint
  93529. */
  93530. constructor(jointData: DistanceJointData);
  93531. /**
  93532. * Update the predefined distance.
  93533. * @param maxDistance The maximum preferred distance
  93534. * @param minDistance The minimum preferred distance
  93535. */
  93536. updateDistance(maxDistance: number, minDistance?: number): void;
  93537. }
  93538. /**
  93539. * Represents a Motor-Enabled Joint
  93540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93541. */
  93542. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  93543. /**
  93544. * Initializes the Motor-Enabled Joint
  93545. * @param type The type of the joint
  93546. * @param jointData The physica joint data for the joint
  93547. */
  93548. constructor(type: number, jointData: PhysicsJointData);
  93549. /**
  93550. * Set the motor values.
  93551. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93552. * @param force the force to apply
  93553. * @param maxForce max force for this motor.
  93554. */
  93555. setMotor(force?: number, maxForce?: number): void;
  93556. /**
  93557. * Set the motor's limits.
  93558. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93559. * @param upperLimit The upper limit of the motor
  93560. * @param lowerLimit The lower limit of the motor
  93561. */
  93562. setLimit(upperLimit: number, lowerLimit?: number): void;
  93563. }
  93564. /**
  93565. * This class represents a single physics Hinge-Joint
  93566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93567. */
  93568. export class HingeJoint extends MotorEnabledJoint {
  93569. /**
  93570. * Initializes the Hinge-Joint
  93571. * @param jointData The joint data for the Hinge-Joint
  93572. */
  93573. constructor(jointData: PhysicsJointData);
  93574. /**
  93575. * Set the motor values.
  93576. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93577. * @param {number} force the force to apply
  93578. * @param {number} maxForce max force for this motor.
  93579. */
  93580. setMotor(force?: number, maxForce?: number): void;
  93581. /**
  93582. * Set the motor's limits.
  93583. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93584. * @param upperLimit The upper limit of the motor
  93585. * @param lowerLimit The lower limit of the motor
  93586. */
  93587. setLimit(upperLimit: number, lowerLimit?: number): void;
  93588. }
  93589. /**
  93590. * This class represents a dual hinge physics joint (same as wheel joint)
  93591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93592. */
  93593. export class Hinge2Joint extends MotorEnabledJoint {
  93594. /**
  93595. * Initializes the Hinge2-Joint
  93596. * @param jointData The joint data for the Hinge2-Joint
  93597. */
  93598. constructor(jointData: PhysicsJointData);
  93599. /**
  93600. * Set the motor values.
  93601. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93602. * @param {number} targetSpeed the speed the motor is to reach
  93603. * @param {number} maxForce max force for this motor.
  93604. * @param {motorIndex} the motor's index, 0 or 1.
  93605. */
  93606. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  93607. /**
  93608. * Set the motor limits.
  93609. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93610. * @param {number} upperLimit the upper limit
  93611. * @param {number} lowerLimit lower limit
  93612. * @param {motorIndex} the motor's index, 0 or 1.
  93613. */
  93614. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93615. }
  93616. /**
  93617. * Interface for a motor enabled joint
  93618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93619. */
  93620. export interface IMotorEnabledJoint {
  93621. /**
  93622. * Physics joint
  93623. */
  93624. physicsJoint: any;
  93625. /**
  93626. * Sets the motor of the motor-enabled joint
  93627. * @param force The force of the motor
  93628. * @param maxForce The maximum force of the motor
  93629. * @param motorIndex The index of the motor
  93630. */
  93631. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  93632. /**
  93633. * Sets the limit of the motor
  93634. * @param upperLimit The upper limit of the motor
  93635. * @param lowerLimit The lower limit of the motor
  93636. * @param motorIndex The index of the motor
  93637. */
  93638. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93639. }
  93640. /**
  93641. * Joint data for a Distance-Joint
  93642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93643. */
  93644. export interface DistanceJointData extends PhysicsJointData {
  93645. /**
  93646. * Max distance the 2 joint objects can be apart
  93647. */
  93648. maxDistance: number;
  93649. }
  93650. /**
  93651. * Joint data from a spring joint
  93652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93653. */
  93654. export interface SpringJointData extends PhysicsJointData {
  93655. /**
  93656. * Length of the spring
  93657. */
  93658. length: number;
  93659. /**
  93660. * Stiffness of the spring
  93661. */
  93662. stiffness: number;
  93663. /**
  93664. * Damping of the spring
  93665. */
  93666. damping: number;
  93667. /** this callback will be called when applying the force to the impostors. */
  93668. forceApplicationCallback: () => void;
  93669. }
  93670. }
  93671. declare module BABYLON {
  93672. /**
  93673. * Holds the data for the raycast result
  93674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93675. */
  93676. export class PhysicsRaycastResult {
  93677. private _hasHit;
  93678. private _hitDistance;
  93679. private _hitNormalWorld;
  93680. private _hitPointWorld;
  93681. private _rayFromWorld;
  93682. private _rayToWorld;
  93683. /**
  93684. * Gets if there was a hit
  93685. */
  93686. get hasHit(): boolean;
  93687. /**
  93688. * Gets the distance from the hit
  93689. */
  93690. get hitDistance(): number;
  93691. /**
  93692. * Gets the hit normal/direction in the world
  93693. */
  93694. get hitNormalWorld(): Vector3;
  93695. /**
  93696. * Gets the hit point in the world
  93697. */
  93698. get hitPointWorld(): Vector3;
  93699. /**
  93700. * Gets the ray "start point" of the ray in the world
  93701. */
  93702. get rayFromWorld(): Vector3;
  93703. /**
  93704. * Gets the ray "end point" of the ray in the world
  93705. */
  93706. get rayToWorld(): Vector3;
  93707. /**
  93708. * Sets the hit data (normal & point in world space)
  93709. * @param hitNormalWorld defines the normal in world space
  93710. * @param hitPointWorld defines the point in world space
  93711. */
  93712. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  93713. /**
  93714. * Sets the distance from the start point to the hit point
  93715. * @param distance
  93716. */
  93717. setHitDistance(distance: number): void;
  93718. /**
  93719. * Calculates the distance manually
  93720. */
  93721. calculateHitDistance(): void;
  93722. /**
  93723. * Resets all the values to default
  93724. * @param from The from point on world space
  93725. * @param to The to point on world space
  93726. */
  93727. reset(from?: Vector3, to?: Vector3): void;
  93728. }
  93729. /**
  93730. * Interface for the size containing width and height
  93731. */
  93732. interface IXYZ {
  93733. /**
  93734. * X
  93735. */
  93736. x: number;
  93737. /**
  93738. * Y
  93739. */
  93740. y: number;
  93741. /**
  93742. * Z
  93743. */
  93744. z: number;
  93745. }
  93746. }
  93747. declare module BABYLON {
  93748. /**
  93749. * Interface used to describe a physics joint
  93750. */
  93751. export interface PhysicsImpostorJoint {
  93752. /** Defines the main impostor to which the joint is linked */
  93753. mainImpostor: PhysicsImpostor;
  93754. /** Defines the impostor that is connected to the main impostor using this joint */
  93755. connectedImpostor: PhysicsImpostor;
  93756. /** Defines the joint itself */
  93757. joint: PhysicsJoint;
  93758. }
  93759. /** @hidden */
  93760. export interface IPhysicsEnginePlugin {
  93761. world: any;
  93762. name: string;
  93763. setGravity(gravity: Vector3): void;
  93764. setTimeStep(timeStep: number): void;
  93765. getTimeStep(): number;
  93766. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  93767. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93768. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93769. generatePhysicsBody(impostor: PhysicsImpostor): void;
  93770. removePhysicsBody(impostor: PhysicsImpostor): void;
  93771. generateJoint(joint: PhysicsImpostorJoint): void;
  93772. removeJoint(joint: PhysicsImpostorJoint): void;
  93773. isSupported(): boolean;
  93774. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  93775. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  93776. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93777. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93778. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93779. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93780. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  93781. getBodyMass(impostor: PhysicsImpostor): number;
  93782. getBodyFriction(impostor: PhysicsImpostor): number;
  93783. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  93784. getBodyRestitution(impostor: PhysicsImpostor): number;
  93785. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  93786. getBodyPressure?(impostor: PhysicsImpostor): number;
  93787. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  93788. getBodyStiffness?(impostor: PhysicsImpostor): number;
  93789. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  93790. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  93791. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  93792. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  93793. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  93794. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93795. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93796. sleepBody(impostor: PhysicsImpostor): void;
  93797. wakeUpBody(impostor: PhysicsImpostor): void;
  93798. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93799. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  93800. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  93801. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93802. getRadius(impostor: PhysicsImpostor): number;
  93803. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  93804. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  93805. dispose(): void;
  93806. }
  93807. /**
  93808. * Interface used to define a physics engine
  93809. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  93810. */
  93811. export interface IPhysicsEngine {
  93812. /**
  93813. * Gets the gravity vector used by the simulation
  93814. */
  93815. gravity: Vector3;
  93816. /**
  93817. * Sets the gravity vector used by the simulation
  93818. * @param gravity defines the gravity vector to use
  93819. */
  93820. setGravity(gravity: Vector3): void;
  93821. /**
  93822. * Set the time step of the physics engine.
  93823. * Default is 1/60.
  93824. * To slow it down, enter 1/600 for example.
  93825. * To speed it up, 1/30
  93826. * @param newTimeStep the new timestep to apply to this world.
  93827. */
  93828. setTimeStep(newTimeStep: number): void;
  93829. /**
  93830. * Get the time step of the physics engine.
  93831. * @returns the current time step
  93832. */
  93833. getTimeStep(): number;
  93834. /**
  93835. * Set the sub time step of the physics engine.
  93836. * Default is 0 meaning there is no sub steps
  93837. * To increase physics resolution precision, set a small value (like 1 ms)
  93838. * @param subTimeStep defines the new sub timestep used for physics resolution.
  93839. */
  93840. setSubTimeStep(subTimeStep: number): void;
  93841. /**
  93842. * Get the sub time step of the physics engine.
  93843. * @returns the current sub time step
  93844. */
  93845. getSubTimeStep(): number;
  93846. /**
  93847. * Release all resources
  93848. */
  93849. dispose(): void;
  93850. /**
  93851. * Gets the name of the current physics plugin
  93852. * @returns the name of the plugin
  93853. */
  93854. getPhysicsPluginName(): string;
  93855. /**
  93856. * Adding a new impostor for the impostor tracking.
  93857. * This will be done by the impostor itself.
  93858. * @param impostor the impostor to add
  93859. */
  93860. addImpostor(impostor: PhysicsImpostor): void;
  93861. /**
  93862. * Remove an impostor from the engine.
  93863. * This impostor and its mesh will not longer be updated by the physics engine.
  93864. * @param impostor the impostor to remove
  93865. */
  93866. removeImpostor(impostor: PhysicsImpostor): void;
  93867. /**
  93868. * Add a joint to the physics engine
  93869. * @param mainImpostor defines the main impostor to which the joint is added.
  93870. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  93871. * @param joint defines the joint that will connect both impostors.
  93872. */
  93873. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93874. /**
  93875. * Removes a joint from the simulation
  93876. * @param mainImpostor defines the impostor used with the joint
  93877. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  93878. * @param joint defines the joint to remove
  93879. */
  93880. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93881. /**
  93882. * Gets the current plugin used to run the simulation
  93883. * @returns current plugin
  93884. */
  93885. getPhysicsPlugin(): IPhysicsEnginePlugin;
  93886. /**
  93887. * Gets the list of physic impostors
  93888. * @returns an array of PhysicsImpostor
  93889. */
  93890. getImpostors(): Array<PhysicsImpostor>;
  93891. /**
  93892. * Gets the impostor for a physics enabled object
  93893. * @param object defines the object impersonated by the impostor
  93894. * @returns the PhysicsImpostor or null if not found
  93895. */
  93896. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93897. /**
  93898. * Gets the impostor for a physics body object
  93899. * @param body defines physics body used by the impostor
  93900. * @returns the PhysicsImpostor or null if not found
  93901. */
  93902. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  93903. /**
  93904. * Does a raycast in the physics world
  93905. * @param from when should the ray start?
  93906. * @param to when should the ray end?
  93907. * @returns PhysicsRaycastResult
  93908. */
  93909. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93910. /**
  93911. * Called by the scene. No need to call it.
  93912. * @param delta defines the timespam between frames
  93913. */
  93914. _step(delta: number): void;
  93915. }
  93916. }
  93917. declare module BABYLON {
  93918. /**
  93919. * The interface for the physics imposter parameters
  93920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93921. */
  93922. export interface PhysicsImpostorParameters {
  93923. /**
  93924. * The mass of the physics imposter
  93925. */
  93926. mass: number;
  93927. /**
  93928. * The friction of the physics imposter
  93929. */
  93930. friction?: number;
  93931. /**
  93932. * The coefficient of restitution of the physics imposter
  93933. */
  93934. restitution?: number;
  93935. /**
  93936. * The native options of the physics imposter
  93937. */
  93938. nativeOptions?: any;
  93939. /**
  93940. * Specifies if the parent should be ignored
  93941. */
  93942. ignoreParent?: boolean;
  93943. /**
  93944. * Specifies if bi-directional transformations should be disabled
  93945. */
  93946. disableBidirectionalTransformation?: boolean;
  93947. /**
  93948. * The pressure inside the physics imposter, soft object only
  93949. */
  93950. pressure?: number;
  93951. /**
  93952. * The stiffness the physics imposter, soft object only
  93953. */
  93954. stiffness?: number;
  93955. /**
  93956. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  93957. */
  93958. velocityIterations?: number;
  93959. /**
  93960. * The number of iterations used in maintaining consistent vertex positions, soft object only
  93961. */
  93962. positionIterations?: number;
  93963. /**
  93964. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  93965. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  93966. * Add to fix multiple points
  93967. */
  93968. fixedPoints?: number;
  93969. /**
  93970. * The collision margin around a soft object
  93971. */
  93972. margin?: number;
  93973. /**
  93974. * The collision margin around a soft object
  93975. */
  93976. damping?: number;
  93977. /**
  93978. * The path for a rope based on an extrusion
  93979. */
  93980. path?: any;
  93981. /**
  93982. * The shape of an extrusion used for a rope based on an extrusion
  93983. */
  93984. shape?: any;
  93985. }
  93986. /**
  93987. * Interface for a physics-enabled object
  93988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93989. */
  93990. export interface IPhysicsEnabledObject {
  93991. /**
  93992. * The position of the physics-enabled object
  93993. */
  93994. position: Vector3;
  93995. /**
  93996. * The rotation of the physics-enabled object
  93997. */
  93998. rotationQuaternion: Nullable<Quaternion>;
  93999. /**
  94000. * The scale of the physics-enabled object
  94001. */
  94002. scaling: Vector3;
  94003. /**
  94004. * The rotation of the physics-enabled object
  94005. */
  94006. rotation?: Vector3;
  94007. /**
  94008. * The parent of the physics-enabled object
  94009. */
  94010. parent?: any;
  94011. /**
  94012. * The bounding info of the physics-enabled object
  94013. * @returns The bounding info of the physics-enabled object
  94014. */
  94015. getBoundingInfo(): BoundingInfo;
  94016. /**
  94017. * Computes the world matrix
  94018. * @param force Specifies if the world matrix should be computed by force
  94019. * @returns A world matrix
  94020. */
  94021. computeWorldMatrix(force: boolean): Matrix;
  94022. /**
  94023. * Gets the world matrix
  94024. * @returns A world matrix
  94025. */
  94026. getWorldMatrix?(): Matrix;
  94027. /**
  94028. * Gets the child meshes
  94029. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94030. * @returns An array of abstract meshes
  94031. */
  94032. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94033. /**
  94034. * Gets the vertex data
  94035. * @param kind The type of vertex data
  94036. * @returns A nullable array of numbers, or a float32 array
  94037. */
  94038. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94039. /**
  94040. * Gets the indices from the mesh
  94041. * @returns A nullable array of index arrays
  94042. */
  94043. getIndices?(): Nullable<IndicesArray>;
  94044. /**
  94045. * Gets the scene from the mesh
  94046. * @returns the indices array or null
  94047. */
  94048. getScene?(): Scene;
  94049. /**
  94050. * Gets the absolute position from the mesh
  94051. * @returns the absolute position
  94052. */
  94053. getAbsolutePosition(): Vector3;
  94054. /**
  94055. * Gets the absolute pivot point from the mesh
  94056. * @returns the absolute pivot point
  94057. */
  94058. getAbsolutePivotPoint(): Vector3;
  94059. /**
  94060. * Rotates the mesh
  94061. * @param axis The axis of rotation
  94062. * @param amount The amount of rotation
  94063. * @param space The space of the rotation
  94064. * @returns The rotation transform node
  94065. */
  94066. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94067. /**
  94068. * Translates the mesh
  94069. * @param axis The axis of translation
  94070. * @param distance The distance of translation
  94071. * @param space The space of the translation
  94072. * @returns The transform node
  94073. */
  94074. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94075. /**
  94076. * Sets the absolute position of the mesh
  94077. * @param absolutePosition The absolute position of the mesh
  94078. * @returns The transform node
  94079. */
  94080. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94081. /**
  94082. * Gets the class name of the mesh
  94083. * @returns The class name
  94084. */
  94085. getClassName(): string;
  94086. }
  94087. /**
  94088. * Represents a physics imposter
  94089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94090. */
  94091. export class PhysicsImpostor {
  94092. /**
  94093. * The physics-enabled object used as the physics imposter
  94094. */
  94095. object: IPhysicsEnabledObject;
  94096. /**
  94097. * The type of the physics imposter
  94098. */
  94099. type: number;
  94100. private _options;
  94101. private _scene?;
  94102. /**
  94103. * The default object size of the imposter
  94104. */
  94105. static DEFAULT_OBJECT_SIZE: Vector3;
  94106. /**
  94107. * The identity quaternion of the imposter
  94108. */
  94109. static IDENTITY_QUATERNION: Quaternion;
  94110. /** @hidden */
  94111. _pluginData: any;
  94112. private _physicsEngine;
  94113. private _physicsBody;
  94114. private _bodyUpdateRequired;
  94115. private _onBeforePhysicsStepCallbacks;
  94116. private _onAfterPhysicsStepCallbacks;
  94117. /** @hidden */
  94118. _onPhysicsCollideCallbacks: Array<{
  94119. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94120. otherImpostors: Array<PhysicsImpostor>;
  94121. }>;
  94122. private _deltaPosition;
  94123. private _deltaRotation;
  94124. private _deltaRotationConjugated;
  94125. /** @hidden */
  94126. _isFromLine: boolean;
  94127. private _parent;
  94128. private _isDisposed;
  94129. private static _tmpVecs;
  94130. private static _tmpQuat;
  94131. /**
  94132. * Specifies if the physics imposter is disposed
  94133. */
  94134. get isDisposed(): boolean;
  94135. /**
  94136. * Gets the mass of the physics imposter
  94137. */
  94138. get mass(): number;
  94139. set mass(value: number);
  94140. /**
  94141. * Gets the coefficient of friction
  94142. */
  94143. get friction(): number;
  94144. /**
  94145. * Sets the coefficient of friction
  94146. */
  94147. set friction(value: number);
  94148. /**
  94149. * Gets the coefficient of restitution
  94150. */
  94151. get restitution(): number;
  94152. /**
  94153. * Sets the coefficient of restitution
  94154. */
  94155. set restitution(value: number);
  94156. /**
  94157. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94158. */
  94159. get pressure(): number;
  94160. /**
  94161. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94162. */
  94163. set pressure(value: number);
  94164. /**
  94165. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94166. */
  94167. get stiffness(): number;
  94168. /**
  94169. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94170. */
  94171. set stiffness(value: number);
  94172. /**
  94173. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94174. */
  94175. get velocityIterations(): number;
  94176. /**
  94177. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94178. */
  94179. set velocityIterations(value: number);
  94180. /**
  94181. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94182. */
  94183. get positionIterations(): number;
  94184. /**
  94185. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94186. */
  94187. set positionIterations(value: number);
  94188. /**
  94189. * The unique id of the physics imposter
  94190. * set by the physics engine when adding this impostor to the array
  94191. */
  94192. uniqueId: number;
  94193. /**
  94194. * @hidden
  94195. */
  94196. soft: boolean;
  94197. /**
  94198. * @hidden
  94199. */
  94200. segments: number;
  94201. private _joints;
  94202. /**
  94203. * Initializes the physics imposter
  94204. * @param object The physics-enabled object used as the physics imposter
  94205. * @param type The type of the physics imposter
  94206. * @param _options The options for the physics imposter
  94207. * @param _scene The Babylon scene
  94208. */
  94209. constructor(
  94210. /**
  94211. * The physics-enabled object used as the physics imposter
  94212. */
  94213. object: IPhysicsEnabledObject,
  94214. /**
  94215. * The type of the physics imposter
  94216. */
  94217. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  94218. /**
  94219. * This function will completly initialize this impostor.
  94220. * It will create a new body - but only if this mesh has no parent.
  94221. * If it has, this impostor will not be used other than to define the impostor
  94222. * of the child mesh.
  94223. * @hidden
  94224. */
  94225. _init(): void;
  94226. private _getPhysicsParent;
  94227. /**
  94228. * Should a new body be generated.
  94229. * @returns boolean specifying if body initialization is required
  94230. */
  94231. isBodyInitRequired(): boolean;
  94232. /**
  94233. * Sets the updated scaling
  94234. * @param updated Specifies if the scaling is updated
  94235. */
  94236. setScalingUpdated(): void;
  94237. /**
  94238. * Force a regeneration of this or the parent's impostor's body.
  94239. * Use under cautious - This will remove all joints already implemented.
  94240. */
  94241. forceUpdate(): void;
  94242. /**
  94243. * Gets the body that holds this impostor. Either its own, or its parent.
  94244. */
  94245. get physicsBody(): any;
  94246. /**
  94247. * Get the parent of the physics imposter
  94248. * @returns Physics imposter or null
  94249. */
  94250. get parent(): Nullable<PhysicsImpostor>;
  94251. /**
  94252. * Sets the parent of the physics imposter
  94253. */
  94254. set parent(value: Nullable<PhysicsImpostor>);
  94255. /**
  94256. * Set the physics body. Used mainly by the physics engine/plugin
  94257. */
  94258. set physicsBody(physicsBody: any);
  94259. /**
  94260. * Resets the update flags
  94261. */
  94262. resetUpdateFlags(): void;
  94263. /**
  94264. * Gets the object extend size
  94265. * @returns the object extend size
  94266. */
  94267. getObjectExtendSize(): Vector3;
  94268. /**
  94269. * Gets the object center
  94270. * @returns The object center
  94271. */
  94272. getObjectCenter(): Vector3;
  94273. /**
  94274. * Get a specific parametes from the options parameter
  94275. * @param paramName The object parameter name
  94276. * @returns The object parameter
  94277. */
  94278. getParam(paramName: string): any;
  94279. /**
  94280. * Sets a specific parameter in the options given to the physics plugin
  94281. * @param paramName The parameter name
  94282. * @param value The value of the parameter
  94283. */
  94284. setParam(paramName: string, value: number): void;
  94285. /**
  94286. * Specifically change the body's mass option. Won't recreate the physics body object
  94287. * @param mass The mass of the physics imposter
  94288. */
  94289. setMass(mass: number): void;
  94290. /**
  94291. * Gets the linear velocity
  94292. * @returns linear velocity or null
  94293. */
  94294. getLinearVelocity(): Nullable<Vector3>;
  94295. /**
  94296. * Sets the linear velocity
  94297. * @param velocity linear velocity or null
  94298. */
  94299. setLinearVelocity(velocity: Nullable<Vector3>): void;
  94300. /**
  94301. * Gets the angular velocity
  94302. * @returns angular velocity or null
  94303. */
  94304. getAngularVelocity(): Nullable<Vector3>;
  94305. /**
  94306. * Sets the angular velocity
  94307. * @param velocity The velocity or null
  94308. */
  94309. setAngularVelocity(velocity: Nullable<Vector3>): void;
  94310. /**
  94311. * Execute a function with the physics plugin native code
  94312. * Provide a function the will have two variables - the world object and the physics body object
  94313. * @param func The function to execute with the physics plugin native code
  94314. */
  94315. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  94316. /**
  94317. * Register a function that will be executed before the physics world is stepping forward
  94318. * @param func The function to execute before the physics world is stepped forward
  94319. */
  94320. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94321. /**
  94322. * Unregister a function that will be executed before the physics world is stepping forward
  94323. * @param func The function to execute before the physics world is stepped forward
  94324. */
  94325. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94326. /**
  94327. * Register a function that will be executed after the physics step
  94328. * @param func The function to execute after physics step
  94329. */
  94330. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94331. /**
  94332. * Unregisters a function that will be executed after the physics step
  94333. * @param func The function to execute after physics step
  94334. */
  94335. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94336. /**
  94337. * register a function that will be executed when this impostor collides against a different body
  94338. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  94339. * @param func Callback that is executed on collision
  94340. */
  94341. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  94342. /**
  94343. * Unregisters the physics imposter on contact
  94344. * @param collideAgainst The physics object to collide against
  94345. * @param func Callback to execute on collision
  94346. */
  94347. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  94348. private _tmpQuat;
  94349. private _tmpQuat2;
  94350. /**
  94351. * Get the parent rotation
  94352. * @returns The parent rotation
  94353. */
  94354. getParentsRotation(): Quaternion;
  94355. /**
  94356. * this function is executed by the physics engine.
  94357. */
  94358. beforeStep: () => void;
  94359. /**
  94360. * this function is executed by the physics engine
  94361. */
  94362. afterStep: () => void;
  94363. /**
  94364. * Legacy collision detection event support
  94365. */
  94366. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  94367. /**
  94368. * event and body object due to cannon's event-based architecture.
  94369. */
  94370. onCollide: (e: {
  94371. body: any;
  94372. }) => void;
  94373. /**
  94374. * Apply a force
  94375. * @param force The force to apply
  94376. * @param contactPoint The contact point for the force
  94377. * @returns The physics imposter
  94378. */
  94379. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94380. /**
  94381. * Apply an impulse
  94382. * @param force The impulse force
  94383. * @param contactPoint The contact point for the impulse force
  94384. * @returns The physics imposter
  94385. */
  94386. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94387. /**
  94388. * A help function to create a joint
  94389. * @param otherImpostor A physics imposter used to create a joint
  94390. * @param jointType The type of joint
  94391. * @param jointData The data for the joint
  94392. * @returns The physics imposter
  94393. */
  94394. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  94395. /**
  94396. * Add a joint to this impostor with a different impostor
  94397. * @param otherImpostor A physics imposter used to add a joint
  94398. * @param joint The joint to add
  94399. * @returns The physics imposter
  94400. */
  94401. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  94402. /**
  94403. * Add an anchor to a cloth impostor
  94404. * @param otherImpostor rigid impostor to anchor to
  94405. * @param width ratio across width from 0 to 1
  94406. * @param height ratio up height from 0 to 1
  94407. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  94408. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  94409. * @returns impostor the soft imposter
  94410. */
  94411. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94412. /**
  94413. * Add a hook to a rope impostor
  94414. * @param otherImpostor rigid impostor to anchor to
  94415. * @param length ratio across rope from 0 to 1
  94416. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  94417. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  94418. * @returns impostor the rope imposter
  94419. */
  94420. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94421. /**
  94422. * Will keep this body still, in a sleep mode.
  94423. * @returns the physics imposter
  94424. */
  94425. sleep(): PhysicsImpostor;
  94426. /**
  94427. * Wake the body up.
  94428. * @returns The physics imposter
  94429. */
  94430. wakeUp(): PhysicsImpostor;
  94431. /**
  94432. * Clones the physics imposter
  94433. * @param newObject The physics imposter clones to this physics-enabled object
  94434. * @returns A nullable physics imposter
  94435. */
  94436. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94437. /**
  94438. * Disposes the physics imposter
  94439. */
  94440. dispose(): void;
  94441. /**
  94442. * Sets the delta position
  94443. * @param position The delta position amount
  94444. */
  94445. setDeltaPosition(position: Vector3): void;
  94446. /**
  94447. * Sets the delta rotation
  94448. * @param rotation The delta rotation amount
  94449. */
  94450. setDeltaRotation(rotation: Quaternion): void;
  94451. /**
  94452. * Gets the box size of the physics imposter and stores the result in the input parameter
  94453. * @param result Stores the box size
  94454. * @returns The physics imposter
  94455. */
  94456. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  94457. /**
  94458. * Gets the radius of the physics imposter
  94459. * @returns Radius of the physics imposter
  94460. */
  94461. getRadius(): number;
  94462. /**
  94463. * Sync a bone with this impostor
  94464. * @param bone The bone to sync to the impostor.
  94465. * @param boneMesh The mesh that the bone is influencing.
  94466. * @param jointPivot The pivot of the joint / bone in local space.
  94467. * @param distToJoint Optional distance from the impostor to the joint.
  94468. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94469. */
  94470. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  94471. /**
  94472. * Sync impostor to a bone
  94473. * @param bone The bone that the impostor will be synced to.
  94474. * @param boneMesh The mesh that the bone is influencing.
  94475. * @param jointPivot The pivot of the joint / bone in local space.
  94476. * @param distToJoint Optional distance from the impostor to the joint.
  94477. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94478. * @param boneAxis Optional vector3 axis the bone is aligned with
  94479. */
  94480. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  94481. /**
  94482. * No-Imposter type
  94483. */
  94484. static NoImpostor: number;
  94485. /**
  94486. * Sphere-Imposter type
  94487. */
  94488. static SphereImpostor: number;
  94489. /**
  94490. * Box-Imposter type
  94491. */
  94492. static BoxImpostor: number;
  94493. /**
  94494. * Plane-Imposter type
  94495. */
  94496. static PlaneImpostor: number;
  94497. /**
  94498. * Mesh-imposter type
  94499. */
  94500. static MeshImpostor: number;
  94501. /**
  94502. * Capsule-Impostor type (Ammo.js plugin only)
  94503. */
  94504. static CapsuleImpostor: number;
  94505. /**
  94506. * Cylinder-Imposter type
  94507. */
  94508. static CylinderImpostor: number;
  94509. /**
  94510. * Particle-Imposter type
  94511. */
  94512. static ParticleImpostor: number;
  94513. /**
  94514. * Heightmap-Imposter type
  94515. */
  94516. static HeightmapImpostor: number;
  94517. /**
  94518. * ConvexHull-Impostor type (Ammo.js plugin only)
  94519. */
  94520. static ConvexHullImpostor: number;
  94521. /**
  94522. * Custom-Imposter type (Ammo.js plugin only)
  94523. */
  94524. static CustomImpostor: number;
  94525. /**
  94526. * Rope-Imposter type
  94527. */
  94528. static RopeImpostor: number;
  94529. /**
  94530. * Cloth-Imposter type
  94531. */
  94532. static ClothImpostor: number;
  94533. /**
  94534. * Softbody-Imposter type
  94535. */
  94536. static SoftbodyImpostor: number;
  94537. }
  94538. }
  94539. declare module BABYLON {
  94540. /**
  94541. * @hidden
  94542. **/
  94543. export class _CreationDataStorage {
  94544. closePath?: boolean;
  94545. closeArray?: boolean;
  94546. idx: number[];
  94547. dashSize: number;
  94548. gapSize: number;
  94549. path3D: Path3D;
  94550. pathArray: Vector3[][];
  94551. arc: number;
  94552. radius: number;
  94553. cap: number;
  94554. tessellation: number;
  94555. }
  94556. /**
  94557. * @hidden
  94558. **/
  94559. class _InstanceDataStorage {
  94560. visibleInstances: any;
  94561. batchCache: _InstancesBatch;
  94562. instancesBufferSize: number;
  94563. instancesBuffer: Nullable<Buffer>;
  94564. instancesData: Float32Array;
  94565. overridenInstanceCount: number;
  94566. isFrozen: boolean;
  94567. previousBatch: Nullable<_InstancesBatch>;
  94568. hardwareInstancedRendering: boolean;
  94569. sideOrientation: number;
  94570. manualUpdate: boolean;
  94571. }
  94572. /**
  94573. * @hidden
  94574. **/
  94575. export class _InstancesBatch {
  94576. mustReturn: boolean;
  94577. visibleInstances: Nullable<InstancedMesh[]>[];
  94578. renderSelf: boolean[];
  94579. hardwareInstancedRendering: boolean[];
  94580. }
  94581. /**
  94582. * Class used to represent renderable models
  94583. */
  94584. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  94585. /**
  94586. * Mesh side orientation : usually the external or front surface
  94587. */
  94588. static readonly FRONTSIDE: number;
  94589. /**
  94590. * Mesh side orientation : usually the internal or back surface
  94591. */
  94592. static readonly BACKSIDE: number;
  94593. /**
  94594. * Mesh side orientation : both internal and external or front and back surfaces
  94595. */
  94596. static readonly DOUBLESIDE: number;
  94597. /**
  94598. * Mesh side orientation : by default, `FRONTSIDE`
  94599. */
  94600. static readonly DEFAULTSIDE: number;
  94601. /**
  94602. * Mesh cap setting : no cap
  94603. */
  94604. static readonly NO_CAP: number;
  94605. /**
  94606. * Mesh cap setting : one cap at the beginning of the mesh
  94607. */
  94608. static readonly CAP_START: number;
  94609. /**
  94610. * Mesh cap setting : one cap at the end of the mesh
  94611. */
  94612. static readonly CAP_END: number;
  94613. /**
  94614. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  94615. */
  94616. static readonly CAP_ALL: number;
  94617. /**
  94618. * Mesh pattern setting : no flip or rotate
  94619. */
  94620. static readonly NO_FLIP: number;
  94621. /**
  94622. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  94623. */
  94624. static readonly FLIP_TILE: number;
  94625. /**
  94626. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  94627. */
  94628. static readonly ROTATE_TILE: number;
  94629. /**
  94630. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  94631. */
  94632. static readonly FLIP_ROW: number;
  94633. /**
  94634. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  94635. */
  94636. static readonly ROTATE_ROW: number;
  94637. /**
  94638. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  94639. */
  94640. static readonly FLIP_N_ROTATE_TILE: number;
  94641. /**
  94642. * Mesh pattern setting : rotate pattern and rotate
  94643. */
  94644. static readonly FLIP_N_ROTATE_ROW: number;
  94645. /**
  94646. * Mesh tile positioning : part tiles same on left/right or top/bottom
  94647. */
  94648. static readonly CENTER: number;
  94649. /**
  94650. * Mesh tile positioning : part tiles on left
  94651. */
  94652. static readonly LEFT: number;
  94653. /**
  94654. * Mesh tile positioning : part tiles on right
  94655. */
  94656. static readonly RIGHT: number;
  94657. /**
  94658. * Mesh tile positioning : part tiles on top
  94659. */
  94660. static readonly TOP: number;
  94661. /**
  94662. * Mesh tile positioning : part tiles on bottom
  94663. */
  94664. static readonly BOTTOM: number;
  94665. /**
  94666. * Gets the default side orientation.
  94667. * @param orientation the orientation to value to attempt to get
  94668. * @returns the default orientation
  94669. * @hidden
  94670. */
  94671. static _GetDefaultSideOrientation(orientation?: number): number;
  94672. private _internalMeshDataInfo;
  94673. /**
  94674. * An event triggered before rendering the mesh
  94675. */
  94676. get onBeforeRenderObservable(): Observable<Mesh>;
  94677. /**
  94678. * An event triggered before binding the mesh
  94679. */
  94680. get onBeforeBindObservable(): Observable<Mesh>;
  94681. /**
  94682. * An event triggered after rendering the mesh
  94683. */
  94684. get onAfterRenderObservable(): Observable<Mesh>;
  94685. /**
  94686. * An event triggered before drawing the mesh
  94687. */
  94688. get onBeforeDrawObservable(): Observable<Mesh>;
  94689. private _onBeforeDrawObserver;
  94690. /**
  94691. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  94692. */
  94693. set onBeforeDraw(callback: () => void);
  94694. get hasInstances(): boolean;
  94695. /**
  94696. * Gets the delay loading state of the mesh (when delay loading is turned on)
  94697. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  94698. */
  94699. delayLoadState: number;
  94700. /**
  94701. * Gets the list of instances created from this mesh
  94702. * it is not supposed to be modified manually.
  94703. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  94704. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94705. */
  94706. instances: InstancedMesh[];
  94707. /**
  94708. * Gets the file containing delay loading data for this mesh
  94709. */
  94710. delayLoadingFile: string;
  94711. /** @hidden */
  94712. _binaryInfo: any;
  94713. /**
  94714. * User defined function used to change how LOD level selection is done
  94715. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94716. */
  94717. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  94718. /**
  94719. * Gets or sets the morph target manager
  94720. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94721. */
  94722. get morphTargetManager(): Nullable<MorphTargetManager>;
  94723. set morphTargetManager(value: Nullable<MorphTargetManager>);
  94724. /** @hidden */
  94725. _creationDataStorage: Nullable<_CreationDataStorage>;
  94726. /** @hidden */
  94727. _geometry: Nullable<Geometry>;
  94728. /** @hidden */
  94729. _delayInfo: Array<string>;
  94730. /** @hidden */
  94731. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  94732. /** @hidden */
  94733. _instanceDataStorage: _InstanceDataStorage;
  94734. private _effectiveMaterial;
  94735. /** @hidden */
  94736. _shouldGenerateFlatShading: boolean;
  94737. /** @hidden */
  94738. _originalBuilderSideOrientation: number;
  94739. /**
  94740. * Use this property to change the original side orientation defined at construction time
  94741. */
  94742. overrideMaterialSideOrientation: Nullable<number>;
  94743. /**
  94744. * Gets the source mesh (the one used to clone this one from)
  94745. */
  94746. get source(): Nullable<Mesh>;
  94747. /**
  94748. * Gets or sets a boolean indicating that this mesh does not use index buffer
  94749. */
  94750. get isUnIndexed(): boolean;
  94751. set isUnIndexed(value: boolean);
  94752. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  94753. get worldMatrixInstancedBuffer(): Float32Array;
  94754. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  94755. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  94756. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  94757. /**
  94758. * @constructor
  94759. * @param name The value used by scene.getMeshByName() to do a lookup.
  94760. * @param scene The scene to add this mesh to.
  94761. * @param parent The parent of this mesh, if it has one
  94762. * @param source An optional Mesh from which geometry is shared, cloned.
  94763. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94764. * When false, achieved by calling a clone(), also passing False.
  94765. * This will make creation of children, recursive.
  94766. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  94767. */
  94768. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  94769. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94770. doNotInstantiate: boolean;
  94771. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94772. /**
  94773. * Gets the class name
  94774. * @returns the string "Mesh".
  94775. */
  94776. getClassName(): string;
  94777. /** @hidden */
  94778. get _isMesh(): boolean;
  94779. /**
  94780. * Returns a description of this mesh
  94781. * @param fullDetails define if full details about this mesh must be used
  94782. * @returns a descriptive string representing this mesh
  94783. */
  94784. toString(fullDetails?: boolean): string;
  94785. /** @hidden */
  94786. _unBindEffect(): void;
  94787. /**
  94788. * Gets a boolean indicating if this mesh has LOD
  94789. */
  94790. get hasLODLevels(): boolean;
  94791. /**
  94792. * Gets the list of MeshLODLevel associated with the current mesh
  94793. * @returns an array of MeshLODLevel
  94794. */
  94795. getLODLevels(): MeshLODLevel[];
  94796. private _sortLODLevels;
  94797. /**
  94798. * Add a mesh as LOD level triggered at the given distance.
  94799. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94800. * @param distance The distance from the center of the object to show this level
  94801. * @param mesh The mesh to be added as LOD level (can be null)
  94802. * @return This mesh (for chaining)
  94803. */
  94804. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  94805. /**
  94806. * Returns the LOD level mesh at the passed distance or null if not found.
  94807. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94808. * @param distance The distance from the center of the object to show this level
  94809. * @returns a Mesh or `null`
  94810. */
  94811. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  94812. /**
  94813. * Remove a mesh from the LOD array
  94814. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94815. * @param mesh defines the mesh to be removed
  94816. * @return This mesh (for chaining)
  94817. */
  94818. removeLODLevel(mesh: Mesh): Mesh;
  94819. /**
  94820. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  94821. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94822. * @param camera defines the camera to use to compute distance
  94823. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  94824. * @return This mesh (for chaining)
  94825. */
  94826. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  94827. /**
  94828. * Gets the mesh internal Geometry object
  94829. */
  94830. get geometry(): Nullable<Geometry>;
  94831. /**
  94832. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  94833. * @returns the total number of vertices
  94834. */
  94835. getTotalVertices(): number;
  94836. /**
  94837. * Returns the content of an associated vertex buffer
  94838. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94839. * - VertexBuffer.PositionKind
  94840. * - VertexBuffer.UVKind
  94841. * - VertexBuffer.UV2Kind
  94842. * - VertexBuffer.UV3Kind
  94843. * - VertexBuffer.UV4Kind
  94844. * - VertexBuffer.UV5Kind
  94845. * - VertexBuffer.UV6Kind
  94846. * - VertexBuffer.ColorKind
  94847. * - VertexBuffer.MatricesIndicesKind
  94848. * - VertexBuffer.MatricesIndicesExtraKind
  94849. * - VertexBuffer.MatricesWeightsKind
  94850. * - VertexBuffer.MatricesWeightsExtraKind
  94851. * @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
  94852. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  94853. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  94854. */
  94855. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94856. /**
  94857. * Returns the mesh VertexBuffer object from the requested `kind`
  94858. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94859. * - VertexBuffer.PositionKind
  94860. * - VertexBuffer.NormalKind
  94861. * - VertexBuffer.UVKind
  94862. * - VertexBuffer.UV2Kind
  94863. * - VertexBuffer.UV3Kind
  94864. * - VertexBuffer.UV4Kind
  94865. * - VertexBuffer.UV5Kind
  94866. * - VertexBuffer.UV6Kind
  94867. * - VertexBuffer.ColorKind
  94868. * - VertexBuffer.MatricesIndicesKind
  94869. * - VertexBuffer.MatricesIndicesExtraKind
  94870. * - VertexBuffer.MatricesWeightsKind
  94871. * - VertexBuffer.MatricesWeightsExtraKind
  94872. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  94873. */
  94874. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94875. /**
  94876. * Tests if a specific vertex buffer is associated with this mesh
  94877. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94878. * - VertexBuffer.PositionKind
  94879. * - VertexBuffer.NormalKind
  94880. * - VertexBuffer.UVKind
  94881. * - VertexBuffer.UV2Kind
  94882. * - VertexBuffer.UV3Kind
  94883. * - VertexBuffer.UV4Kind
  94884. * - VertexBuffer.UV5Kind
  94885. * - VertexBuffer.UV6Kind
  94886. * - VertexBuffer.ColorKind
  94887. * - VertexBuffer.MatricesIndicesKind
  94888. * - VertexBuffer.MatricesIndicesExtraKind
  94889. * - VertexBuffer.MatricesWeightsKind
  94890. * - VertexBuffer.MatricesWeightsExtraKind
  94891. * @returns a boolean
  94892. */
  94893. isVerticesDataPresent(kind: string): boolean;
  94894. /**
  94895. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  94896. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94897. * - VertexBuffer.PositionKind
  94898. * - VertexBuffer.UVKind
  94899. * - VertexBuffer.UV2Kind
  94900. * - VertexBuffer.UV3Kind
  94901. * - VertexBuffer.UV4Kind
  94902. * - VertexBuffer.UV5Kind
  94903. * - VertexBuffer.UV6Kind
  94904. * - VertexBuffer.ColorKind
  94905. * - VertexBuffer.MatricesIndicesKind
  94906. * - VertexBuffer.MatricesIndicesExtraKind
  94907. * - VertexBuffer.MatricesWeightsKind
  94908. * - VertexBuffer.MatricesWeightsExtraKind
  94909. * @returns a boolean
  94910. */
  94911. isVertexBufferUpdatable(kind: string): boolean;
  94912. /**
  94913. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  94914. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94915. * - VertexBuffer.PositionKind
  94916. * - VertexBuffer.NormalKind
  94917. * - VertexBuffer.UVKind
  94918. * - VertexBuffer.UV2Kind
  94919. * - VertexBuffer.UV3Kind
  94920. * - VertexBuffer.UV4Kind
  94921. * - VertexBuffer.UV5Kind
  94922. * - VertexBuffer.UV6Kind
  94923. * - VertexBuffer.ColorKind
  94924. * - VertexBuffer.MatricesIndicesKind
  94925. * - VertexBuffer.MatricesIndicesExtraKind
  94926. * - VertexBuffer.MatricesWeightsKind
  94927. * - VertexBuffer.MatricesWeightsExtraKind
  94928. * @returns an array of strings
  94929. */
  94930. getVerticesDataKinds(): string[];
  94931. /**
  94932. * Returns a positive integer : the total number of indices in this mesh geometry.
  94933. * @returns the numner of indices or zero if the mesh has no geometry.
  94934. */
  94935. getTotalIndices(): number;
  94936. /**
  94937. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94938. * @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.
  94939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94940. * @returns the indices array or an empty array if the mesh has no geometry
  94941. */
  94942. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94943. get isBlocked(): boolean;
  94944. /**
  94945. * Determine if the current mesh is ready to be rendered
  94946. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94947. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  94948. * @returns true if all associated assets are ready (material, textures, shaders)
  94949. */
  94950. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  94951. /**
  94952. * 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.
  94953. */
  94954. get areNormalsFrozen(): boolean;
  94955. /**
  94956. * 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.
  94957. * @returns the current mesh
  94958. */
  94959. freezeNormals(): Mesh;
  94960. /**
  94961. * 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
  94962. * @returns the current mesh
  94963. */
  94964. unfreezeNormals(): Mesh;
  94965. /**
  94966. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  94967. */
  94968. set overridenInstanceCount(count: number);
  94969. /** @hidden */
  94970. _preActivate(): Mesh;
  94971. /** @hidden */
  94972. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94973. /** @hidden */
  94974. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  94975. /**
  94976. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94977. * This means the mesh underlying bounding box and sphere are recomputed.
  94978. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94979. * @returns the current mesh
  94980. */
  94981. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  94982. /** @hidden */
  94983. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  94984. /**
  94985. * This function will subdivide the mesh into multiple submeshes
  94986. * @param count defines the expected number of submeshes
  94987. */
  94988. subdivide(count: number): void;
  94989. /**
  94990. * Copy a FloatArray into a specific associated vertex buffer
  94991. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94992. * - VertexBuffer.PositionKind
  94993. * - VertexBuffer.UVKind
  94994. * - VertexBuffer.UV2Kind
  94995. * - VertexBuffer.UV3Kind
  94996. * - VertexBuffer.UV4Kind
  94997. * - VertexBuffer.UV5Kind
  94998. * - VertexBuffer.UV6Kind
  94999. * - VertexBuffer.ColorKind
  95000. * - VertexBuffer.MatricesIndicesKind
  95001. * - VertexBuffer.MatricesIndicesExtraKind
  95002. * - VertexBuffer.MatricesWeightsKind
  95003. * - VertexBuffer.MatricesWeightsExtraKind
  95004. * @param data defines the data source
  95005. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95006. * @param stride defines the data stride size (can be null)
  95007. * @returns the current mesh
  95008. */
  95009. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95010. /**
  95011. * Delete a vertex buffer associated with this mesh
  95012. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  95013. * - VertexBuffer.PositionKind
  95014. * - VertexBuffer.UVKind
  95015. * - VertexBuffer.UV2Kind
  95016. * - VertexBuffer.UV3Kind
  95017. * - VertexBuffer.UV4Kind
  95018. * - VertexBuffer.UV5Kind
  95019. * - VertexBuffer.UV6Kind
  95020. * - VertexBuffer.ColorKind
  95021. * - VertexBuffer.MatricesIndicesKind
  95022. * - VertexBuffer.MatricesIndicesExtraKind
  95023. * - VertexBuffer.MatricesWeightsKind
  95024. * - VertexBuffer.MatricesWeightsExtraKind
  95025. */
  95026. removeVerticesData(kind: string): void;
  95027. /**
  95028. * Flags an associated vertex buffer as updatable
  95029. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95030. * - VertexBuffer.PositionKind
  95031. * - VertexBuffer.UVKind
  95032. * - VertexBuffer.UV2Kind
  95033. * - VertexBuffer.UV3Kind
  95034. * - VertexBuffer.UV4Kind
  95035. * - VertexBuffer.UV5Kind
  95036. * - VertexBuffer.UV6Kind
  95037. * - VertexBuffer.ColorKind
  95038. * - VertexBuffer.MatricesIndicesKind
  95039. * - VertexBuffer.MatricesIndicesExtraKind
  95040. * - VertexBuffer.MatricesWeightsKind
  95041. * - VertexBuffer.MatricesWeightsExtraKind
  95042. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95043. */
  95044. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95045. /**
  95046. * Sets the mesh global Vertex Buffer
  95047. * @param buffer defines the buffer to use
  95048. * @returns the current mesh
  95049. */
  95050. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95051. /**
  95052. * Update a specific associated vertex buffer
  95053. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95054. * - VertexBuffer.PositionKind
  95055. * - VertexBuffer.UVKind
  95056. * - VertexBuffer.UV2Kind
  95057. * - VertexBuffer.UV3Kind
  95058. * - VertexBuffer.UV4Kind
  95059. * - VertexBuffer.UV5Kind
  95060. * - VertexBuffer.UV6Kind
  95061. * - VertexBuffer.ColorKind
  95062. * - VertexBuffer.MatricesIndicesKind
  95063. * - VertexBuffer.MatricesIndicesExtraKind
  95064. * - VertexBuffer.MatricesWeightsKind
  95065. * - VertexBuffer.MatricesWeightsExtraKind
  95066. * @param data defines the data source
  95067. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95068. * @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)
  95069. * @returns the current mesh
  95070. */
  95071. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95072. /**
  95073. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95074. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95075. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95076. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95077. * @returns the current mesh
  95078. */
  95079. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95080. /**
  95081. * Creates a un-shared specific occurence of the geometry for the mesh.
  95082. * @returns the current mesh
  95083. */
  95084. makeGeometryUnique(): Mesh;
  95085. /**
  95086. * Set the index buffer of this mesh
  95087. * @param indices defines the source data
  95088. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95089. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95090. * @returns the current mesh
  95091. */
  95092. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95093. /**
  95094. * Update the current index buffer
  95095. * @param indices defines the source data
  95096. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95097. * @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)
  95098. * @returns the current mesh
  95099. */
  95100. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95101. /**
  95102. * Invert the geometry to move from a right handed system to a left handed one.
  95103. * @returns the current mesh
  95104. */
  95105. toLeftHanded(): Mesh;
  95106. /** @hidden */
  95107. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95108. /** @hidden */
  95109. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95110. /**
  95111. * Registers for this mesh a javascript function called just before the rendering process
  95112. * @param func defines the function to call before rendering this mesh
  95113. * @returns the current mesh
  95114. */
  95115. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95116. /**
  95117. * Disposes a previously registered javascript function called before the rendering
  95118. * @param func defines the function to remove
  95119. * @returns the current mesh
  95120. */
  95121. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95122. /**
  95123. * Registers for this mesh a javascript function called just after the rendering is complete
  95124. * @param func defines the function to call after rendering this mesh
  95125. * @returns the current mesh
  95126. */
  95127. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95128. /**
  95129. * Disposes a previously registered javascript function called after the rendering.
  95130. * @param func defines the function to remove
  95131. * @returns the current mesh
  95132. */
  95133. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95134. /** @hidden */
  95135. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95136. /** @hidden */
  95137. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95138. /** @hidden */
  95139. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95140. /** @hidden */
  95141. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95142. /** @hidden */
  95143. _rebuild(): void;
  95144. /** @hidden */
  95145. _freeze(): void;
  95146. /** @hidden */
  95147. _unFreeze(): void;
  95148. /**
  95149. * 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
  95150. * @param subMesh defines the subMesh to render
  95151. * @param enableAlphaMode defines if alpha mode can be changed
  95152. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95153. * @returns the current mesh
  95154. */
  95155. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95156. private _onBeforeDraw;
  95157. /**
  95158. * Renormalize the mesh and patch it up if there are no weights
  95159. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95160. * However in the case of zero weights then we set just a single influence to 1.
  95161. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95162. */
  95163. cleanMatrixWeights(): void;
  95164. private normalizeSkinFourWeights;
  95165. private normalizeSkinWeightsAndExtra;
  95166. /**
  95167. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95168. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95169. * the user know there was an issue with importing the mesh
  95170. * @returns a validation object with skinned, valid and report string
  95171. */
  95172. validateSkinning(): {
  95173. skinned: boolean;
  95174. valid: boolean;
  95175. report: string;
  95176. };
  95177. /** @hidden */
  95178. _checkDelayState(): Mesh;
  95179. private _queueLoad;
  95180. /**
  95181. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95182. * A mesh is in the frustum if its bounding box intersects the frustum
  95183. * @param frustumPlanes defines the frustum to test
  95184. * @returns true if the mesh is in the frustum planes
  95185. */
  95186. isInFrustum(frustumPlanes: Plane[]): boolean;
  95187. /**
  95188. * Sets the mesh material by the material or multiMaterial `id` property
  95189. * @param id is a string identifying the material or the multiMaterial
  95190. * @returns the current mesh
  95191. */
  95192. setMaterialByID(id: string): Mesh;
  95193. /**
  95194. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  95195. * @returns an array of IAnimatable
  95196. */
  95197. getAnimatables(): IAnimatable[];
  95198. /**
  95199. * Modifies the mesh geometry according to the passed transformation matrix.
  95200. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  95201. * The mesh normals are modified using the same transformation.
  95202. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95203. * @param transform defines the transform matrix to use
  95204. * @see http://doc.babylonjs.com/resources/baking_transformations
  95205. * @returns the current mesh
  95206. */
  95207. bakeTransformIntoVertices(transform: Matrix): Mesh;
  95208. /**
  95209. * Modifies the mesh geometry according to its own current World Matrix.
  95210. * The mesh World Matrix is then reset.
  95211. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  95212. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95213. * @see http://doc.babylonjs.com/resources/baking_transformations
  95214. * @returns the current mesh
  95215. */
  95216. bakeCurrentTransformIntoVertices(): Mesh;
  95217. /** @hidden */
  95218. get _positions(): Nullable<Vector3[]>;
  95219. /** @hidden */
  95220. _resetPointsArrayCache(): Mesh;
  95221. /** @hidden */
  95222. _generatePointsArray(): boolean;
  95223. /**
  95224. * Returns a new Mesh object generated from the current mesh properties.
  95225. * This method must not get confused with createInstance()
  95226. * @param name is a string, the name given to the new mesh
  95227. * @param newParent can be any Node object (default `null`)
  95228. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  95229. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  95230. * @returns a new mesh
  95231. */
  95232. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  95233. /**
  95234. * Releases resources associated with this mesh.
  95235. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95236. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95237. */
  95238. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95239. /** @hidden */
  95240. _disposeInstanceSpecificData(): void;
  95241. /**
  95242. * Modifies the mesh geometry according to a displacement map.
  95243. * 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.
  95244. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95245. * @param url is a string, the URL from the image file is to be downloaded.
  95246. * @param minHeight is the lower limit of the displacement.
  95247. * @param maxHeight is the upper limit of the displacement.
  95248. * @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.
  95249. * @param uvOffset is an optional vector2 used to offset UV.
  95250. * @param uvScale is an optional vector2 used to scale UV.
  95251. * @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.
  95252. * @returns the Mesh.
  95253. */
  95254. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95255. /**
  95256. * Modifies the mesh geometry according to a displacementMap buffer.
  95257. * 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.
  95258. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95259. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  95260. * @param heightMapWidth is the width of the buffer image.
  95261. * @param heightMapHeight is the height of the buffer image.
  95262. * @param minHeight is the lower limit of the displacement.
  95263. * @param maxHeight is the upper limit of the displacement.
  95264. * @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.
  95265. * @param uvOffset is an optional vector2 used to offset UV.
  95266. * @param uvScale is an optional vector2 used to scale UV.
  95267. * @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.
  95268. * @returns the Mesh.
  95269. */
  95270. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95271. /**
  95272. * Modify the mesh to get a flat shading rendering.
  95273. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  95274. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  95275. * @returns current mesh
  95276. */
  95277. convertToFlatShadedMesh(): Mesh;
  95278. /**
  95279. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  95280. * In other words, more vertices, no more indices and a single bigger VBO.
  95281. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  95282. * @returns current mesh
  95283. */
  95284. convertToUnIndexedMesh(): Mesh;
  95285. /**
  95286. * Inverses facet orientations.
  95287. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95288. * @param flipNormals will also inverts the normals
  95289. * @returns current mesh
  95290. */
  95291. flipFaces(flipNormals?: boolean): Mesh;
  95292. /**
  95293. * Increase the number of facets and hence vertices in a mesh
  95294. * Vertex normals are interpolated from existing vertex normals
  95295. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95296. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  95297. */
  95298. increaseVertices(numberPerEdge: number): void;
  95299. /**
  95300. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  95301. * This will undo any application of covertToFlatShadedMesh
  95302. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95303. */
  95304. forceSharedVertices(): void;
  95305. /** @hidden */
  95306. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  95307. /** @hidden */
  95308. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  95309. /**
  95310. * Creates a new InstancedMesh object from the mesh model.
  95311. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95312. * @param name defines the name of the new instance
  95313. * @returns a new InstancedMesh
  95314. */
  95315. createInstance(name: string): InstancedMesh;
  95316. /**
  95317. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  95318. * After this call, all the mesh instances have the same submeshes than the current mesh.
  95319. * @returns the current mesh
  95320. */
  95321. synchronizeInstances(): Mesh;
  95322. /**
  95323. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  95324. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  95325. * This should be used together with the simplification to avoid disappearing triangles.
  95326. * @param successCallback an optional success callback to be called after the optimization finished.
  95327. * @returns the current mesh
  95328. */
  95329. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  95330. /**
  95331. * Serialize current mesh
  95332. * @param serializationObject defines the object which will receive the serialization data
  95333. */
  95334. serialize(serializationObject: any): void;
  95335. /** @hidden */
  95336. _syncGeometryWithMorphTargetManager(): void;
  95337. /** @hidden */
  95338. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  95339. /**
  95340. * Returns a new Mesh object parsed from the source provided.
  95341. * @param parsedMesh is the source
  95342. * @param scene defines the hosting scene
  95343. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  95344. * @returns a new Mesh
  95345. */
  95346. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  95347. /**
  95348. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  95349. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95350. * @param name defines the name of the mesh to create
  95351. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  95352. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  95353. * @param closePath creates a seam between the first and the last points of each path of the path array
  95354. * @param offset is taken in account only if the `pathArray` is containing a single path
  95355. * @param scene defines the hosting scene
  95356. * @param updatable defines if the mesh must be flagged as updatable
  95357. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95358. * @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)
  95359. * @returns a new Mesh
  95360. */
  95361. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95362. /**
  95363. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  95364. * @param name defines the name of the mesh to create
  95365. * @param radius sets the radius size (float) of the polygon (default 0.5)
  95366. * @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
  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 CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95373. /**
  95374. * Creates a box 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 size sets the size (float) of each box side (default 1)
  95377. * @param scene defines the hosting scene
  95378. * @param updatable defines if the mesh must be flagged as updatable
  95379. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95380. * @returns a new Mesh
  95381. */
  95382. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95383. /**
  95384. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  95385. * @param name defines the name of the mesh to create
  95386. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95387. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95388. * @param scene defines the hosting scene
  95389. * @param updatable defines if the mesh must be flagged as updatable
  95390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95391. * @returns a new Mesh
  95392. */
  95393. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95394. /**
  95395. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  95396. * @param name defines the name of the mesh to create
  95397. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95398. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95399. * @param scene defines the hosting scene
  95400. * @returns a new Mesh
  95401. */
  95402. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  95403. /**
  95404. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  95405. * @param name defines the name of the mesh to create
  95406. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  95407. * @param diameterTop set the top cap diameter (floats, default 1)
  95408. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  95409. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  95410. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  95411. * @param scene defines the hosting scene
  95412. * @param updatable defines if the mesh must be flagged as updatable
  95413. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95414. * @returns a new Mesh
  95415. */
  95416. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  95417. /**
  95418. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  95419. * @param name defines the name of the mesh to create
  95420. * @param diameter sets the diameter size (float) of the torus (default 1)
  95421. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  95422. * @param tessellation sets the number of torus sides (postive integer, default 16)
  95423. * @param scene defines the hosting scene
  95424. * @param updatable defines if the mesh must be flagged as updatable
  95425. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95426. * @returns a new Mesh
  95427. */
  95428. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95429. /**
  95430. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  95431. * @param name defines the name of the mesh to create
  95432. * @param radius sets the global radius size (float) of the torus knot (default 2)
  95433. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  95434. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  95435. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  95436. * @param p the number of windings on X axis (positive integers, default 2)
  95437. * @param q the number of windings on Y axis (positive integers, default 3)
  95438. * @param scene defines the hosting scene
  95439. * @param updatable defines if the mesh must be flagged as updatable
  95440. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95441. * @returns a new Mesh
  95442. */
  95443. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95444. /**
  95445. * Creates a 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 scene defines the hosting scene
  95449. * @param updatable defines if the mesh must be flagged as updatable
  95450. * @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).
  95451. * @returns a new Mesh
  95452. */
  95453. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  95454. /**
  95455. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  95456. * @param name defines the name of the mesh to create
  95457. * @param points is an array successive Vector3
  95458. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  95459. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95460. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  95461. * @param scene defines the hosting scene
  95462. * @param updatable defines if the mesh must be flagged as updatable
  95463. * @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)
  95464. * @returns a new Mesh
  95465. */
  95466. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  95467. /**
  95468. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  95469. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  95470. * 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.
  95471. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95472. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95473. * Remember you can only change the shape positions, not their number when updating a polygon.
  95474. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  95475. * @param name defines the name of the mesh to create
  95476. * @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
  95477. * @param scene defines the hosting scene
  95478. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95479. * @param updatable defines if the mesh must be flagged as updatable
  95480. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95481. * @param earcutInjection can be used to inject your own earcut reference
  95482. * @returns a new Mesh
  95483. */
  95484. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95485. /**
  95486. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  95487. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  95488. * @param name defines the name of the mesh to create
  95489. * @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
  95490. * @param depth defines the height of extrusion
  95491. * @param scene defines the hosting scene
  95492. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95493. * @param updatable defines if the mesh must be flagged as updatable
  95494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95495. * @param earcutInjection can be used to inject your own earcut reference
  95496. * @returns a new Mesh
  95497. */
  95498. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95499. /**
  95500. * Creates an extruded shape mesh.
  95501. * 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
  95502. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95503. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95504. * @param name defines the name of the mesh to create
  95505. * @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
  95506. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95507. * @param scale is the value to scale the shape
  95508. * @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
  95509. * @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
  95510. * @param scene defines the hosting scene
  95511. * @param updatable defines if the mesh must be flagged as updatable
  95512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95513. * @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)
  95514. * @returns a new Mesh
  95515. */
  95516. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95517. /**
  95518. * Creates an custom extruded shape mesh.
  95519. * The custom extrusion is a parametric shape.
  95520. * It has no predefined shape. Its final shape will depend on the input parameters.
  95521. * Please consider using the same method from the MeshBuilder class instead
  95522. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95523. * @param name defines the name of the mesh to create
  95524. * @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
  95525. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95526. * @param scaleFunction is a custom Javascript function called on each path point
  95527. * @param rotationFunction is a custom Javascript function called on each path point
  95528. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  95529. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  95530. * @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
  95531. * @param scene defines the hosting scene
  95532. * @param updatable defines if the mesh must be flagged as updatable
  95533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95534. * @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)
  95535. * @returns a new Mesh
  95536. */
  95537. 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;
  95538. /**
  95539. * Creates lathe mesh.
  95540. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  95541. * Please consider using the same method from the MeshBuilder class instead
  95542. * @param name defines the name of the mesh to create
  95543. * @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
  95544. * @param radius is the radius value of the lathe
  95545. * @param tessellation is the side number of the lathe.
  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 CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95552. /**
  95553. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  95554. * @param name defines the name of the mesh to create
  95555. * @param size sets the size (float) of both sides of the plane at once (default 1)
  95556. * @param scene defines the hosting scene
  95557. * @param updatable defines if the mesh must be flagged as updatable
  95558. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95559. * @returns a new Mesh
  95560. */
  95561. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95562. /**
  95563. * Creates a ground mesh.
  95564. * Please consider using the same method from the MeshBuilder class instead
  95565. * @param name defines the name of the mesh to create
  95566. * @param width set the width of the ground
  95567. * @param height set the height of the ground
  95568. * @param subdivisions sets the number of subdivisions per side
  95569. * @param scene defines the hosting scene
  95570. * @param updatable defines if the mesh must be flagged as updatable
  95571. * @returns a new Mesh
  95572. */
  95573. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  95574. /**
  95575. * Creates a tiled ground mesh.
  95576. * Please consider using the same method from the MeshBuilder class instead
  95577. * @param name defines the name of the mesh to create
  95578. * @param xmin set the ground minimum X coordinate
  95579. * @param zmin set the ground minimum Y coordinate
  95580. * @param xmax set the ground maximum X coordinate
  95581. * @param zmax set the ground maximum Z coordinate
  95582. * @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
  95583. * @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
  95584. * @param scene defines the hosting scene
  95585. * @param updatable defines if the mesh must be flagged as updatable
  95586. * @returns a new Mesh
  95587. */
  95588. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  95589. w: number;
  95590. h: number;
  95591. }, precision: {
  95592. w: number;
  95593. h: number;
  95594. }, scene: Scene, updatable?: boolean): Mesh;
  95595. /**
  95596. * Creates a ground mesh from a height map.
  95597. * Please consider using the same method from the MeshBuilder class instead
  95598. * @see http://doc.babylonjs.com/babylon101/height_map
  95599. * @param name defines the name of the mesh to create
  95600. * @param url sets the URL of the height map image resource
  95601. * @param width set the ground width size
  95602. * @param height set the ground height size
  95603. * @param subdivisions sets the number of subdivision per side
  95604. * @param minHeight is the minimum altitude on the ground
  95605. * @param maxHeight is the maximum altitude on the ground
  95606. * @param scene defines the hosting scene
  95607. * @param updatable defines if the mesh must be flagged as updatable
  95608. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  95609. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95610. * @returns a new Mesh
  95611. */
  95612. 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;
  95613. /**
  95614. * Creates a tube mesh.
  95615. * The tube is a parametric shape.
  95616. * It has no predefined shape. Its final shape will depend on the input parameters.
  95617. * Please consider using the same method from the MeshBuilder class instead
  95618. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95619. * @param name defines the name of the mesh to create
  95620. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  95621. * @param radius sets the tube radius size
  95622. * @param tessellation is the number of sides on the tubular surface
  95623. * @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
  95624. * @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
  95625. * @param scene defines the hosting scene
  95626. * @param updatable defines if the mesh must be flagged as updatable
  95627. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95628. * @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)
  95629. * @returns a new Mesh
  95630. */
  95631. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  95632. (i: number, distance: number): number;
  95633. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95634. /**
  95635. * Creates a polyhedron mesh.
  95636. * Please consider using the same method from the MeshBuilder class instead.
  95637. * * 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
  95638. * * The parameter `size` (positive float, default 1) sets the polygon size
  95639. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  95640. * * 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`
  95641. * * 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
  95642. * * 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)`)
  95643. * * 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
  95644. * * 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
  95645. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95646. * * If you create a double-sided mesh, you can choose what parts of 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
  95647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95648. * @param name defines the name of the mesh to create
  95649. * @param options defines the options used to create the mesh
  95650. * @param scene defines the hosting scene
  95651. * @returns a new Mesh
  95652. */
  95653. static CreatePolyhedron(name: string, options: {
  95654. type?: number;
  95655. size?: number;
  95656. sizeX?: number;
  95657. sizeY?: number;
  95658. sizeZ?: number;
  95659. custom?: any;
  95660. faceUV?: Vector4[];
  95661. faceColors?: Color4[];
  95662. updatable?: boolean;
  95663. sideOrientation?: number;
  95664. }, scene: Scene): Mesh;
  95665. /**
  95666. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  95667. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  95668. * * 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`)
  95669. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  95670. * * 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
  95671. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95672. * * If you create a double-sided mesh, you can choose what parts of 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
  95673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95674. * @param name defines the name of the mesh
  95675. * @param options defines the options used to create the mesh
  95676. * @param scene defines the hosting scene
  95677. * @returns a new Mesh
  95678. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  95679. */
  95680. static CreateIcoSphere(name: string, options: {
  95681. radius?: number;
  95682. flat?: boolean;
  95683. subdivisions?: number;
  95684. sideOrientation?: number;
  95685. updatable?: boolean;
  95686. }, scene: Scene): Mesh;
  95687. /**
  95688. * Creates a decal mesh.
  95689. * Please consider using the same method from the MeshBuilder class instead.
  95690. * A decal is a mesh usually applied as a model onto the surface of another mesh
  95691. * @param name defines the name of the mesh
  95692. * @param sourceMesh defines the mesh receiving the decal
  95693. * @param position sets the position of the decal in world coordinates
  95694. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  95695. * @param size sets the decal scaling
  95696. * @param angle sets the angle to rotate the decal
  95697. * @returns a new Mesh
  95698. */
  95699. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  95700. /**
  95701. * Prepare internal position array for software CPU skinning
  95702. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  95703. */
  95704. setPositionsForCPUSkinning(): Float32Array;
  95705. /**
  95706. * Prepare internal normal array for software CPU skinning
  95707. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  95708. */
  95709. setNormalsForCPUSkinning(): Float32Array;
  95710. /**
  95711. * Updates the vertex buffer by applying transformation from the bones
  95712. * @param skeleton defines the skeleton to apply to current mesh
  95713. * @returns the current mesh
  95714. */
  95715. applySkeleton(skeleton: Skeleton): Mesh;
  95716. /**
  95717. * 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
  95718. * @param meshes defines the list of meshes to scan
  95719. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  95720. */
  95721. static MinMax(meshes: AbstractMesh[]): {
  95722. min: Vector3;
  95723. max: Vector3;
  95724. };
  95725. /**
  95726. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  95727. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  95728. * @returns a vector3
  95729. */
  95730. static Center(meshesOrMinMaxVector: {
  95731. min: Vector3;
  95732. max: Vector3;
  95733. } | AbstractMesh[]): Vector3;
  95734. /**
  95735. * Merge the array of meshes into a single mesh for performance reasons.
  95736. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  95737. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  95738. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  95739. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  95740. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  95741. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  95742. * @returns a new mesh
  95743. */
  95744. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  95745. /** @hidden */
  95746. addInstance(instance: InstancedMesh): void;
  95747. /** @hidden */
  95748. removeInstance(instance: InstancedMesh): void;
  95749. }
  95750. }
  95751. declare module BABYLON {
  95752. /**
  95753. * This is the base class of all the camera used in the application.
  95754. * @see http://doc.babylonjs.com/features/cameras
  95755. */
  95756. export class Camera extends Node {
  95757. /** @hidden */
  95758. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  95759. /**
  95760. * This is the default projection mode used by the cameras.
  95761. * It helps recreating a feeling of perspective and better appreciate depth.
  95762. * This is the best way to simulate real life cameras.
  95763. */
  95764. static readonly PERSPECTIVE_CAMERA: number;
  95765. /**
  95766. * This helps creating camera with an orthographic mode.
  95767. * 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.
  95768. */
  95769. static readonly ORTHOGRAPHIC_CAMERA: number;
  95770. /**
  95771. * This is the default FOV mode for perspective cameras.
  95772. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  95773. */
  95774. static readonly FOVMODE_VERTICAL_FIXED: number;
  95775. /**
  95776. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  95777. */
  95778. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  95779. /**
  95780. * This specifies ther is no need for a camera rig.
  95781. * Basically only one eye is rendered corresponding to the camera.
  95782. */
  95783. static readonly RIG_MODE_NONE: number;
  95784. /**
  95785. * Simulates a camera Rig with one blue eye and one red eye.
  95786. * This can be use with 3d blue and red glasses.
  95787. */
  95788. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  95789. /**
  95790. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  95791. */
  95792. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  95793. /**
  95794. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  95795. */
  95796. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  95797. /**
  95798. * Defines that both eyes of the camera will be rendered over under each other.
  95799. */
  95800. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  95801. /**
  95802. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  95803. */
  95804. static readonly RIG_MODE_VR: number;
  95805. /**
  95806. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  95807. */
  95808. static readonly RIG_MODE_WEBVR: number;
  95809. /**
  95810. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  95811. */
  95812. static readonly RIG_MODE_CUSTOM: number;
  95813. /**
  95814. * Defines if by default attaching controls should prevent the default javascript event to continue.
  95815. */
  95816. static ForceAttachControlToAlwaysPreventDefault: boolean;
  95817. /**
  95818. * Define the input manager associated with the camera.
  95819. */
  95820. inputs: CameraInputsManager<Camera>;
  95821. /** @hidden */
  95822. _position: Vector3;
  95823. /**
  95824. * Define the current local position of the camera in the scene
  95825. */
  95826. get position(): Vector3;
  95827. set position(newPosition: Vector3);
  95828. /**
  95829. * The vector the camera should consider as up.
  95830. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  95831. */
  95832. upVector: Vector3;
  95833. /**
  95834. * Define the current limit on the left side for an orthographic camera
  95835. * In scene unit
  95836. */
  95837. orthoLeft: Nullable<number>;
  95838. /**
  95839. * Define the current limit on the right side for an orthographic camera
  95840. * In scene unit
  95841. */
  95842. orthoRight: Nullable<number>;
  95843. /**
  95844. * Define the current limit on the bottom side for an orthographic camera
  95845. * In scene unit
  95846. */
  95847. orthoBottom: Nullable<number>;
  95848. /**
  95849. * Define the current limit on the top side for an orthographic camera
  95850. * In scene unit
  95851. */
  95852. orthoTop: Nullable<number>;
  95853. /**
  95854. * Field Of View is set in Radians. (default is 0.8)
  95855. */
  95856. fov: number;
  95857. /**
  95858. * Define the minimum distance the camera can see from.
  95859. * This is important to note that the depth buffer are not infinite and the closer it starts
  95860. * the more your scene might encounter depth fighting issue.
  95861. */
  95862. minZ: number;
  95863. /**
  95864. * Define the maximum distance the camera can see to.
  95865. * This is important to note that the depth buffer are not infinite and the further it end
  95866. * the more your scene might encounter depth fighting issue.
  95867. */
  95868. maxZ: number;
  95869. /**
  95870. * Define the default inertia of the camera.
  95871. * This helps giving a smooth feeling to the camera movement.
  95872. */
  95873. inertia: number;
  95874. /**
  95875. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  95876. */
  95877. mode: number;
  95878. /**
  95879. * Define wether the camera is intermediate.
  95880. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  95881. */
  95882. isIntermediate: boolean;
  95883. /**
  95884. * Define the viewport of the camera.
  95885. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  95886. */
  95887. viewport: Viewport;
  95888. /**
  95889. * Restricts the camera to viewing objects with the same layerMask.
  95890. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  95891. */
  95892. layerMask: number;
  95893. /**
  95894. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  95895. */
  95896. fovMode: number;
  95897. /**
  95898. * Rig mode of the camera.
  95899. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  95900. * This is normally controlled byt the camera themselves as internal use.
  95901. */
  95902. cameraRigMode: number;
  95903. /**
  95904. * Defines the distance between both "eyes" in case of a RIG
  95905. */
  95906. interaxialDistance: number;
  95907. /**
  95908. * Defines if stereoscopic rendering is done side by side or over under.
  95909. */
  95910. isStereoscopicSideBySide: boolean;
  95911. /**
  95912. * 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
  95913. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  95914. * else in the scene. (Eg. security camera)
  95915. *
  95916. * 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)
  95917. */
  95918. customRenderTargets: RenderTargetTexture[];
  95919. /**
  95920. * When set, the camera will render to this render target instead of the default canvas
  95921. *
  95922. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  95923. */
  95924. outputRenderTarget: Nullable<RenderTargetTexture>;
  95925. /**
  95926. * Observable triggered when the camera view matrix has changed.
  95927. */
  95928. onViewMatrixChangedObservable: Observable<Camera>;
  95929. /**
  95930. * Observable triggered when the camera Projection matrix has changed.
  95931. */
  95932. onProjectionMatrixChangedObservable: Observable<Camera>;
  95933. /**
  95934. * Observable triggered when the inputs have been processed.
  95935. */
  95936. onAfterCheckInputsObservable: Observable<Camera>;
  95937. /**
  95938. * Observable triggered when reset has been called and applied to the camera.
  95939. */
  95940. onRestoreStateObservable: Observable<Camera>;
  95941. /** @hidden */
  95942. _cameraRigParams: any;
  95943. /** @hidden */
  95944. _rigCameras: Camera[];
  95945. /** @hidden */
  95946. _rigPostProcess: Nullable<PostProcess>;
  95947. protected _webvrViewMatrix: Matrix;
  95948. /** @hidden */
  95949. _skipRendering: boolean;
  95950. /** @hidden */
  95951. _projectionMatrix: Matrix;
  95952. /** @hidden */
  95953. _postProcesses: Nullable<PostProcess>[];
  95954. /** @hidden */
  95955. _activeMeshes: SmartArray<AbstractMesh>;
  95956. protected _globalPosition: Vector3;
  95957. /** @hidden */
  95958. _computedViewMatrix: Matrix;
  95959. private _doNotComputeProjectionMatrix;
  95960. private _transformMatrix;
  95961. private _frustumPlanes;
  95962. private _refreshFrustumPlanes;
  95963. private _storedFov;
  95964. private _stateStored;
  95965. /**
  95966. * Instantiates a new camera object.
  95967. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  95968. * @see http://doc.babylonjs.com/features/cameras
  95969. * @param name Defines the name of the camera in the scene
  95970. * @param position Defines the position of the camera
  95971. * @param scene Defines the scene the camera belongs too
  95972. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  95973. */
  95974. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95975. /**
  95976. * Store current camera state (fov, position, etc..)
  95977. * @returns the camera
  95978. */
  95979. storeState(): Camera;
  95980. /**
  95981. * Restores the camera state values if it has been stored. You must call storeState() first
  95982. */
  95983. protected _restoreStateValues(): boolean;
  95984. /**
  95985. * Restored camera state. You must call storeState() first.
  95986. * @returns true if restored and false otherwise
  95987. */
  95988. restoreState(): boolean;
  95989. /**
  95990. * Gets the class name of the camera.
  95991. * @returns the class name
  95992. */
  95993. getClassName(): string;
  95994. /** @hidden */
  95995. readonly _isCamera: boolean;
  95996. /**
  95997. * Gets a string representation of the camera useful for debug purpose.
  95998. * @param fullDetails Defines that a more verboe level of logging is required
  95999. * @returns the string representation
  96000. */
  96001. toString(fullDetails?: boolean): string;
  96002. /**
  96003. * Gets the current world space position of the camera.
  96004. */
  96005. get globalPosition(): Vector3;
  96006. /**
  96007. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  96008. * @returns the active meshe list
  96009. */
  96010. getActiveMeshes(): SmartArray<AbstractMesh>;
  96011. /**
  96012. * Check wether a mesh is part of the current active mesh list of the camera
  96013. * @param mesh Defines the mesh to check
  96014. * @returns true if active, false otherwise
  96015. */
  96016. isActiveMesh(mesh: Mesh): boolean;
  96017. /**
  96018. * Is this camera ready to be used/rendered
  96019. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  96020. * @return true if the camera is ready
  96021. */
  96022. isReady(completeCheck?: boolean): boolean;
  96023. /** @hidden */
  96024. _initCache(): void;
  96025. /** @hidden */
  96026. _updateCache(ignoreParentClass?: boolean): void;
  96027. /** @hidden */
  96028. _isSynchronized(): boolean;
  96029. /** @hidden */
  96030. _isSynchronizedViewMatrix(): boolean;
  96031. /** @hidden */
  96032. _isSynchronizedProjectionMatrix(): boolean;
  96033. /**
  96034. * Attach the input controls to a specific dom element to get the input from.
  96035. * @param element Defines the element the controls should be listened from
  96036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96037. */
  96038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96039. /**
  96040. * Detach the current controls from the specified dom element.
  96041. * @param element Defines the element to stop listening the inputs from
  96042. */
  96043. detachControl(element: HTMLElement): void;
  96044. /**
  96045. * Update the camera state according to the different inputs gathered during the frame.
  96046. */
  96047. update(): void;
  96048. /** @hidden */
  96049. _checkInputs(): void;
  96050. /** @hidden */
  96051. get rigCameras(): Camera[];
  96052. /**
  96053. * Gets the post process used by the rig cameras
  96054. */
  96055. get rigPostProcess(): Nullable<PostProcess>;
  96056. /**
  96057. * Internal, gets the first post proces.
  96058. * @returns the first post process to be run on this camera.
  96059. */
  96060. _getFirstPostProcess(): Nullable<PostProcess>;
  96061. private _cascadePostProcessesToRigCams;
  96062. /**
  96063. * Attach a post process to the camera.
  96064. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96065. * @param postProcess The post process to attach to the camera
  96066. * @param insertAt The position of the post process in case several of them are in use in the scene
  96067. * @returns the position the post process has been inserted at
  96068. */
  96069. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96070. /**
  96071. * Detach a post process to the camera.
  96072. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96073. * @param postProcess The post process to detach from the camera
  96074. */
  96075. detachPostProcess(postProcess: PostProcess): void;
  96076. /**
  96077. * Gets the current world matrix of the camera
  96078. */
  96079. getWorldMatrix(): Matrix;
  96080. /** @hidden */
  96081. _getViewMatrix(): Matrix;
  96082. /**
  96083. * Gets the current view matrix of the camera.
  96084. * @param force forces the camera to recompute the matrix without looking at the cached state
  96085. * @returns the view matrix
  96086. */
  96087. getViewMatrix(force?: boolean): Matrix;
  96088. /**
  96089. * Freeze the projection matrix.
  96090. * It will prevent the cache check of the camera projection compute and can speed up perf
  96091. * if no parameter of the camera are meant to change
  96092. * @param projection Defines manually a projection if necessary
  96093. */
  96094. freezeProjectionMatrix(projection?: Matrix): void;
  96095. /**
  96096. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96097. */
  96098. unfreezeProjectionMatrix(): void;
  96099. /**
  96100. * Gets the current projection matrix of the camera.
  96101. * @param force forces the camera to recompute the matrix without looking at the cached state
  96102. * @returns the projection matrix
  96103. */
  96104. getProjectionMatrix(force?: boolean): Matrix;
  96105. /**
  96106. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96107. * @returns a Matrix
  96108. */
  96109. getTransformationMatrix(): Matrix;
  96110. private _updateFrustumPlanes;
  96111. /**
  96112. * Checks if a cullable object (mesh...) is in the camera frustum
  96113. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96114. * @param target The object to check
  96115. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96116. * @returns true if the object is in frustum otherwise false
  96117. */
  96118. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96119. /**
  96120. * Checks if a cullable object (mesh...) is in the camera frustum
  96121. * Unlike isInFrustum this cheks the full bounding box
  96122. * @param target The object to check
  96123. * @returns true if the object is in frustum otherwise false
  96124. */
  96125. isCompletelyInFrustum(target: ICullable): boolean;
  96126. /**
  96127. * Gets a ray in the forward direction from the camera.
  96128. * @param length Defines the length of the ray to create
  96129. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96130. * @param origin Defines the start point of the ray which defaults to the camera position
  96131. * @returns the forward ray
  96132. */
  96133. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96134. /**
  96135. * Releases resources associated with this node.
  96136. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96137. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96138. */
  96139. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96140. /** @hidden */
  96141. _isLeftCamera: boolean;
  96142. /**
  96143. * Gets the left camera of a rig setup in case of Rigged Camera
  96144. */
  96145. get isLeftCamera(): boolean;
  96146. /** @hidden */
  96147. _isRightCamera: boolean;
  96148. /**
  96149. * Gets the right camera of a rig setup in case of Rigged Camera
  96150. */
  96151. get isRightCamera(): boolean;
  96152. /**
  96153. * Gets the left camera of a rig setup in case of Rigged Camera
  96154. */
  96155. get leftCamera(): Nullable<FreeCamera>;
  96156. /**
  96157. * Gets the right camera of a rig setup in case of Rigged Camera
  96158. */
  96159. get rightCamera(): Nullable<FreeCamera>;
  96160. /**
  96161. * Gets the left camera target of a rig setup in case of Rigged Camera
  96162. * @returns the target position
  96163. */
  96164. getLeftTarget(): Nullable<Vector3>;
  96165. /**
  96166. * Gets the right camera target of a rig setup in case of Rigged Camera
  96167. * @returns the target position
  96168. */
  96169. getRightTarget(): Nullable<Vector3>;
  96170. /**
  96171. * @hidden
  96172. */
  96173. setCameraRigMode(mode: number, rigParams: any): void;
  96174. /** @hidden */
  96175. static _setStereoscopicRigMode(camera: Camera): void;
  96176. /** @hidden */
  96177. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96178. /** @hidden */
  96179. static _setVRRigMode(camera: Camera, rigParams: any): void;
  96180. /** @hidden */
  96181. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  96182. /** @hidden */
  96183. _getVRProjectionMatrix(): Matrix;
  96184. protected _updateCameraRotationMatrix(): void;
  96185. protected _updateWebVRCameraRotationMatrix(): void;
  96186. /**
  96187. * This function MUST be overwritten by the different WebVR cameras available.
  96188. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96189. * @hidden
  96190. */
  96191. _getWebVRProjectionMatrix(): Matrix;
  96192. /**
  96193. * This function MUST be overwritten by the different WebVR cameras available.
  96194. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96195. * @hidden
  96196. */
  96197. _getWebVRViewMatrix(): Matrix;
  96198. /** @hidden */
  96199. setCameraRigParameter(name: string, value: any): void;
  96200. /**
  96201. * needs to be overridden by children so sub has required properties to be copied
  96202. * @hidden
  96203. */
  96204. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96205. /**
  96206. * May need to be overridden by children
  96207. * @hidden
  96208. */
  96209. _updateRigCameras(): void;
  96210. /** @hidden */
  96211. _setupInputs(): void;
  96212. /**
  96213. * Serialiaze the camera setup to a json represention
  96214. * @returns the JSON representation
  96215. */
  96216. serialize(): any;
  96217. /**
  96218. * Clones the current camera.
  96219. * @param name The cloned camera name
  96220. * @returns the cloned camera
  96221. */
  96222. clone(name: string): Camera;
  96223. /**
  96224. * Gets the direction of the camera relative to a given local axis.
  96225. * @param localAxis Defines the reference axis to provide a relative direction.
  96226. * @return the direction
  96227. */
  96228. getDirection(localAxis: Vector3): Vector3;
  96229. /**
  96230. * Returns the current camera absolute rotation
  96231. */
  96232. get absoluteRotation(): Quaternion;
  96233. /**
  96234. * Gets the direction of the camera relative to a given local axis into a passed vector.
  96235. * @param localAxis Defines the reference axis to provide a relative direction.
  96236. * @param result Defines the vector to store the result in
  96237. */
  96238. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  96239. /**
  96240. * Gets a camera constructor for a given camera type
  96241. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  96242. * @param name The name of the camera the result will be able to instantiate
  96243. * @param scene The scene the result will construct the camera in
  96244. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  96245. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  96246. * @returns a factory method to construc the camera
  96247. */
  96248. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  96249. /**
  96250. * Compute the world matrix of the camera.
  96251. * @returns the camera world matrix
  96252. */
  96253. computeWorldMatrix(): Matrix;
  96254. /**
  96255. * Parse a JSON and creates the camera from the parsed information
  96256. * @param parsedCamera The JSON to parse
  96257. * @param scene The scene to instantiate the camera in
  96258. * @returns the newly constructed camera
  96259. */
  96260. static Parse(parsedCamera: any, scene: Scene): Camera;
  96261. }
  96262. }
  96263. declare module BABYLON {
  96264. /**
  96265. * Class containing static functions to help procedurally build meshes
  96266. */
  96267. export class DiscBuilder {
  96268. /**
  96269. * Creates a plane polygonal mesh. By default, this is a disc
  96270. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  96271. * * 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
  96272. * * 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
  96273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96276. * @param name defines the name of the mesh
  96277. * @param options defines the options used to create the mesh
  96278. * @param scene defines the hosting scene
  96279. * @returns the plane polygonal mesh
  96280. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  96281. */
  96282. static CreateDisc(name: string, options: {
  96283. radius?: number;
  96284. tessellation?: number;
  96285. arc?: number;
  96286. updatable?: boolean;
  96287. sideOrientation?: number;
  96288. frontUVs?: Vector4;
  96289. backUVs?: Vector4;
  96290. }, scene?: Nullable<Scene>): Mesh;
  96291. }
  96292. }
  96293. declare module BABYLON {
  96294. /**
  96295. * This represents all the required information to add a fresnel effect on a material:
  96296. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96297. */
  96298. export class FresnelParameters {
  96299. private _isEnabled;
  96300. /**
  96301. * Define if the fresnel effect is enable or not.
  96302. */
  96303. get isEnabled(): boolean;
  96304. set isEnabled(value: boolean);
  96305. /**
  96306. * Define the color used on edges (grazing angle)
  96307. */
  96308. leftColor: Color3;
  96309. /**
  96310. * Define the color used on center
  96311. */
  96312. rightColor: Color3;
  96313. /**
  96314. * Define bias applied to computed fresnel term
  96315. */
  96316. bias: number;
  96317. /**
  96318. * Defined the power exponent applied to fresnel term
  96319. */
  96320. power: number;
  96321. /**
  96322. * Clones the current fresnel and its valuues
  96323. * @returns a clone fresnel configuration
  96324. */
  96325. clone(): FresnelParameters;
  96326. /**
  96327. * Serializes the current fresnel parameters to a JSON representation.
  96328. * @return the JSON serialization
  96329. */
  96330. serialize(): any;
  96331. /**
  96332. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96333. * @param parsedFresnelParameters Define the JSON representation
  96334. * @returns the parsed parameters
  96335. */
  96336. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96337. }
  96338. }
  96339. declare module BABYLON {
  96340. /**
  96341. * Base class of materials working in push mode in babylon JS
  96342. * @hidden
  96343. */
  96344. export class PushMaterial extends Material {
  96345. protected _activeEffect: Effect;
  96346. protected _normalMatrix: Matrix;
  96347. /**
  96348. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96349. * This means that the material can keep using a previous shader while a new one is being compiled.
  96350. * This is mostly used when shader parallel compilation is supported (true by default)
  96351. */
  96352. allowShaderHotSwapping: boolean;
  96353. constructor(name: string, scene: Scene);
  96354. getEffect(): Effect;
  96355. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96356. /**
  96357. * Binds the given world matrix to the active effect
  96358. *
  96359. * @param world the matrix to bind
  96360. */
  96361. bindOnlyWorldMatrix(world: Matrix): void;
  96362. /**
  96363. * Binds the given normal matrix to the active effect
  96364. *
  96365. * @param normalMatrix the matrix to bind
  96366. */
  96367. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96368. bind(world: Matrix, mesh?: Mesh): void;
  96369. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96370. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96371. }
  96372. }
  96373. declare module BABYLON {
  96374. /**
  96375. * This groups all the flags used to control the materials channel.
  96376. */
  96377. export class MaterialFlags {
  96378. private static _DiffuseTextureEnabled;
  96379. /**
  96380. * Are diffuse textures enabled in the application.
  96381. */
  96382. static get DiffuseTextureEnabled(): boolean;
  96383. static set DiffuseTextureEnabled(value: boolean);
  96384. private static _AmbientTextureEnabled;
  96385. /**
  96386. * Are ambient textures enabled in the application.
  96387. */
  96388. static get AmbientTextureEnabled(): boolean;
  96389. static set AmbientTextureEnabled(value: boolean);
  96390. private static _OpacityTextureEnabled;
  96391. /**
  96392. * Are opacity textures enabled in the application.
  96393. */
  96394. static get OpacityTextureEnabled(): boolean;
  96395. static set OpacityTextureEnabled(value: boolean);
  96396. private static _ReflectionTextureEnabled;
  96397. /**
  96398. * Are reflection textures enabled in the application.
  96399. */
  96400. static get ReflectionTextureEnabled(): boolean;
  96401. static set ReflectionTextureEnabled(value: boolean);
  96402. private static _EmissiveTextureEnabled;
  96403. /**
  96404. * Are emissive textures enabled in the application.
  96405. */
  96406. static get EmissiveTextureEnabled(): boolean;
  96407. static set EmissiveTextureEnabled(value: boolean);
  96408. private static _SpecularTextureEnabled;
  96409. /**
  96410. * Are specular textures enabled in the application.
  96411. */
  96412. static get SpecularTextureEnabled(): boolean;
  96413. static set SpecularTextureEnabled(value: boolean);
  96414. private static _BumpTextureEnabled;
  96415. /**
  96416. * Are bump textures enabled in the application.
  96417. */
  96418. static get BumpTextureEnabled(): boolean;
  96419. static set BumpTextureEnabled(value: boolean);
  96420. private static _LightmapTextureEnabled;
  96421. /**
  96422. * Are lightmap textures enabled in the application.
  96423. */
  96424. static get LightmapTextureEnabled(): boolean;
  96425. static set LightmapTextureEnabled(value: boolean);
  96426. private static _RefractionTextureEnabled;
  96427. /**
  96428. * Are refraction textures enabled in the application.
  96429. */
  96430. static get RefractionTextureEnabled(): boolean;
  96431. static set RefractionTextureEnabled(value: boolean);
  96432. private static _ColorGradingTextureEnabled;
  96433. /**
  96434. * Are color grading textures enabled in the application.
  96435. */
  96436. static get ColorGradingTextureEnabled(): boolean;
  96437. static set ColorGradingTextureEnabled(value: boolean);
  96438. private static _FresnelEnabled;
  96439. /**
  96440. * Are fresnels enabled in the application.
  96441. */
  96442. static get FresnelEnabled(): boolean;
  96443. static set FresnelEnabled(value: boolean);
  96444. private static _ClearCoatTextureEnabled;
  96445. /**
  96446. * Are clear coat textures enabled in the application.
  96447. */
  96448. static get ClearCoatTextureEnabled(): boolean;
  96449. static set ClearCoatTextureEnabled(value: boolean);
  96450. private static _ClearCoatBumpTextureEnabled;
  96451. /**
  96452. * Are clear coat bump textures enabled in the application.
  96453. */
  96454. static get ClearCoatBumpTextureEnabled(): boolean;
  96455. static set ClearCoatBumpTextureEnabled(value: boolean);
  96456. private static _ClearCoatTintTextureEnabled;
  96457. /**
  96458. * Are clear coat tint textures enabled in the application.
  96459. */
  96460. static get ClearCoatTintTextureEnabled(): boolean;
  96461. static set ClearCoatTintTextureEnabled(value: boolean);
  96462. private static _SheenTextureEnabled;
  96463. /**
  96464. * Are sheen textures enabled in the application.
  96465. */
  96466. static get SheenTextureEnabled(): boolean;
  96467. static set SheenTextureEnabled(value: boolean);
  96468. private static _AnisotropicTextureEnabled;
  96469. /**
  96470. * Are anisotropic textures enabled in the application.
  96471. */
  96472. static get AnisotropicTextureEnabled(): boolean;
  96473. static set AnisotropicTextureEnabled(value: boolean);
  96474. private static _ThicknessTextureEnabled;
  96475. /**
  96476. * Are thickness textures enabled in the application.
  96477. */
  96478. static get ThicknessTextureEnabled(): boolean;
  96479. static set ThicknessTextureEnabled(value: boolean);
  96480. }
  96481. }
  96482. declare module BABYLON {
  96483. /** @hidden */
  96484. export var defaultFragmentDeclaration: {
  96485. name: string;
  96486. shader: string;
  96487. };
  96488. }
  96489. declare module BABYLON {
  96490. /** @hidden */
  96491. export var defaultUboDeclaration: {
  96492. name: string;
  96493. shader: string;
  96494. };
  96495. }
  96496. declare module BABYLON {
  96497. /** @hidden */
  96498. export var lightFragmentDeclaration: {
  96499. name: string;
  96500. shader: string;
  96501. };
  96502. }
  96503. declare module BABYLON {
  96504. /** @hidden */
  96505. export var lightUboDeclaration: {
  96506. name: string;
  96507. shader: string;
  96508. };
  96509. }
  96510. declare module BABYLON {
  96511. /** @hidden */
  96512. export var lightsFragmentFunctions: {
  96513. name: string;
  96514. shader: string;
  96515. };
  96516. }
  96517. declare module BABYLON {
  96518. /** @hidden */
  96519. export var shadowsFragmentFunctions: {
  96520. name: string;
  96521. shader: string;
  96522. };
  96523. }
  96524. declare module BABYLON {
  96525. /** @hidden */
  96526. export var fresnelFunction: {
  96527. name: string;
  96528. shader: string;
  96529. };
  96530. }
  96531. declare module BABYLON {
  96532. /** @hidden */
  96533. export var reflectionFunction: {
  96534. name: string;
  96535. shader: string;
  96536. };
  96537. }
  96538. declare module BABYLON {
  96539. /** @hidden */
  96540. export var bumpFragmentFunctions: {
  96541. name: string;
  96542. shader: string;
  96543. };
  96544. }
  96545. declare module BABYLON {
  96546. /** @hidden */
  96547. export var logDepthDeclaration: {
  96548. name: string;
  96549. shader: string;
  96550. };
  96551. }
  96552. declare module BABYLON {
  96553. /** @hidden */
  96554. export var bumpFragment: {
  96555. name: string;
  96556. shader: string;
  96557. };
  96558. }
  96559. declare module BABYLON {
  96560. /** @hidden */
  96561. export var depthPrePass: {
  96562. name: string;
  96563. shader: string;
  96564. };
  96565. }
  96566. declare module BABYLON {
  96567. /** @hidden */
  96568. export var lightFragment: {
  96569. name: string;
  96570. shader: string;
  96571. };
  96572. }
  96573. declare module BABYLON {
  96574. /** @hidden */
  96575. export var logDepthFragment: {
  96576. name: string;
  96577. shader: string;
  96578. };
  96579. }
  96580. declare module BABYLON {
  96581. /** @hidden */
  96582. export var defaultPixelShader: {
  96583. name: string;
  96584. shader: string;
  96585. };
  96586. }
  96587. declare module BABYLON {
  96588. /** @hidden */
  96589. export var defaultVertexDeclaration: {
  96590. name: string;
  96591. shader: string;
  96592. };
  96593. }
  96594. declare module BABYLON {
  96595. /** @hidden */
  96596. export var bumpVertexDeclaration: {
  96597. name: string;
  96598. shader: string;
  96599. };
  96600. }
  96601. declare module BABYLON {
  96602. /** @hidden */
  96603. export var bumpVertex: {
  96604. name: string;
  96605. shader: string;
  96606. };
  96607. }
  96608. declare module BABYLON {
  96609. /** @hidden */
  96610. export var fogVertex: {
  96611. name: string;
  96612. shader: string;
  96613. };
  96614. }
  96615. declare module BABYLON {
  96616. /** @hidden */
  96617. export var shadowsVertex: {
  96618. name: string;
  96619. shader: string;
  96620. };
  96621. }
  96622. declare module BABYLON {
  96623. /** @hidden */
  96624. export var pointCloudVertex: {
  96625. name: string;
  96626. shader: string;
  96627. };
  96628. }
  96629. declare module BABYLON {
  96630. /** @hidden */
  96631. export var logDepthVertex: {
  96632. name: string;
  96633. shader: string;
  96634. };
  96635. }
  96636. declare module BABYLON {
  96637. /** @hidden */
  96638. export var defaultVertexShader: {
  96639. name: string;
  96640. shader: string;
  96641. };
  96642. }
  96643. declare module BABYLON {
  96644. /** @hidden */
  96645. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96646. MAINUV1: boolean;
  96647. MAINUV2: boolean;
  96648. DIFFUSE: boolean;
  96649. DIFFUSEDIRECTUV: number;
  96650. AMBIENT: boolean;
  96651. AMBIENTDIRECTUV: number;
  96652. OPACITY: boolean;
  96653. OPACITYDIRECTUV: number;
  96654. OPACITYRGB: boolean;
  96655. REFLECTION: boolean;
  96656. EMISSIVE: boolean;
  96657. EMISSIVEDIRECTUV: number;
  96658. SPECULAR: boolean;
  96659. SPECULARDIRECTUV: number;
  96660. BUMP: boolean;
  96661. BUMPDIRECTUV: number;
  96662. PARALLAX: boolean;
  96663. PARALLAXOCCLUSION: boolean;
  96664. SPECULAROVERALPHA: boolean;
  96665. CLIPPLANE: boolean;
  96666. CLIPPLANE2: boolean;
  96667. CLIPPLANE3: boolean;
  96668. CLIPPLANE4: boolean;
  96669. CLIPPLANE5: boolean;
  96670. CLIPPLANE6: boolean;
  96671. ALPHATEST: boolean;
  96672. DEPTHPREPASS: boolean;
  96673. ALPHAFROMDIFFUSE: boolean;
  96674. POINTSIZE: boolean;
  96675. FOG: boolean;
  96676. SPECULARTERM: boolean;
  96677. DIFFUSEFRESNEL: boolean;
  96678. OPACITYFRESNEL: boolean;
  96679. REFLECTIONFRESNEL: boolean;
  96680. REFRACTIONFRESNEL: boolean;
  96681. EMISSIVEFRESNEL: boolean;
  96682. FRESNEL: boolean;
  96683. NORMAL: boolean;
  96684. UV1: boolean;
  96685. UV2: boolean;
  96686. VERTEXCOLOR: boolean;
  96687. VERTEXALPHA: boolean;
  96688. NUM_BONE_INFLUENCERS: number;
  96689. BonesPerMesh: number;
  96690. BONETEXTURE: boolean;
  96691. INSTANCES: boolean;
  96692. GLOSSINESS: boolean;
  96693. ROUGHNESS: boolean;
  96694. EMISSIVEASILLUMINATION: boolean;
  96695. LINKEMISSIVEWITHDIFFUSE: boolean;
  96696. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96697. LIGHTMAP: boolean;
  96698. LIGHTMAPDIRECTUV: number;
  96699. OBJECTSPACE_NORMALMAP: boolean;
  96700. USELIGHTMAPASSHADOWMAP: boolean;
  96701. REFLECTIONMAP_3D: boolean;
  96702. REFLECTIONMAP_SPHERICAL: boolean;
  96703. REFLECTIONMAP_PLANAR: boolean;
  96704. REFLECTIONMAP_CUBIC: boolean;
  96705. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96706. REFLECTIONMAP_PROJECTION: boolean;
  96707. REFLECTIONMAP_SKYBOX: boolean;
  96708. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96709. REFLECTIONMAP_EXPLICIT: boolean;
  96710. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96711. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96712. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96713. INVERTCUBICMAP: boolean;
  96714. LOGARITHMICDEPTH: boolean;
  96715. REFRACTION: boolean;
  96716. REFRACTIONMAP_3D: boolean;
  96717. REFLECTIONOVERALPHA: boolean;
  96718. TWOSIDEDLIGHTING: boolean;
  96719. SHADOWFLOAT: boolean;
  96720. MORPHTARGETS: boolean;
  96721. MORPHTARGETS_NORMAL: boolean;
  96722. MORPHTARGETS_TANGENT: boolean;
  96723. MORPHTARGETS_UV: boolean;
  96724. NUM_MORPH_INFLUENCERS: number;
  96725. NONUNIFORMSCALING: boolean;
  96726. PREMULTIPLYALPHA: boolean;
  96727. IMAGEPROCESSING: boolean;
  96728. VIGNETTE: boolean;
  96729. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96730. VIGNETTEBLENDMODEOPAQUE: boolean;
  96731. TONEMAPPING: boolean;
  96732. TONEMAPPING_ACES: boolean;
  96733. CONTRAST: boolean;
  96734. COLORCURVES: boolean;
  96735. COLORGRADING: boolean;
  96736. COLORGRADING3D: boolean;
  96737. SAMPLER3DGREENDEPTH: boolean;
  96738. SAMPLER3DBGRMAP: boolean;
  96739. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96740. MULTIVIEW: boolean;
  96741. /**
  96742. * If the reflection texture on this material is in linear color space
  96743. * @hidden
  96744. */
  96745. IS_REFLECTION_LINEAR: boolean;
  96746. /**
  96747. * If the refraction texture on this material is in linear color space
  96748. * @hidden
  96749. */
  96750. IS_REFRACTION_LINEAR: boolean;
  96751. EXPOSURE: boolean;
  96752. constructor();
  96753. setReflectionMode(modeToEnable: string): void;
  96754. }
  96755. /**
  96756. * This is the default material used in Babylon. It is the best trade off between quality
  96757. * and performances.
  96758. * @see http://doc.babylonjs.com/babylon101/materials
  96759. */
  96760. export class StandardMaterial extends PushMaterial {
  96761. private _diffuseTexture;
  96762. /**
  96763. * The basic texture of the material as viewed under a light.
  96764. */
  96765. diffuseTexture: Nullable<BaseTexture>;
  96766. private _ambientTexture;
  96767. /**
  96768. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96769. */
  96770. ambientTexture: Nullable<BaseTexture>;
  96771. private _opacityTexture;
  96772. /**
  96773. * Define the transparency of the material from a texture.
  96774. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96775. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96776. */
  96777. opacityTexture: Nullable<BaseTexture>;
  96778. private _reflectionTexture;
  96779. /**
  96780. * Define the texture used to display the reflection.
  96781. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96782. */
  96783. reflectionTexture: Nullable<BaseTexture>;
  96784. private _emissiveTexture;
  96785. /**
  96786. * Define texture of the material as if self lit.
  96787. * This will be mixed in the final result even in the absence of light.
  96788. */
  96789. emissiveTexture: Nullable<BaseTexture>;
  96790. private _specularTexture;
  96791. /**
  96792. * Define how the color and intensity of the highlight given by the light in the material.
  96793. */
  96794. specularTexture: Nullable<BaseTexture>;
  96795. private _bumpTexture;
  96796. /**
  96797. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96798. * 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.
  96799. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96800. */
  96801. bumpTexture: Nullable<BaseTexture>;
  96802. private _lightmapTexture;
  96803. /**
  96804. * Complex lighting can be computationally expensive to compute at runtime.
  96805. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96806. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96807. */
  96808. lightmapTexture: Nullable<BaseTexture>;
  96809. private _refractionTexture;
  96810. /**
  96811. * Define the texture used to display the refraction.
  96812. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96813. */
  96814. refractionTexture: Nullable<BaseTexture>;
  96815. /**
  96816. * The color of the material lit by the environmental background lighting.
  96817. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96818. */
  96819. ambientColor: Color3;
  96820. /**
  96821. * The basic color of the material as viewed under a light.
  96822. */
  96823. diffuseColor: Color3;
  96824. /**
  96825. * Define how the color and intensity of the highlight given by the light in the material.
  96826. */
  96827. specularColor: Color3;
  96828. /**
  96829. * Define the color of the material as if self lit.
  96830. * This will be mixed in the final result even in the absence of light.
  96831. */
  96832. emissiveColor: Color3;
  96833. /**
  96834. * Defines how sharp are the highlights in the material.
  96835. * The bigger the value the sharper giving a more glossy feeling to the result.
  96836. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96837. */
  96838. specularPower: number;
  96839. private _useAlphaFromDiffuseTexture;
  96840. /**
  96841. * Does the transparency come from the diffuse texture alpha channel.
  96842. */
  96843. useAlphaFromDiffuseTexture: boolean;
  96844. private _useEmissiveAsIllumination;
  96845. /**
  96846. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96847. */
  96848. useEmissiveAsIllumination: boolean;
  96849. private _linkEmissiveWithDiffuse;
  96850. /**
  96851. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96852. * the emissive level when the final color is close to one.
  96853. */
  96854. linkEmissiveWithDiffuse: boolean;
  96855. private _useSpecularOverAlpha;
  96856. /**
  96857. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96858. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96859. */
  96860. useSpecularOverAlpha: boolean;
  96861. private _useReflectionOverAlpha;
  96862. /**
  96863. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96864. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96865. */
  96866. useReflectionOverAlpha: boolean;
  96867. private _disableLighting;
  96868. /**
  96869. * Does lights from the scene impacts this material.
  96870. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96871. */
  96872. disableLighting: boolean;
  96873. private _useObjectSpaceNormalMap;
  96874. /**
  96875. * Allows using an object space normal map (instead of tangent space).
  96876. */
  96877. useObjectSpaceNormalMap: boolean;
  96878. private _useParallax;
  96879. /**
  96880. * Is parallax enabled or not.
  96881. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96882. */
  96883. useParallax: boolean;
  96884. private _useParallaxOcclusion;
  96885. /**
  96886. * Is parallax occlusion enabled or not.
  96887. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96888. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96889. */
  96890. useParallaxOcclusion: boolean;
  96891. /**
  96892. * 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.
  96893. */
  96894. parallaxScaleBias: number;
  96895. private _roughness;
  96896. /**
  96897. * Helps to define how blurry the reflections should appears in the material.
  96898. */
  96899. roughness: number;
  96900. /**
  96901. * In case of refraction, define the value of the index of refraction.
  96902. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96903. */
  96904. indexOfRefraction: number;
  96905. /**
  96906. * Invert the refraction texture alongside the y axis.
  96907. * It can be useful with procedural textures or probe for instance.
  96908. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96909. */
  96910. invertRefractionY: boolean;
  96911. /**
  96912. * Defines the alpha limits in alpha test mode.
  96913. */
  96914. alphaCutOff: number;
  96915. private _useLightmapAsShadowmap;
  96916. /**
  96917. * In case of light mapping, define whether the map contains light or shadow informations.
  96918. */
  96919. useLightmapAsShadowmap: boolean;
  96920. private _diffuseFresnelParameters;
  96921. /**
  96922. * Define the diffuse fresnel parameters of the material.
  96923. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96924. */
  96925. diffuseFresnelParameters: FresnelParameters;
  96926. private _opacityFresnelParameters;
  96927. /**
  96928. * Define the opacity fresnel parameters of the material.
  96929. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96930. */
  96931. opacityFresnelParameters: FresnelParameters;
  96932. private _reflectionFresnelParameters;
  96933. /**
  96934. * Define the reflection fresnel parameters of the material.
  96935. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96936. */
  96937. reflectionFresnelParameters: FresnelParameters;
  96938. private _refractionFresnelParameters;
  96939. /**
  96940. * Define the refraction fresnel parameters of the material.
  96941. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96942. */
  96943. refractionFresnelParameters: FresnelParameters;
  96944. private _emissiveFresnelParameters;
  96945. /**
  96946. * Define the emissive fresnel parameters of the material.
  96947. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96948. */
  96949. emissiveFresnelParameters: FresnelParameters;
  96950. private _useReflectionFresnelFromSpecular;
  96951. /**
  96952. * If true automatically deducts the fresnels values from the material specularity.
  96953. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96954. */
  96955. useReflectionFresnelFromSpecular: boolean;
  96956. private _useGlossinessFromSpecularMapAlpha;
  96957. /**
  96958. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96959. */
  96960. useGlossinessFromSpecularMapAlpha: boolean;
  96961. private _maxSimultaneousLights;
  96962. /**
  96963. * Defines the maximum number of lights that can be used in the material
  96964. */
  96965. maxSimultaneousLights: number;
  96966. private _invertNormalMapX;
  96967. /**
  96968. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96969. */
  96970. invertNormalMapX: boolean;
  96971. private _invertNormalMapY;
  96972. /**
  96973. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96974. */
  96975. invertNormalMapY: boolean;
  96976. private _twoSidedLighting;
  96977. /**
  96978. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96979. */
  96980. twoSidedLighting: boolean;
  96981. /**
  96982. * Default configuration related to image processing available in the standard Material.
  96983. */
  96984. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96985. /**
  96986. * Gets the image processing configuration used either in this material.
  96987. */
  96988. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  96989. /**
  96990. * Sets the Default image processing configuration used either in the this material.
  96991. *
  96992. * If sets to null, the scene one is in use.
  96993. */
  96994. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  96995. /**
  96996. * Keep track of the image processing observer to allow dispose and replace.
  96997. */
  96998. private _imageProcessingObserver;
  96999. /**
  97000. * Attaches a new image processing configuration to the Standard Material.
  97001. * @param configuration
  97002. */
  97003. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97004. /**
  97005. * Gets wether the color curves effect is enabled.
  97006. */
  97007. get cameraColorCurvesEnabled(): boolean;
  97008. /**
  97009. * Sets wether the color curves effect is enabled.
  97010. */
  97011. set cameraColorCurvesEnabled(value: boolean);
  97012. /**
  97013. * Gets wether the color grading effect is enabled.
  97014. */
  97015. get cameraColorGradingEnabled(): boolean;
  97016. /**
  97017. * Gets wether the color grading effect is enabled.
  97018. */
  97019. set cameraColorGradingEnabled(value: boolean);
  97020. /**
  97021. * Gets wether tonemapping is enabled or not.
  97022. */
  97023. get cameraToneMappingEnabled(): boolean;
  97024. /**
  97025. * Sets wether tonemapping is enabled or not
  97026. */
  97027. set cameraToneMappingEnabled(value: boolean);
  97028. /**
  97029. * The camera exposure used on this material.
  97030. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97031. * This corresponds to a photographic exposure.
  97032. */
  97033. get cameraExposure(): number;
  97034. /**
  97035. * The camera exposure used on this material.
  97036. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97037. * This corresponds to a photographic exposure.
  97038. */
  97039. set cameraExposure(value: number);
  97040. /**
  97041. * Gets The camera contrast used on this material.
  97042. */
  97043. get cameraContrast(): number;
  97044. /**
  97045. * Sets The camera contrast used on this material.
  97046. */
  97047. set cameraContrast(value: number);
  97048. /**
  97049. * Gets the Color Grading 2D Lookup Texture.
  97050. */
  97051. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97052. /**
  97053. * Sets the Color Grading 2D Lookup Texture.
  97054. */
  97055. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97056. /**
  97057. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97058. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97059. * 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;
  97060. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97061. */
  97062. get cameraColorCurves(): Nullable<ColorCurves>;
  97063. /**
  97064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97066. * 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;
  97067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97068. */
  97069. set cameraColorCurves(value: Nullable<ColorCurves>);
  97070. /**
  97071. * Custom callback helping to override the default shader used in the material.
  97072. */
  97073. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97074. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97075. protected _worldViewProjectionMatrix: Matrix;
  97076. protected _globalAmbientColor: Color3;
  97077. protected _useLogarithmicDepth: boolean;
  97078. protected _rebuildInParallel: boolean;
  97079. /**
  97080. * Instantiates a new standard material.
  97081. * This is the default material used in Babylon. It is the best trade off between quality
  97082. * and performances.
  97083. * @see http://doc.babylonjs.com/babylon101/materials
  97084. * @param name Define the name of the material in the scene
  97085. * @param scene Define the scene the material belong to
  97086. */
  97087. constructor(name: string, scene: Scene);
  97088. /**
  97089. * Gets a boolean indicating that current material needs to register RTT
  97090. */
  97091. get hasRenderTargetTextures(): boolean;
  97092. /**
  97093. * Gets the current class name of the material e.g. "StandardMaterial"
  97094. * Mainly use in serialization.
  97095. * @returns the class name
  97096. */
  97097. getClassName(): string;
  97098. /**
  97099. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97100. * You can try switching to logarithmic depth.
  97101. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97102. */
  97103. get useLogarithmicDepth(): boolean;
  97104. set useLogarithmicDepth(value: boolean);
  97105. /**
  97106. * Specifies if the material will require alpha blending
  97107. * @returns a boolean specifying if alpha blending is needed
  97108. */
  97109. needAlphaBlending(): boolean;
  97110. /**
  97111. * Specifies if this material should be rendered in alpha test mode
  97112. * @returns a boolean specifying if an alpha test is needed.
  97113. */
  97114. needAlphaTesting(): boolean;
  97115. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97116. /**
  97117. * Get the texture used for alpha test purpose.
  97118. * @returns the diffuse texture in case of the standard material.
  97119. */
  97120. getAlphaTestTexture(): Nullable<BaseTexture>;
  97121. /**
  97122. * Get if the submesh is ready to be used and all its information available.
  97123. * Child classes can use it to update shaders
  97124. * @param mesh defines the mesh to check
  97125. * @param subMesh defines which submesh to check
  97126. * @param useInstances specifies that instances should be used
  97127. * @returns a boolean indicating that the submesh is ready or not
  97128. */
  97129. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97130. /**
  97131. * Builds the material UBO layouts.
  97132. * Used internally during the effect preparation.
  97133. */
  97134. buildUniformLayout(): void;
  97135. /**
  97136. * Unbinds the material from the mesh
  97137. */
  97138. unbind(): void;
  97139. /**
  97140. * Binds the submesh to this material by preparing the effect and shader to draw
  97141. * @param world defines the world transformation matrix
  97142. * @param mesh defines the mesh containing the submesh
  97143. * @param subMesh defines the submesh to bind the material to
  97144. */
  97145. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97146. /**
  97147. * Get the list of animatables in the material.
  97148. * @returns the list of animatables object used in the material
  97149. */
  97150. getAnimatables(): IAnimatable[];
  97151. /**
  97152. * Gets the active textures from the material
  97153. * @returns an array of textures
  97154. */
  97155. getActiveTextures(): BaseTexture[];
  97156. /**
  97157. * Specifies if the material uses a texture
  97158. * @param texture defines the texture to check against the material
  97159. * @returns a boolean specifying if the material uses the texture
  97160. */
  97161. hasTexture(texture: BaseTexture): boolean;
  97162. /**
  97163. * Disposes the material
  97164. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97165. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97166. */
  97167. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97168. /**
  97169. * Makes a duplicate of the material, and gives it a new name
  97170. * @param name defines the new name for the duplicated material
  97171. * @returns the cloned material
  97172. */
  97173. clone(name: string): StandardMaterial;
  97174. /**
  97175. * Serializes this material in a JSON representation
  97176. * @returns the serialized material object
  97177. */
  97178. serialize(): any;
  97179. /**
  97180. * Creates a standard material from parsed material data
  97181. * @param source defines the JSON representation of the material
  97182. * @param scene defines the hosting scene
  97183. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97184. * @returns a new standard material
  97185. */
  97186. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97187. /**
  97188. * Are diffuse textures enabled in the application.
  97189. */
  97190. static get DiffuseTextureEnabled(): boolean;
  97191. static set DiffuseTextureEnabled(value: boolean);
  97192. /**
  97193. * Are ambient textures enabled in the application.
  97194. */
  97195. static get AmbientTextureEnabled(): boolean;
  97196. static set AmbientTextureEnabled(value: boolean);
  97197. /**
  97198. * Are opacity textures enabled in the application.
  97199. */
  97200. static get OpacityTextureEnabled(): boolean;
  97201. static set OpacityTextureEnabled(value: boolean);
  97202. /**
  97203. * Are reflection textures enabled in the application.
  97204. */
  97205. static get ReflectionTextureEnabled(): boolean;
  97206. static set ReflectionTextureEnabled(value: boolean);
  97207. /**
  97208. * Are emissive textures enabled in the application.
  97209. */
  97210. static get EmissiveTextureEnabled(): boolean;
  97211. static set EmissiveTextureEnabled(value: boolean);
  97212. /**
  97213. * Are specular textures enabled in the application.
  97214. */
  97215. static get SpecularTextureEnabled(): boolean;
  97216. static set SpecularTextureEnabled(value: boolean);
  97217. /**
  97218. * Are bump textures enabled in the application.
  97219. */
  97220. static get BumpTextureEnabled(): boolean;
  97221. static set BumpTextureEnabled(value: boolean);
  97222. /**
  97223. * Are lightmap textures enabled in the application.
  97224. */
  97225. static get LightmapTextureEnabled(): boolean;
  97226. static set LightmapTextureEnabled(value: boolean);
  97227. /**
  97228. * Are refraction textures enabled in the application.
  97229. */
  97230. static get RefractionTextureEnabled(): boolean;
  97231. static set RefractionTextureEnabled(value: boolean);
  97232. /**
  97233. * Are color grading textures enabled in the application.
  97234. */
  97235. static get ColorGradingTextureEnabled(): boolean;
  97236. static set ColorGradingTextureEnabled(value: boolean);
  97237. /**
  97238. * Are fresnels enabled in the application.
  97239. */
  97240. static get FresnelEnabled(): boolean;
  97241. static set FresnelEnabled(value: boolean);
  97242. }
  97243. }
  97244. declare module BABYLON {
  97245. /**
  97246. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  97247. *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.
  97248. * The SPS is also a particle system. It provides some methods to manage the particles.
  97249. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  97250. *
  97251. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  97252. */
  97253. export class SolidParticleSystem implements IDisposable {
  97254. /**
  97255. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  97256. * Example : var p = SPS.particles[i];
  97257. */
  97258. particles: SolidParticle[];
  97259. /**
  97260. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  97261. */
  97262. nbParticles: number;
  97263. /**
  97264. * If the particles must ever face the camera (default false). Useful for planar particles.
  97265. */
  97266. billboard: boolean;
  97267. /**
  97268. * Recompute normals when adding a shape
  97269. */
  97270. recomputeNormals: boolean;
  97271. /**
  97272. * This a counter ofr your own usage. It's not set by any SPS functions.
  97273. */
  97274. counter: number;
  97275. /**
  97276. * The SPS name. This name is also given to the underlying mesh.
  97277. */
  97278. name: string;
  97279. /**
  97280. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  97281. */
  97282. mesh: Mesh;
  97283. /**
  97284. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  97285. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  97286. */
  97287. vars: any;
  97288. /**
  97289. * This array is populated when the SPS is set as 'pickable'.
  97290. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  97291. * Each element of this array is an object `{idx: int, faceId: int}`.
  97292. * `idx` is the picked particle index in the `SPS.particles` array
  97293. * `faceId` is the picked face index counted within this particle.
  97294. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  97295. */
  97296. pickedParticles: {
  97297. idx: number;
  97298. faceId: number;
  97299. }[];
  97300. /**
  97301. * This array is populated when `enableDepthSort` is set to true.
  97302. * Each element of this array is an instance of the class DepthSortedParticle.
  97303. */
  97304. depthSortedParticles: DepthSortedParticle[];
  97305. /**
  97306. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  97307. * @hidden
  97308. */
  97309. _bSphereOnly: boolean;
  97310. /**
  97311. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  97312. * @hidden
  97313. */
  97314. _bSphereRadiusFactor: number;
  97315. private _scene;
  97316. private _positions;
  97317. private _indices;
  97318. private _normals;
  97319. private _colors;
  97320. private _uvs;
  97321. private _indices32;
  97322. private _positions32;
  97323. private _normals32;
  97324. private _fixedNormal32;
  97325. private _colors32;
  97326. private _uvs32;
  97327. private _index;
  97328. private _updatable;
  97329. private _pickable;
  97330. private _isVisibilityBoxLocked;
  97331. private _alwaysVisible;
  97332. private _depthSort;
  97333. private _expandable;
  97334. private _shapeCounter;
  97335. private _copy;
  97336. private _color;
  97337. private _computeParticleColor;
  97338. private _computeParticleTexture;
  97339. private _computeParticleRotation;
  97340. private _computeParticleVertex;
  97341. private _computeBoundingBox;
  97342. private _depthSortParticles;
  97343. private _camera;
  97344. private _mustUnrotateFixedNormals;
  97345. private _particlesIntersect;
  97346. private _needs32Bits;
  97347. private _isNotBuilt;
  97348. private _lastParticleId;
  97349. private _idxOfId;
  97350. private _multimaterialEnabled;
  97351. private _useModelMaterial;
  97352. private _indicesByMaterial;
  97353. private _materialIndexes;
  97354. private _depthSortFunction;
  97355. private _materialSortFunction;
  97356. private _materials;
  97357. private _multimaterial;
  97358. private _materialIndexesById;
  97359. private _defaultMaterial;
  97360. private _autoUpdateSubMeshes;
  97361. /**
  97362. * Creates a SPS (Solid Particle System) object.
  97363. * @param name (String) is the SPS name, this will be the underlying mesh name.
  97364. * @param scene (Scene) is the scene in which the SPS is added.
  97365. * @param options defines the options of the sps e.g.
  97366. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  97367. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  97368. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  97369. * * 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.
  97370. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  97371. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  97372. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  97373. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  97374. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  97375. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  97376. */
  97377. constructor(name: string, scene: Scene, options?: {
  97378. updatable?: boolean;
  97379. isPickable?: boolean;
  97380. enableDepthSort?: boolean;
  97381. particleIntersection?: boolean;
  97382. boundingSphereOnly?: boolean;
  97383. bSphereRadiusFactor?: number;
  97384. expandable?: boolean;
  97385. useModelMaterial?: boolean;
  97386. enableMultiMaterial?: boolean;
  97387. });
  97388. /**
  97389. * Builds the SPS underlying mesh. Returns a standard Mesh.
  97390. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  97391. * @returns the created mesh
  97392. */
  97393. buildMesh(): Mesh;
  97394. /**
  97395. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  97396. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  97397. * Thus the particles generated from `digest()` have their property `position` set yet.
  97398. * @param mesh ( Mesh ) is the mesh to be digested
  97399. * @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
  97400. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  97401. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  97402. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97403. * @returns the current SPS
  97404. */
  97405. digest(mesh: Mesh, options?: {
  97406. facetNb?: number;
  97407. number?: number;
  97408. delta?: number;
  97409. storage?: [];
  97410. }): SolidParticleSystem;
  97411. /**
  97412. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  97413. * @hidden
  97414. */
  97415. private _unrotateFixedNormals;
  97416. /**
  97417. * Resets the temporary working copy particle
  97418. * @hidden
  97419. */
  97420. private _resetCopy;
  97421. /**
  97422. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  97423. * @param p the current index in the positions array to be updated
  97424. * @param ind the current index in the indices array
  97425. * @param shape a Vector3 array, the shape geometry
  97426. * @param positions the positions array to be updated
  97427. * @param meshInd the shape indices array
  97428. * @param indices the indices array to be updated
  97429. * @param meshUV the shape uv array
  97430. * @param uvs the uv array to be updated
  97431. * @param meshCol the shape color array
  97432. * @param colors the color array to be updated
  97433. * @param meshNor the shape normals array
  97434. * @param normals the normals array to be updated
  97435. * @param idx the particle index
  97436. * @param idxInShape the particle index in its shape
  97437. * @param options the addShape() method passed options
  97438. * @model the particle model
  97439. * @hidden
  97440. */
  97441. private _meshBuilder;
  97442. /**
  97443. * Returns a shape Vector3 array from positions float array
  97444. * @param positions float array
  97445. * @returns a vector3 array
  97446. * @hidden
  97447. */
  97448. private _posToShape;
  97449. /**
  97450. * Returns a shapeUV array from a float uvs (array deep copy)
  97451. * @param uvs as a float array
  97452. * @returns a shapeUV array
  97453. * @hidden
  97454. */
  97455. private _uvsToShapeUV;
  97456. /**
  97457. * Adds a new particle object in the particles array
  97458. * @param idx particle index in particles array
  97459. * @param id particle id
  97460. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  97461. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  97462. * @param model particle ModelShape object
  97463. * @param shapeId model shape identifier
  97464. * @param idxInShape index of the particle in the current model
  97465. * @param bInfo model bounding info object
  97466. * @param storage target storage array, if any
  97467. * @hidden
  97468. */
  97469. private _addParticle;
  97470. /**
  97471. * Adds some particles to the SPS from the model shape. Returns the shape id.
  97472. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  97473. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  97474. * @param nb (positive integer) the number of particles to be created from this model
  97475. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  97476. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  97477. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97478. * @returns the number of shapes in the system
  97479. */
  97480. addShape(mesh: Mesh, nb: number, options?: {
  97481. positionFunction?: any;
  97482. vertexFunction?: any;
  97483. storage?: [];
  97484. }): number;
  97485. /**
  97486. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  97487. * @hidden
  97488. */
  97489. private _rebuildParticle;
  97490. /**
  97491. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  97492. * @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.
  97493. * @returns the SPS.
  97494. */
  97495. rebuildMesh(reset?: boolean): SolidParticleSystem;
  97496. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  97497. * Returns an array with the removed particles.
  97498. * 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.
  97499. * The SPS can't be empty so at least one particle needs to remain in place.
  97500. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  97501. * @param start index of the first particle to remove
  97502. * @param end index of the last particle to remove (included)
  97503. * @returns an array populated with the removed particles
  97504. */
  97505. removeParticles(start: number, end: number): SolidParticle[];
  97506. /**
  97507. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  97508. * @param solidParticleArray an array populated with Solid Particles objects
  97509. * @returns the SPS
  97510. */
  97511. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  97512. /**
  97513. * Creates a new particle and modifies the SPS mesh geometry :
  97514. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  97515. * - calls _addParticle() to populate the particle array
  97516. * factorized code from addShape() and insertParticlesFromArray()
  97517. * @param idx particle index in the particles array
  97518. * @param i particle index in its shape
  97519. * @param modelShape particle ModelShape object
  97520. * @param shape shape vertex array
  97521. * @param meshInd shape indices array
  97522. * @param meshUV shape uv array
  97523. * @param meshCol shape color array
  97524. * @param meshNor shape normals array
  97525. * @param bbInfo shape bounding info
  97526. * @param storage target particle storage
  97527. * @options addShape() passed options
  97528. * @hidden
  97529. */
  97530. private _insertNewParticle;
  97531. /**
  97532. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  97533. * This method calls `updateParticle()` for each particle of the SPS.
  97534. * For an animated SPS, it is usually called within the render loop.
  97535. * 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.
  97536. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  97537. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  97538. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  97539. * @returns the SPS.
  97540. */
  97541. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  97542. /**
  97543. * Disposes the SPS.
  97544. */
  97545. dispose(): void;
  97546. /**
  97547. * Returns a SolidParticle object from its identifier : particle.id
  97548. * @param id (integer) the particle Id
  97549. * @returns the searched particle or null if not found in the SPS.
  97550. */
  97551. getParticleById(id: number): Nullable<SolidParticle>;
  97552. /**
  97553. * Returns a new array populated with the particles having the passed shapeId.
  97554. * @param shapeId (integer) the shape identifier
  97555. * @returns a new solid particle array
  97556. */
  97557. getParticlesByShapeId(shapeId: number): SolidParticle[];
  97558. /**
  97559. * Populates the passed array "ref" with the particles having the passed shapeId.
  97560. * @param shapeId the shape identifier
  97561. * @returns the SPS
  97562. * @param ref
  97563. */
  97564. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  97565. /**
  97566. * Computes the required SubMeshes according the materials assigned to the particles.
  97567. * @returns the solid particle system.
  97568. * Does nothing if called before the SPS mesh is built.
  97569. */
  97570. computeSubMeshes(): SolidParticleSystem;
  97571. /**
  97572. * Sorts the solid particles by material when MultiMaterial is enabled.
  97573. * Updates the indices32 array.
  97574. * Updates the indicesByMaterial array.
  97575. * Updates the mesh indices array.
  97576. * @returns the SPS
  97577. * @hidden
  97578. */
  97579. private _sortParticlesByMaterial;
  97580. /**
  97581. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  97582. * @hidden
  97583. */
  97584. private _setMaterialIndexesById;
  97585. /**
  97586. * Returns an array with unique values of Materials from the passed array
  97587. * @param array the material array to be checked and filtered
  97588. * @hidden
  97589. */
  97590. private _filterUniqueMaterialId;
  97591. /**
  97592. * Sets a new Standard Material as _defaultMaterial if not already set.
  97593. * @hidden
  97594. */
  97595. private _setDefaultMaterial;
  97596. /**
  97597. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  97598. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97599. * @returns the SPS.
  97600. */
  97601. refreshVisibleSize(): SolidParticleSystem;
  97602. /**
  97603. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  97604. * @param size the size (float) of the visibility box
  97605. * note : this doesn't lock the SPS mesh bounding box.
  97606. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97607. */
  97608. setVisibilityBox(size: number): void;
  97609. /**
  97610. * Gets whether the SPS as always visible or not
  97611. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97612. */
  97613. get isAlwaysVisible(): boolean;
  97614. /**
  97615. * Sets the SPS as always visible or not
  97616. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97617. */
  97618. set isAlwaysVisible(val: boolean);
  97619. /**
  97620. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97621. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97622. */
  97623. set isVisibilityBoxLocked(val: boolean);
  97624. /**
  97625. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97626. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97627. */
  97628. get isVisibilityBoxLocked(): boolean;
  97629. /**
  97630. * Tells to `setParticles()` to compute the particle rotations or not.
  97631. * Default value : true. The SPS is faster when it's set to false.
  97632. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97633. */
  97634. set computeParticleRotation(val: boolean);
  97635. /**
  97636. * Tells to `setParticles()` to compute the particle colors or not.
  97637. * Default value : true. The SPS is faster when it's set to false.
  97638. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97639. */
  97640. set computeParticleColor(val: boolean);
  97641. set computeParticleTexture(val: boolean);
  97642. /**
  97643. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  97644. * Default value : false. The SPS is faster when it's set to false.
  97645. * Note : the particle custom vertex positions aren't stored values.
  97646. */
  97647. set computeParticleVertex(val: boolean);
  97648. /**
  97649. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  97650. */
  97651. set computeBoundingBox(val: boolean);
  97652. /**
  97653. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  97654. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97655. * Default : `true`
  97656. */
  97657. set depthSortParticles(val: boolean);
  97658. /**
  97659. * Gets if `setParticles()` computes the particle rotations or not.
  97660. * Default value : true. The SPS is faster when it's set to false.
  97661. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97662. */
  97663. get computeParticleRotation(): boolean;
  97664. /**
  97665. * Gets if `setParticles()` computes the particle colors or not.
  97666. * Default value : true. The SPS is faster when it's set to false.
  97667. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97668. */
  97669. get computeParticleColor(): boolean;
  97670. /**
  97671. * Gets if `setParticles()` computes the particle textures or not.
  97672. * Default value : true. The SPS is faster when it's set to false.
  97673. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  97674. */
  97675. get computeParticleTexture(): boolean;
  97676. /**
  97677. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  97678. * Default value : false. The SPS is faster when it's set to false.
  97679. * Note : the particle custom vertex positions aren't stored values.
  97680. */
  97681. get computeParticleVertex(): boolean;
  97682. /**
  97683. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  97684. */
  97685. get computeBoundingBox(): boolean;
  97686. /**
  97687. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  97688. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97689. * Default : `true`
  97690. */
  97691. get depthSortParticles(): boolean;
  97692. /**
  97693. * Gets if the SPS is created as expandable at construction time.
  97694. * Default : `false`
  97695. */
  97696. get expandable(): boolean;
  97697. /**
  97698. * Gets if the SPS supports the Multi Materials
  97699. */
  97700. get multimaterialEnabled(): boolean;
  97701. /**
  97702. * Gets if the SPS uses the model materials for its own multimaterial.
  97703. */
  97704. get useModelMaterial(): boolean;
  97705. /**
  97706. * The SPS used material array.
  97707. */
  97708. get materials(): Material[];
  97709. /**
  97710. * Sets the SPS MultiMaterial from the passed materials.
  97711. * Note : the passed array is internally copied and not used then by reference.
  97712. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  97713. */
  97714. setMultiMaterial(materials: Material[]): void;
  97715. /**
  97716. * The SPS computed multimaterial object
  97717. */
  97718. get multimaterial(): MultiMaterial;
  97719. set multimaterial(mm: MultiMaterial);
  97720. /**
  97721. * If the subMeshes must be updated on the next call to setParticles()
  97722. */
  97723. get autoUpdateSubMeshes(): boolean;
  97724. set autoUpdateSubMeshes(val: boolean);
  97725. /**
  97726. * This function does nothing. It may be overwritten to set all the particle first values.
  97727. * The SPS doesn't call this function, you may have to call it by your own.
  97728. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97729. */
  97730. initParticles(): void;
  97731. /**
  97732. * This function does nothing. It may be overwritten to recycle a particle.
  97733. * The SPS doesn't call this function, you may have to call it by your own.
  97734. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97735. * @param particle The particle to recycle
  97736. * @returns the recycled particle
  97737. */
  97738. recycleParticle(particle: SolidParticle): SolidParticle;
  97739. /**
  97740. * Updates a particle : this function should be overwritten by the user.
  97741. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  97742. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97743. * @example : just set a particle position or velocity and recycle conditions
  97744. * @param particle The particle to update
  97745. * @returns the updated particle
  97746. */
  97747. updateParticle(particle: SolidParticle): SolidParticle;
  97748. /**
  97749. * Updates a vertex of a particle : it can be overwritten by the user.
  97750. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  97751. * @param particle the current particle
  97752. * @param vertex the current index of the current particle
  97753. * @param pt the index of the current vertex in the particle shape
  97754. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  97755. * @example : just set a vertex particle position
  97756. * @returns the updated vertex
  97757. */
  97758. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  97759. /**
  97760. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  97761. * This does nothing and may be overwritten by the user.
  97762. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97763. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97764. * @param update the boolean update value actually passed to setParticles()
  97765. */
  97766. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97767. /**
  97768. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  97769. * This will be passed three parameters.
  97770. * This does nothing and may be overwritten by the user.
  97771. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97772. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97773. * @param update the boolean update value actually passed to setParticles()
  97774. */
  97775. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97776. }
  97777. }
  97778. declare module BABYLON {
  97779. /**
  97780. * Represents one particle of a solid particle system.
  97781. */
  97782. export class SolidParticle {
  97783. /**
  97784. * particle global index
  97785. */
  97786. idx: number;
  97787. /**
  97788. * particle identifier
  97789. */
  97790. id: number;
  97791. /**
  97792. * The color of the particle
  97793. */
  97794. color: Nullable<Color4>;
  97795. /**
  97796. * The world space position of the particle.
  97797. */
  97798. position: Vector3;
  97799. /**
  97800. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  97801. */
  97802. rotation: Vector3;
  97803. /**
  97804. * The world space rotation quaternion of the particle.
  97805. */
  97806. rotationQuaternion: Nullable<Quaternion>;
  97807. /**
  97808. * The scaling of the particle.
  97809. */
  97810. scaling: Vector3;
  97811. /**
  97812. * The uvs of the particle.
  97813. */
  97814. uvs: Vector4;
  97815. /**
  97816. * The current speed of the particle.
  97817. */
  97818. velocity: Vector3;
  97819. /**
  97820. * The pivot point in the particle local space.
  97821. */
  97822. pivot: Vector3;
  97823. /**
  97824. * Must the particle be translated from its pivot point in its local space ?
  97825. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  97826. * Default : false
  97827. */
  97828. translateFromPivot: boolean;
  97829. /**
  97830. * Is the particle active or not ?
  97831. */
  97832. alive: boolean;
  97833. /**
  97834. * Is the particle visible or not ?
  97835. */
  97836. isVisible: boolean;
  97837. /**
  97838. * Index of this particle in the global "positions" array (Internal use)
  97839. * @hidden
  97840. */
  97841. _pos: number;
  97842. /**
  97843. * @hidden Index of this particle in the global "indices" array (Internal use)
  97844. */
  97845. _ind: number;
  97846. /**
  97847. * @hidden ModelShape of this particle (Internal use)
  97848. */
  97849. _model: ModelShape;
  97850. /**
  97851. * ModelShape id of this particle
  97852. */
  97853. shapeId: number;
  97854. /**
  97855. * Index of the particle in its shape id
  97856. */
  97857. idxInShape: number;
  97858. /**
  97859. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  97860. */
  97861. _modelBoundingInfo: BoundingInfo;
  97862. /**
  97863. * @hidden Particle BoundingInfo object (Internal use)
  97864. */
  97865. _boundingInfo: BoundingInfo;
  97866. /**
  97867. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  97868. */
  97869. _sps: SolidParticleSystem;
  97870. /**
  97871. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  97872. */
  97873. _stillInvisible: boolean;
  97874. /**
  97875. * @hidden Last computed particle rotation matrix
  97876. */
  97877. _rotationMatrix: number[];
  97878. /**
  97879. * Parent particle Id, if any.
  97880. * Default null.
  97881. */
  97882. parentId: Nullable<number>;
  97883. /**
  97884. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  97885. */
  97886. materialIndex: Nullable<number>;
  97887. /**
  97888. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  97889. * The possible values are :
  97890. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  97891. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97892. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  97893. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  97894. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97895. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  97896. * */
  97897. cullingStrategy: number;
  97898. /**
  97899. * @hidden Internal global position in the SPS.
  97900. */
  97901. _globalPosition: Vector3;
  97902. /**
  97903. * Creates a Solid Particle object.
  97904. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  97905. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  97906. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  97907. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  97908. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  97909. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  97910. * @param shapeId (integer) is the model shape identifier in the SPS.
  97911. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  97912. * @param sps defines the sps it is associated to
  97913. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  97914. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  97915. */
  97916. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  97917. /**
  97918. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  97919. * @param target the particle target
  97920. * @returns the current particle
  97921. */
  97922. copyToRef(target: SolidParticle): SolidParticle;
  97923. /**
  97924. * Legacy support, changed scale to scaling
  97925. */
  97926. get scale(): Vector3;
  97927. /**
  97928. * Legacy support, changed scale to scaling
  97929. */
  97930. set scale(scale: Vector3);
  97931. /**
  97932. * Legacy support, changed quaternion to rotationQuaternion
  97933. */
  97934. get quaternion(): Nullable<Quaternion>;
  97935. /**
  97936. * Legacy support, changed quaternion to rotationQuaternion
  97937. */
  97938. set quaternion(q: Nullable<Quaternion>);
  97939. /**
  97940. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  97941. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  97942. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  97943. * @returns true if it intersects
  97944. */
  97945. intersectsMesh(target: Mesh | SolidParticle): boolean;
  97946. /**
  97947. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  97948. * A particle is in the frustum if its bounding box intersects the frustum
  97949. * @param frustumPlanes defines the frustum to test
  97950. * @returns true if the particle is in the frustum planes
  97951. */
  97952. isInFrustum(frustumPlanes: Plane[]): boolean;
  97953. /**
  97954. * get the rotation matrix of the particle
  97955. * @hidden
  97956. */
  97957. getRotationMatrix(m: Matrix): void;
  97958. }
  97959. /**
  97960. * Represents the shape of the model used by one particle of a solid particle system.
  97961. * SPS internal tool, don't use it manually.
  97962. */
  97963. export class ModelShape {
  97964. /**
  97965. * The shape id
  97966. * @hidden
  97967. */
  97968. shapeID: number;
  97969. /**
  97970. * flat array of model positions (internal use)
  97971. * @hidden
  97972. */
  97973. _shape: Vector3[];
  97974. /**
  97975. * flat array of model UVs (internal use)
  97976. * @hidden
  97977. */
  97978. _shapeUV: number[];
  97979. /**
  97980. * color array of the model
  97981. * @hidden
  97982. */
  97983. _shapeColors: number[];
  97984. /**
  97985. * indices array of the model
  97986. * @hidden
  97987. */
  97988. _indices: number[];
  97989. /**
  97990. * normals array of the model
  97991. * @hidden
  97992. */
  97993. _normals: number[];
  97994. /**
  97995. * length of the shape in the model indices array (internal use)
  97996. * @hidden
  97997. */
  97998. _indicesLength: number;
  97999. /**
  98000. * Custom position function (internal use)
  98001. * @hidden
  98002. */
  98003. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  98004. /**
  98005. * Custom vertex function (internal use)
  98006. * @hidden
  98007. */
  98008. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  98009. /**
  98010. * Model material (internal use)
  98011. * @hidden
  98012. */
  98013. _material: Nullable<Material>;
  98014. /**
  98015. * 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.
  98016. * SPS internal tool, don't use it manually.
  98017. * @hidden
  98018. */
  98019. 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>);
  98020. }
  98021. /**
  98022. * Represents a Depth Sorted Particle in the solid particle system.
  98023. * @hidden
  98024. */
  98025. export class DepthSortedParticle {
  98026. /**
  98027. * Index of the particle in the "indices" array
  98028. */
  98029. ind: number;
  98030. /**
  98031. * Length of the particle shape in the "indices" array
  98032. */
  98033. indicesLength: number;
  98034. /**
  98035. * Squared distance from the particle to the camera
  98036. */
  98037. sqDistance: number;
  98038. /**
  98039. * Material index when used with MultiMaterials
  98040. */
  98041. materialIndex: number;
  98042. /**
  98043. * Creates a new sorted particle
  98044. * @param materialIndex
  98045. */
  98046. constructor(ind: number, indLength: number, materialIndex: number);
  98047. }
  98048. }
  98049. declare module BABYLON {
  98050. /**
  98051. * @hidden
  98052. */
  98053. export class _MeshCollisionData {
  98054. _checkCollisions: boolean;
  98055. _collisionMask: number;
  98056. _collisionGroup: number;
  98057. _collider: Nullable<Collider>;
  98058. _oldPositionForCollisions: Vector3;
  98059. _diffPositionForCollisions: Vector3;
  98060. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98061. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98062. }
  98063. }
  98064. declare module BABYLON {
  98065. /** @hidden */
  98066. class _FacetDataStorage {
  98067. facetPositions: Vector3[];
  98068. facetNormals: Vector3[];
  98069. facetPartitioning: number[][];
  98070. facetNb: number;
  98071. partitioningSubdivisions: number;
  98072. partitioningBBoxRatio: number;
  98073. facetDataEnabled: boolean;
  98074. facetParameters: any;
  98075. bbSize: Vector3;
  98076. subDiv: {
  98077. max: number;
  98078. X: number;
  98079. Y: number;
  98080. Z: number;
  98081. };
  98082. facetDepthSort: boolean;
  98083. facetDepthSortEnabled: boolean;
  98084. depthSortedIndices: IndicesArray;
  98085. depthSortedFacets: {
  98086. ind: number;
  98087. sqDistance: number;
  98088. }[];
  98089. facetDepthSortFunction: (f1: {
  98090. ind: number;
  98091. sqDistance: number;
  98092. }, f2: {
  98093. ind: number;
  98094. sqDistance: number;
  98095. }) => number;
  98096. facetDepthSortFrom: Vector3;
  98097. facetDepthSortOrigin: Vector3;
  98098. invertedMatrix: Matrix;
  98099. }
  98100. /**
  98101. * @hidden
  98102. **/
  98103. class _InternalAbstractMeshDataInfo {
  98104. _hasVertexAlpha: boolean;
  98105. _useVertexColors: boolean;
  98106. _numBoneInfluencers: number;
  98107. _applyFog: boolean;
  98108. _receiveShadows: boolean;
  98109. _facetData: _FacetDataStorage;
  98110. _visibility: number;
  98111. _skeleton: Nullable<Skeleton>;
  98112. _layerMask: number;
  98113. _computeBonesUsingShaders: boolean;
  98114. _isActive: boolean;
  98115. _onlyForInstances: boolean;
  98116. _isActiveIntermediate: boolean;
  98117. _onlyForInstancesIntermediate: boolean;
  98118. _actAsRegularMesh: boolean;
  98119. }
  98120. /**
  98121. * Class used to store all common mesh properties
  98122. */
  98123. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98124. /** No occlusion */
  98125. static OCCLUSION_TYPE_NONE: number;
  98126. /** Occlusion set to optimisitic */
  98127. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98128. /** Occlusion set to strict */
  98129. static OCCLUSION_TYPE_STRICT: number;
  98130. /** Use an accurante occlusion algorithm */
  98131. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98132. /** Use a conservative occlusion algorithm */
  98133. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98134. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98135. * Test order :
  98136. * Is the bounding sphere outside the frustum ?
  98137. * If not, are the bounding box vertices outside the frustum ?
  98138. * It not, then the cullable object is in the frustum.
  98139. */
  98140. static readonly CULLINGSTRATEGY_STANDARD: number;
  98141. /** Culling strategy : Bounding Sphere Only.
  98142. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98143. * It's also less accurate than the standard because some not visible objects can still be selected.
  98144. * Test : is the bounding sphere outside the frustum ?
  98145. * If not, then the cullable object is in the frustum.
  98146. */
  98147. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98148. /** Culling strategy : Optimistic Inclusion.
  98149. * This in an inclusion test first, then the standard exclusion test.
  98150. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98151. * 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.
  98152. * Anyway, it's as accurate as the standard strategy.
  98153. * Test :
  98154. * Is the cullable object bounding sphere center in the frustum ?
  98155. * If not, apply the default culling strategy.
  98156. */
  98157. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98158. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98159. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98160. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98161. * 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.
  98162. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98163. * Test :
  98164. * Is the cullable object bounding sphere center in the frustum ?
  98165. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98166. */
  98167. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98168. /**
  98169. * No billboard
  98170. */
  98171. static get BILLBOARDMODE_NONE(): number;
  98172. /** Billboard on X axis */
  98173. static get BILLBOARDMODE_X(): number;
  98174. /** Billboard on Y axis */
  98175. static get BILLBOARDMODE_Y(): number;
  98176. /** Billboard on Z axis */
  98177. static get BILLBOARDMODE_Z(): number;
  98178. /** Billboard on all axes */
  98179. static get BILLBOARDMODE_ALL(): number;
  98180. /** Billboard on using position instead of orientation */
  98181. static get BILLBOARDMODE_USE_POSITION(): number;
  98182. /** @hidden */
  98183. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  98184. /**
  98185. * The culling strategy to use to check whether the mesh must be rendered or not.
  98186. * This value can be changed at any time and will be used on the next render mesh selection.
  98187. * The possible values are :
  98188. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98189. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98190. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98191. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98192. * Please read each static variable documentation to get details about the culling process.
  98193. * */
  98194. cullingStrategy: number;
  98195. /**
  98196. * Gets the number of facets in the mesh
  98197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98198. */
  98199. get facetNb(): number;
  98200. /**
  98201. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  98202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98203. */
  98204. get partitioningSubdivisions(): number;
  98205. set partitioningSubdivisions(nb: number);
  98206. /**
  98207. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  98208. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  98209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98210. */
  98211. get partitioningBBoxRatio(): number;
  98212. set partitioningBBoxRatio(ratio: number);
  98213. /**
  98214. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  98215. * Works only for updatable meshes.
  98216. * Doesn't work with multi-materials
  98217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98218. */
  98219. get mustDepthSortFacets(): boolean;
  98220. set mustDepthSortFacets(sort: boolean);
  98221. /**
  98222. * The location (Vector3) where the facet depth sort must be computed from.
  98223. * By default, the active camera position.
  98224. * Used only when facet depth sort is enabled
  98225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98226. */
  98227. get facetDepthSortFrom(): Vector3;
  98228. set facetDepthSortFrom(location: Vector3);
  98229. /**
  98230. * gets a boolean indicating if facetData is enabled
  98231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98232. */
  98233. get isFacetDataEnabled(): boolean;
  98234. /** @hidden */
  98235. _updateNonUniformScalingState(value: boolean): boolean;
  98236. /**
  98237. * An event triggered when this mesh collides with another one
  98238. */
  98239. onCollideObservable: Observable<AbstractMesh>;
  98240. /** Set a function to call when this mesh collides with another one */
  98241. set onCollide(callback: () => void);
  98242. /**
  98243. * An event triggered when the collision's position changes
  98244. */
  98245. onCollisionPositionChangeObservable: Observable<Vector3>;
  98246. /** Set a function to call when the collision's position changes */
  98247. set onCollisionPositionChange(callback: () => void);
  98248. /**
  98249. * An event triggered when material is changed
  98250. */
  98251. onMaterialChangedObservable: Observable<AbstractMesh>;
  98252. /**
  98253. * Gets or sets the orientation for POV movement & rotation
  98254. */
  98255. definedFacingForward: boolean;
  98256. /** @hidden */
  98257. _occlusionQuery: Nullable<WebGLQuery>;
  98258. /** @hidden */
  98259. _renderingGroup: Nullable<RenderingGroup>;
  98260. /**
  98261. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98262. */
  98263. get visibility(): number;
  98264. /**
  98265. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98266. */
  98267. set visibility(value: number);
  98268. /** Gets or sets the alpha index used to sort transparent meshes
  98269. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  98270. */
  98271. alphaIndex: number;
  98272. /**
  98273. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  98274. */
  98275. isVisible: boolean;
  98276. /**
  98277. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  98278. */
  98279. isPickable: boolean;
  98280. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  98281. showSubMeshesBoundingBox: boolean;
  98282. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  98283. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  98284. */
  98285. isBlocker: boolean;
  98286. /**
  98287. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  98288. */
  98289. enablePointerMoveEvents: boolean;
  98290. /**
  98291. * Specifies the rendering group id for this mesh (0 by default)
  98292. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  98293. */
  98294. renderingGroupId: number;
  98295. private _material;
  98296. /** Gets or sets current material */
  98297. get material(): Nullable<Material>;
  98298. set material(value: Nullable<Material>);
  98299. /**
  98300. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  98301. * @see http://doc.babylonjs.com/babylon101/shadows
  98302. */
  98303. get receiveShadows(): boolean;
  98304. set receiveShadows(value: boolean);
  98305. /** Defines color to use when rendering outline */
  98306. outlineColor: Color3;
  98307. /** Define width to use when rendering outline */
  98308. outlineWidth: number;
  98309. /** Defines color to use when rendering overlay */
  98310. overlayColor: Color3;
  98311. /** Defines alpha to use when rendering overlay */
  98312. overlayAlpha: number;
  98313. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  98314. get hasVertexAlpha(): boolean;
  98315. set hasVertexAlpha(value: boolean);
  98316. /** 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) */
  98317. get useVertexColors(): boolean;
  98318. set useVertexColors(value: boolean);
  98319. /**
  98320. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  98321. */
  98322. get computeBonesUsingShaders(): boolean;
  98323. set computeBonesUsingShaders(value: boolean);
  98324. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  98325. get numBoneInfluencers(): number;
  98326. set numBoneInfluencers(value: number);
  98327. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  98328. get applyFog(): boolean;
  98329. set applyFog(value: boolean);
  98330. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  98331. useOctreeForRenderingSelection: boolean;
  98332. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  98333. useOctreeForPicking: boolean;
  98334. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  98335. useOctreeForCollisions: boolean;
  98336. /**
  98337. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  98338. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  98339. */
  98340. get layerMask(): number;
  98341. set layerMask(value: number);
  98342. /**
  98343. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  98344. */
  98345. alwaysSelectAsActiveMesh: boolean;
  98346. /**
  98347. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  98348. */
  98349. doNotSyncBoundingInfo: boolean;
  98350. /**
  98351. * Gets or sets the current action manager
  98352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98353. */
  98354. actionManager: Nullable<AbstractActionManager>;
  98355. private _meshCollisionData;
  98356. /**
  98357. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  98358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98359. */
  98360. ellipsoid: Vector3;
  98361. /**
  98362. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  98363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98364. */
  98365. ellipsoidOffset: Vector3;
  98366. /**
  98367. * Gets or sets a collision mask used to mask collisions (default is -1).
  98368. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98369. */
  98370. get collisionMask(): number;
  98371. set collisionMask(mask: number);
  98372. /**
  98373. * Gets or sets the current collision group mask (-1 by default).
  98374. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98375. */
  98376. get collisionGroup(): number;
  98377. set collisionGroup(mask: number);
  98378. /**
  98379. * Defines edge width used when edgesRenderer is enabled
  98380. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98381. */
  98382. edgesWidth: number;
  98383. /**
  98384. * Defines edge color used when edgesRenderer is enabled
  98385. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98386. */
  98387. edgesColor: Color4;
  98388. /** @hidden */
  98389. _edgesRenderer: Nullable<IEdgesRenderer>;
  98390. /** @hidden */
  98391. _masterMesh: Nullable<AbstractMesh>;
  98392. /** @hidden */
  98393. _boundingInfo: Nullable<BoundingInfo>;
  98394. /** @hidden */
  98395. _renderId: number;
  98396. /**
  98397. * Gets or sets the list of subMeshes
  98398. * @see http://doc.babylonjs.com/how_to/multi_materials
  98399. */
  98400. subMeshes: SubMesh[];
  98401. /** @hidden */
  98402. _intersectionsInProgress: AbstractMesh[];
  98403. /** @hidden */
  98404. _unIndexed: boolean;
  98405. /** @hidden */
  98406. _lightSources: Light[];
  98407. /** Gets the list of lights affecting that mesh */
  98408. get lightSources(): Light[];
  98409. /** @hidden */
  98410. get _positions(): Nullable<Vector3[]>;
  98411. /** @hidden */
  98412. _waitingData: {
  98413. lods: Nullable<any>;
  98414. actions: Nullable<any>;
  98415. freezeWorldMatrix: Nullable<boolean>;
  98416. };
  98417. /** @hidden */
  98418. _bonesTransformMatrices: Nullable<Float32Array>;
  98419. /** @hidden */
  98420. _transformMatrixTexture: Nullable<RawTexture>;
  98421. /**
  98422. * Gets or sets a skeleton to apply skining transformations
  98423. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98424. */
  98425. set skeleton(value: Nullable<Skeleton>);
  98426. get skeleton(): Nullable<Skeleton>;
  98427. /**
  98428. * An event triggered when the mesh is rebuilt.
  98429. */
  98430. onRebuildObservable: Observable<AbstractMesh>;
  98431. /**
  98432. * Creates a new AbstractMesh
  98433. * @param name defines the name of the mesh
  98434. * @param scene defines the hosting scene
  98435. */
  98436. constructor(name: string, scene?: Nullable<Scene>);
  98437. /**
  98438. * Returns the string "AbstractMesh"
  98439. * @returns "AbstractMesh"
  98440. */
  98441. getClassName(): string;
  98442. /**
  98443. * Gets a string representation of the current mesh
  98444. * @param fullDetails defines a boolean indicating if full details must be included
  98445. * @returns a string representation of the current mesh
  98446. */
  98447. toString(fullDetails?: boolean): string;
  98448. /**
  98449. * @hidden
  98450. */
  98451. protected _getEffectiveParent(): Nullable<Node>;
  98452. /** @hidden */
  98453. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  98454. /** @hidden */
  98455. _rebuild(): void;
  98456. /** @hidden */
  98457. _resyncLightSources(): void;
  98458. /** @hidden */
  98459. _resyncLightSource(light: Light): void;
  98460. /** @hidden */
  98461. _unBindEffect(): void;
  98462. /** @hidden */
  98463. _removeLightSource(light: Light, dispose: boolean): void;
  98464. private _markSubMeshesAsDirty;
  98465. /** @hidden */
  98466. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  98467. /** @hidden */
  98468. _markSubMeshesAsAttributesDirty(): void;
  98469. /** @hidden */
  98470. _markSubMeshesAsMiscDirty(): void;
  98471. /**
  98472. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  98473. */
  98474. get scaling(): Vector3;
  98475. set scaling(newScaling: Vector3);
  98476. /**
  98477. * Returns true if the mesh is blocked. Implemented by child classes
  98478. */
  98479. get isBlocked(): boolean;
  98480. /**
  98481. * Returns the mesh itself by default. Implemented by child classes
  98482. * @param camera defines the camera to use to pick the right LOD level
  98483. * @returns the currentAbstractMesh
  98484. */
  98485. getLOD(camera: Camera): Nullable<AbstractMesh>;
  98486. /**
  98487. * Returns 0 by default. Implemented by child classes
  98488. * @returns an integer
  98489. */
  98490. getTotalVertices(): number;
  98491. /**
  98492. * Returns a positive integer : the total number of indices in this mesh geometry.
  98493. * @returns the numner of indices or zero if the mesh has no geometry.
  98494. */
  98495. getTotalIndices(): number;
  98496. /**
  98497. * Returns null by default. Implemented by child classes
  98498. * @returns null
  98499. */
  98500. getIndices(): Nullable<IndicesArray>;
  98501. /**
  98502. * Returns the array of the requested vertex data kind. Implemented by child classes
  98503. * @param kind defines the vertex data kind to use
  98504. * @returns null
  98505. */
  98506. getVerticesData(kind: string): Nullable<FloatArray>;
  98507. /**
  98508. * Sets the vertex data of the mesh geometry for the requested `kind`.
  98509. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  98510. * Note that a new underlying VertexBuffer object is created each call.
  98511. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  98512. * @param kind defines vertex data kind:
  98513. * * VertexBuffer.PositionKind
  98514. * * VertexBuffer.UVKind
  98515. * * VertexBuffer.UV2Kind
  98516. * * VertexBuffer.UV3Kind
  98517. * * VertexBuffer.UV4Kind
  98518. * * VertexBuffer.UV5Kind
  98519. * * VertexBuffer.UV6Kind
  98520. * * VertexBuffer.ColorKind
  98521. * * VertexBuffer.MatricesIndicesKind
  98522. * * VertexBuffer.MatricesIndicesExtraKind
  98523. * * VertexBuffer.MatricesWeightsKind
  98524. * * VertexBuffer.MatricesWeightsExtraKind
  98525. * @param data defines the data source
  98526. * @param updatable defines if the data must be flagged as updatable (or static)
  98527. * @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
  98528. * @returns the current mesh
  98529. */
  98530. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98531. /**
  98532. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  98533. * If the mesh has no geometry, it is simply returned as it is.
  98534. * @param kind defines vertex data kind:
  98535. * * VertexBuffer.PositionKind
  98536. * * VertexBuffer.UVKind
  98537. * * VertexBuffer.UV2Kind
  98538. * * VertexBuffer.UV3Kind
  98539. * * VertexBuffer.UV4Kind
  98540. * * VertexBuffer.UV5Kind
  98541. * * VertexBuffer.UV6Kind
  98542. * * VertexBuffer.ColorKind
  98543. * * VertexBuffer.MatricesIndicesKind
  98544. * * VertexBuffer.MatricesIndicesExtraKind
  98545. * * VertexBuffer.MatricesWeightsKind
  98546. * * VertexBuffer.MatricesWeightsExtraKind
  98547. * @param data defines the data source
  98548. * @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
  98549. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  98550. * @returns the current mesh
  98551. */
  98552. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98553. /**
  98554. * Sets the mesh indices,
  98555. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  98556. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  98557. * @param totalVertices Defines the total number of vertices
  98558. * @returns the current mesh
  98559. */
  98560. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  98561. /**
  98562. * Gets a boolean indicating if specific vertex data is present
  98563. * @param kind defines the vertex data kind to use
  98564. * @returns true is data kind is present
  98565. */
  98566. isVerticesDataPresent(kind: string): boolean;
  98567. /**
  98568. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  98569. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  98570. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  98571. * @returns a BoundingInfo
  98572. */
  98573. getBoundingInfo(): BoundingInfo;
  98574. /**
  98575. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  98576. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  98577. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  98578. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  98579. * @returns the current mesh
  98580. */
  98581. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  98582. /**
  98583. * Overwrite the current bounding info
  98584. * @param boundingInfo defines the new bounding info
  98585. * @returns the current mesh
  98586. */
  98587. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  98588. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  98589. get useBones(): boolean;
  98590. /** @hidden */
  98591. _preActivate(): void;
  98592. /** @hidden */
  98593. _preActivateForIntermediateRendering(renderId: number): void;
  98594. /** @hidden */
  98595. _activate(renderId: number, intermediateRendering: boolean): boolean;
  98596. /** @hidden */
  98597. _postActivate(): void;
  98598. /** @hidden */
  98599. _freeze(): void;
  98600. /** @hidden */
  98601. _unFreeze(): void;
  98602. /**
  98603. * Gets the current world matrix
  98604. * @returns a Matrix
  98605. */
  98606. getWorldMatrix(): Matrix;
  98607. /** @hidden */
  98608. _getWorldMatrixDeterminant(): number;
  98609. /**
  98610. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  98611. */
  98612. get isAnInstance(): boolean;
  98613. /**
  98614. * Gets a boolean indicating if this mesh has instances
  98615. */
  98616. get hasInstances(): boolean;
  98617. /**
  98618. * Perform 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 current mesh
  98625. */
  98626. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  98627. /**
  98628. * Calculate relative position change from the point of view of behind the front of the mesh.
  98629. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98630. * Supports definition of mesh facing forward or backward
  98631. * @param amountRight defines the distance on the right axis
  98632. * @param amountUp defines the distance on the up axis
  98633. * @param amountForward defines the distance on the forward axis
  98634. * @returns the new displacement vector
  98635. */
  98636. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  98637. /**
  98638. * Perform relative rotation change from the point of view of behind the front of the mesh.
  98639. * Supports definition of mesh facing forward or backward
  98640. * @param flipBack defines the flip
  98641. * @param twirlClockwise defines the twirl
  98642. * @param tiltRight defines the tilt
  98643. * @returns the current mesh
  98644. */
  98645. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  98646. /**
  98647. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  98648. * Supports definition of mesh facing forward or backward.
  98649. * @param flipBack defines the flip
  98650. * @param twirlClockwise defines the twirl
  98651. * @param tiltRight defines the tilt
  98652. * @returns the new rotation vector
  98653. */
  98654. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  98655. /**
  98656. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98657. * This means the mesh underlying bounding box and sphere are recomputed.
  98658. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98659. * @returns the current mesh
  98660. */
  98661. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  98662. /** @hidden */
  98663. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  98664. /** @hidden */
  98665. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  98666. /** @hidden */
  98667. _updateBoundingInfo(): AbstractMesh;
  98668. /** @hidden */
  98669. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  98670. /** @hidden */
  98671. protected _afterComputeWorldMatrix(): void;
  98672. /** @hidden */
  98673. get _effectiveMesh(): AbstractMesh;
  98674. /**
  98675. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98676. * A mesh is in the frustum if its bounding box intersects the frustum
  98677. * @param frustumPlanes defines the frustum to test
  98678. * @returns true if the mesh is in the frustum planes
  98679. */
  98680. isInFrustum(frustumPlanes: Plane[]): boolean;
  98681. /**
  98682. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  98683. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  98684. * @param frustumPlanes defines the frustum to test
  98685. * @returns true if the mesh is completely in the frustum planes
  98686. */
  98687. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98688. /**
  98689. * True if the mesh intersects another mesh or a SolidParticle object
  98690. * @param mesh defines a target mesh or SolidParticle to test
  98691. * @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)
  98692. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  98693. * @returns true if there is an intersection
  98694. */
  98695. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  98696. /**
  98697. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  98698. * @param point defines the point to test
  98699. * @returns true if there is an intersection
  98700. */
  98701. intersectsPoint(point: Vector3): boolean;
  98702. /**
  98703. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  98704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98705. */
  98706. get checkCollisions(): boolean;
  98707. set checkCollisions(collisionEnabled: boolean);
  98708. /**
  98709. * Gets Collider object used to compute collisions (not physics)
  98710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98711. */
  98712. get collider(): Nullable<Collider>;
  98713. /**
  98714. * Move the mesh using collision engine
  98715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98716. * @param displacement defines the requested displacement vector
  98717. * @returns the current mesh
  98718. */
  98719. moveWithCollisions(displacement: Vector3): AbstractMesh;
  98720. private _onCollisionPositionChange;
  98721. /** @hidden */
  98722. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  98723. /** @hidden */
  98724. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  98725. /** @hidden */
  98726. _checkCollision(collider: Collider): AbstractMesh;
  98727. /** @hidden */
  98728. _generatePointsArray(): boolean;
  98729. /**
  98730. * Checks if the passed Ray intersects with the mesh
  98731. * @param ray defines the ray to use
  98732. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  98733. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98734. * @returns the picking info
  98735. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  98736. */
  98737. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  98738. /**
  98739. * Clones the current mesh
  98740. * @param name defines the mesh name
  98741. * @param newParent defines the new mesh parent
  98742. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  98743. * @returns the new mesh
  98744. */
  98745. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  98746. /**
  98747. * Disposes all the submeshes of the current meshnp
  98748. * @returns the current mesh
  98749. */
  98750. releaseSubMeshes(): AbstractMesh;
  98751. /**
  98752. * Releases resources associated with this abstract mesh.
  98753. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98754. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98755. */
  98756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98757. /**
  98758. * Adds the passed mesh as a child to the current mesh
  98759. * @param mesh defines the child mesh
  98760. * @returns the current mesh
  98761. */
  98762. addChild(mesh: AbstractMesh): AbstractMesh;
  98763. /**
  98764. * Removes the passed mesh from the current mesh children list
  98765. * @param mesh defines the child mesh
  98766. * @returns the current mesh
  98767. */
  98768. removeChild(mesh: AbstractMesh): AbstractMesh;
  98769. /** @hidden */
  98770. private _initFacetData;
  98771. /**
  98772. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  98773. * This method can be called within the render loop.
  98774. * 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
  98775. * @returns the current mesh
  98776. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98777. */
  98778. updateFacetData(): AbstractMesh;
  98779. /**
  98780. * Returns the facetLocalNormals array.
  98781. * The normals are expressed in the mesh local spac
  98782. * @returns an array of Vector3
  98783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98784. */
  98785. getFacetLocalNormals(): Vector3[];
  98786. /**
  98787. * Returns the facetLocalPositions array.
  98788. * The facet positions are expressed in the mesh local space
  98789. * @returns an array of Vector3
  98790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98791. */
  98792. getFacetLocalPositions(): Vector3[];
  98793. /**
  98794. * Returns the facetLocalPartioning array
  98795. * @returns an array of array of numbers
  98796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98797. */
  98798. getFacetLocalPartitioning(): number[][];
  98799. /**
  98800. * Returns the i-th facet position in the world system.
  98801. * This method allocates a new Vector3 per call
  98802. * @param i defines the facet index
  98803. * @returns a new Vector3
  98804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98805. */
  98806. getFacetPosition(i: number): Vector3;
  98807. /**
  98808. * Sets the reference Vector3 with the i-th facet position in the world system
  98809. * @param i defines the facet index
  98810. * @param ref defines the target vector
  98811. * @returns the current mesh
  98812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98813. */
  98814. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  98815. /**
  98816. * Returns the i-th facet normal in the world system.
  98817. * This method allocates a new Vector3 per call
  98818. * @param i defines the facet index
  98819. * @returns a new Vector3
  98820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98821. */
  98822. getFacetNormal(i: number): Vector3;
  98823. /**
  98824. * Sets the reference Vector3 with the i-th facet normal in the world system
  98825. * @param i defines the facet index
  98826. * @param ref defines the target vector
  98827. * @returns the current mesh
  98828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98829. */
  98830. getFacetNormalToRef(i: number, ref: Vector3): this;
  98831. /**
  98832. * 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)
  98833. * @param x defines x coordinate
  98834. * @param y defines y coordinate
  98835. * @param z defines z coordinate
  98836. * @returns the array of facet indexes
  98837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98838. */
  98839. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  98840. /**
  98841. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  98842. * @param projected sets as the (x,y,z) world projection on the facet
  98843. * @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
  98844. * @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
  98845. * @param x defines x coordinate
  98846. * @param y defines y coordinate
  98847. * @param z defines z coordinate
  98848. * @returns the face index if found (or null instead)
  98849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98850. */
  98851. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98852. /**
  98853. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  98854. * @param projected sets as the (x,y,z) local projection on the facet
  98855. * @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
  98856. * @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
  98857. * @param x defines x coordinate
  98858. * @param y defines y coordinate
  98859. * @param z defines z coordinate
  98860. * @returns the face index if found (or null instead)
  98861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98862. */
  98863. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98864. /**
  98865. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  98866. * @returns the parameters
  98867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98868. */
  98869. getFacetDataParameters(): any;
  98870. /**
  98871. * Disables the feature FacetData and frees the related memory
  98872. * @returns the current mesh
  98873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98874. */
  98875. disableFacetData(): AbstractMesh;
  98876. /**
  98877. * Updates the AbstractMesh indices array
  98878. * @param indices defines the data source
  98879. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98880. * @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)
  98881. * @returns the current mesh
  98882. */
  98883. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98884. /**
  98885. * Creates new normals data for the mesh
  98886. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  98887. * @returns the current mesh
  98888. */
  98889. createNormals(updatable: boolean): AbstractMesh;
  98890. /**
  98891. * Align the mesh with a normal
  98892. * @param normal defines the normal to use
  98893. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  98894. * @returns the current mesh
  98895. */
  98896. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  98897. /** @hidden */
  98898. _checkOcclusionQuery(): boolean;
  98899. /**
  98900. * Disables the mesh edge rendering mode
  98901. * @returns the currentAbstractMesh
  98902. */
  98903. disableEdgesRendering(): AbstractMesh;
  98904. /**
  98905. * Enables the edge rendering mode on the mesh.
  98906. * This mode makes the mesh edges visible
  98907. * @param epsilon defines the maximal distance between two angles to detect a face
  98908. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98909. * @returns the currentAbstractMesh
  98910. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98911. */
  98912. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98913. }
  98914. }
  98915. declare module BABYLON {
  98916. /**
  98917. * Interface used to define ActionEvent
  98918. */
  98919. export interface IActionEvent {
  98920. /** The mesh or sprite that triggered the action */
  98921. source: any;
  98922. /** The X mouse cursor position at the time of the event */
  98923. pointerX: number;
  98924. /** The Y mouse cursor position at the time of the event */
  98925. pointerY: number;
  98926. /** The mesh that is currently pointed at (can be null) */
  98927. meshUnderPointer: Nullable<AbstractMesh>;
  98928. /** the original (browser) event that triggered the ActionEvent */
  98929. sourceEvent?: any;
  98930. /** additional data for the event */
  98931. additionalData?: any;
  98932. }
  98933. /**
  98934. * ActionEvent is the event being sent when an action is triggered.
  98935. */
  98936. export class ActionEvent implements IActionEvent {
  98937. /** The mesh or sprite that triggered the action */
  98938. source: any;
  98939. /** The X mouse cursor position at the time of the event */
  98940. pointerX: number;
  98941. /** The Y mouse cursor position at the time of the event */
  98942. pointerY: number;
  98943. /** The mesh that is currently pointed at (can be null) */
  98944. meshUnderPointer: Nullable<AbstractMesh>;
  98945. /** the original (browser) event that triggered the ActionEvent */
  98946. sourceEvent?: any;
  98947. /** additional data for the event */
  98948. additionalData?: any;
  98949. /**
  98950. * Creates a new ActionEvent
  98951. * @param source The mesh or sprite that triggered the action
  98952. * @param pointerX The X mouse cursor position at the time of the event
  98953. * @param pointerY The Y mouse cursor position at the time of the event
  98954. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  98955. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  98956. * @param additionalData additional data for the event
  98957. */
  98958. constructor(
  98959. /** The mesh or sprite that triggered the action */
  98960. source: any,
  98961. /** The X mouse cursor position at the time of the event */
  98962. pointerX: number,
  98963. /** The Y mouse cursor position at the time of the event */
  98964. pointerY: number,
  98965. /** The mesh that is currently pointed at (can be null) */
  98966. meshUnderPointer: Nullable<AbstractMesh>,
  98967. /** the original (browser) event that triggered the ActionEvent */
  98968. sourceEvent?: any,
  98969. /** additional data for the event */
  98970. additionalData?: any);
  98971. /**
  98972. * Helper function to auto-create an ActionEvent from a source mesh.
  98973. * @param source The source mesh that triggered the event
  98974. * @param evt The original (browser) event
  98975. * @param additionalData additional data for the event
  98976. * @returns the new ActionEvent
  98977. */
  98978. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  98979. /**
  98980. * Helper function to auto-create an ActionEvent from a source sprite
  98981. * @param source The source sprite that triggered the event
  98982. * @param scene Scene associated with the sprite
  98983. * @param evt The original (browser) event
  98984. * @param additionalData additional data for the event
  98985. * @returns the new ActionEvent
  98986. */
  98987. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  98988. /**
  98989. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  98990. * @param scene the scene where the event occurred
  98991. * @param evt The original (browser) event
  98992. * @returns the new ActionEvent
  98993. */
  98994. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  98995. /**
  98996. * Helper function to auto-create an ActionEvent from a primitive
  98997. * @param prim defines the target primitive
  98998. * @param pointerPos defines the pointer position
  98999. * @param evt The original (browser) event
  99000. * @param additionalData additional data for the event
  99001. * @returns the new ActionEvent
  99002. */
  99003. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  99004. }
  99005. }
  99006. declare module BABYLON {
  99007. /**
  99008. * Abstract class used to decouple action Manager from scene and meshes.
  99009. * Do not instantiate.
  99010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99011. */
  99012. export abstract class AbstractActionManager implements IDisposable {
  99013. /** Gets the list of active triggers */
  99014. static Triggers: {
  99015. [key: string]: number;
  99016. };
  99017. /** Gets the cursor to use when hovering items */
  99018. hoverCursor: string;
  99019. /** Gets the list of actions */
  99020. actions: IAction[];
  99021. /**
  99022. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  99023. */
  99024. isRecursive: boolean;
  99025. /**
  99026. * Releases all associated resources
  99027. */
  99028. abstract dispose(): void;
  99029. /**
  99030. * Does this action manager has pointer triggers
  99031. */
  99032. abstract get hasPointerTriggers(): boolean;
  99033. /**
  99034. * Does this action manager has pick triggers
  99035. */
  99036. abstract get hasPickTriggers(): boolean;
  99037. /**
  99038. * Process a specific trigger
  99039. * @param trigger defines the trigger to process
  99040. * @param evt defines the event details to be processed
  99041. */
  99042. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99043. /**
  99044. * Does this action manager handles actions of any of the given triggers
  99045. * @param triggers defines the triggers to be tested
  99046. * @return a boolean indicating whether one (or more) of the triggers is handled
  99047. */
  99048. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99049. /**
  99050. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99051. * speed.
  99052. * @param triggerA defines the trigger to be tested
  99053. * @param triggerB defines the trigger to be tested
  99054. * @return a boolean indicating whether one (or more) of the triggers is handled
  99055. */
  99056. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99057. /**
  99058. * Does this action manager handles actions of a given trigger
  99059. * @param trigger defines the trigger to be tested
  99060. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99061. * @return whether the trigger is handled
  99062. */
  99063. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99064. /**
  99065. * Serialize this manager to a JSON object
  99066. * @param name defines the property name to store this manager
  99067. * @returns a JSON representation of this manager
  99068. */
  99069. abstract serialize(name: string): any;
  99070. /**
  99071. * Registers an action to this action manager
  99072. * @param action defines the action to be registered
  99073. * @return the action amended (prepared) after registration
  99074. */
  99075. abstract registerAction(action: IAction): Nullable<IAction>;
  99076. /**
  99077. * Unregisters an action to this action manager
  99078. * @param action defines the action to be unregistered
  99079. * @return a boolean indicating whether the action has been unregistered
  99080. */
  99081. abstract unregisterAction(action: IAction): Boolean;
  99082. /**
  99083. * Does exist one action manager with at least one trigger
  99084. **/
  99085. static get HasTriggers(): boolean;
  99086. /**
  99087. * Does exist one action manager with at least one pick trigger
  99088. **/
  99089. static get HasPickTriggers(): boolean;
  99090. /**
  99091. * Does exist one action manager that handles actions of a given trigger
  99092. * @param trigger defines the trigger to be tested
  99093. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99094. **/
  99095. static HasSpecificTrigger(trigger: number): boolean;
  99096. }
  99097. }
  99098. declare module BABYLON {
  99099. /**
  99100. * Defines how a node can be built from a string name.
  99101. */
  99102. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99103. /**
  99104. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99105. */
  99106. export class Node implements IBehaviorAware<Node> {
  99107. /** @hidden */
  99108. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99109. private static _NodeConstructors;
  99110. /**
  99111. * Add a new node constructor
  99112. * @param type defines the type name of the node to construct
  99113. * @param constructorFunc defines the constructor function
  99114. */
  99115. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99116. /**
  99117. * Returns a node constructor based on type name
  99118. * @param type defines the type name
  99119. * @param name defines the new node name
  99120. * @param scene defines the hosting scene
  99121. * @param options defines optional options to transmit to constructors
  99122. * @returns the new constructor or null
  99123. */
  99124. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99125. /**
  99126. * Gets or sets the name of the node
  99127. */
  99128. name: string;
  99129. /**
  99130. * Gets or sets the id of the node
  99131. */
  99132. id: string;
  99133. /**
  99134. * Gets or sets the unique id of the node
  99135. */
  99136. uniqueId: number;
  99137. /**
  99138. * Gets or sets a string used to store user defined state for the node
  99139. */
  99140. state: string;
  99141. /**
  99142. * Gets or sets an object used to store user defined information for the node
  99143. */
  99144. metadata: any;
  99145. /**
  99146. * For internal use only. Please do not use.
  99147. */
  99148. reservedDataStore: any;
  99149. /**
  99150. * List of inspectable custom properties (used by the Inspector)
  99151. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99152. */
  99153. inspectableCustomProperties: IInspectable[];
  99154. private _doNotSerialize;
  99155. /**
  99156. * Gets or sets a boolean used to define if the node must be serialized
  99157. */
  99158. get doNotSerialize(): boolean;
  99159. set doNotSerialize(value: boolean);
  99160. /** @hidden */
  99161. _isDisposed: boolean;
  99162. /**
  99163. * Gets a list of Animations associated with the node
  99164. */
  99165. animations: Animation[];
  99166. protected _ranges: {
  99167. [name: string]: Nullable<AnimationRange>;
  99168. };
  99169. /**
  99170. * Callback raised when the node is ready to be used
  99171. */
  99172. onReady: Nullable<(node: Node) => void>;
  99173. private _isEnabled;
  99174. private _isParentEnabled;
  99175. private _isReady;
  99176. /** @hidden */
  99177. _currentRenderId: number;
  99178. private _parentUpdateId;
  99179. /** @hidden */
  99180. _childUpdateId: number;
  99181. /** @hidden */
  99182. _waitingParentId: Nullable<string>;
  99183. /** @hidden */
  99184. _scene: Scene;
  99185. /** @hidden */
  99186. _cache: any;
  99187. private _parentNode;
  99188. private _children;
  99189. /** @hidden */
  99190. _worldMatrix: Matrix;
  99191. /** @hidden */
  99192. _worldMatrixDeterminant: number;
  99193. /** @hidden */
  99194. _worldMatrixDeterminantIsDirty: boolean;
  99195. /** @hidden */
  99196. private _sceneRootNodesIndex;
  99197. /**
  99198. * Gets a boolean indicating if the node has been disposed
  99199. * @returns true if the node was disposed
  99200. */
  99201. isDisposed(): boolean;
  99202. /**
  99203. * Gets or sets the parent of the node (without keeping the current position in the scene)
  99204. * @see https://doc.babylonjs.com/how_to/parenting
  99205. */
  99206. set parent(parent: Nullable<Node>);
  99207. get parent(): Nullable<Node>;
  99208. /** @hidden */
  99209. _addToSceneRootNodes(): void;
  99210. /** @hidden */
  99211. _removeFromSceneRootNodes(): void;
  99212. private _animationPropertiesOverride;
  99213. /**
  99214. * Gets or sets the animation properties override
  99215. */
  99216. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99217. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99218. /**
  99219. * Gets a string idenfifying the name of the class
  99220. * @returns "Node" string
  99221. */
  99222. getClassName(): string;
  99223. /** @hidden */
  99224. readonly _isNode: boolean;
  99225. /**
  99226. * An event triggered when the mesh is disposed
  99227. */
  99228. onDisposeObservable: Observable<Node>;
  99229. private _onDisposeObserver;
  99230. /**
  99231. * Sets a callback that will be raised when the node will be disposed
  99232. */
  99233. set onDispose(callback: () => void);
  99234. /**
  99235. * Creates a new Node
  99236. * @param name the name and id to be given to this node
  99237. * @param scene the scene this node will be added to
  99238. */
  99239. constructor(name: string, scene?: Nullable<Scene>);
  99240. /**
  99241. * Gets the scene of the node
  99242. * @returns a scene
  99243. */
  99244. getScene(): Scene;
  99245. /**
  99246. * Gets the engine of the node
  99247. * @returns a Engine
  99248. */
  99249. getEngine(): Engine;
  99250. private _behaviors;
  99251. /**
  99252. * Attach a behavior to the node
  99253. * @see http://doc.babylonjs.com/features/behaviour
  99254. * @param behavior defines the behavior to attach
  99255. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  99256. * @returns the current Node
  99257. */
  99258. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  99259. /**
  99260. * Remove an attached behavior
  99261. * @see http://doc.babylonjs.com/features/behaviour
  99262. * @param behavior defines the behavior to attach
  99263. * @returns the current Node
  99264. */
  99265. removeBehavior(behavior: Behavior<Node>): Node;
  99266. /**
  99267. * Gets the list of attached behaviors
  99268. * @see http://doc.babylonjs.com/features/behaviour
  99269. */
  99270. get behaviors(): Behavior<Node>[];
  99271. /**
  99272. * Gets an attached behavior by name
  99273. * @param name defines the name of the behavior to look for
  99274. * @see http://doc.babylonjs.com/features/behaviour
  99275. * @returns null if behavior was not found else the requested behavior
  99276. */
  99277. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  99278. /**
  99279. * Returns the latest update of the World matrix
  99280. * @returns a Matrix
  99281. */
  99282. getWorldMatrix(): Matrix;
  99283. /** @hidden */
  99284. _getWorldMatrixDeterminant(): number;
  99285. /**
  99286. * Returns directly the latest state of the mesh World matrix.
  99287. * A Matrix is returned.
  99288. */
  99289. get worldMatrixFromCache(): Matrix;
  99290. /** @hidden */
  99291. _initCache(): void;
  99292. /** @hidden */
  99293. updateCache(force?: boolean): void;
  99294. /** @hidden */
  99295. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99296. /** @hidden */
  99297. _updateCache(ignoreParentClass?: boolean): void;
  99298. /** @hidden */
  99299. _isSynchronized(): boolean;
  99300. /** @hidden */
  99301. _markSyncedWithParent(): void;
  99302. /** @hidden */
  99303. isSynchronizedWithParent(): boolean;
  99304. /** @hidden */
  99305. isSynchronized(): boolean;
  99306. /**
  99307. * Is this node ready to be used/rendered
  99308. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99309. * @return true if the node is ready
  99310. */
  99311. isReady(completeCheck?: boolean): boolean;
  99312. /**
  99313. * Is this node enabled?
  99314. * 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
  99315. * @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
  99316. * @return whether this node (and its parent) is enabled
  99317. */
  99318. isEnabled(checkAncestors?: boolean): boolean;
  99319. /** @hidden */
  99320. protected _syncParentEnabledState(): void;
  99321. /**
  99322. * Set the enabled state of this node
  99323. * @param value defines the new enabled state
  99324. */
  99325. setEnabled(value: boolean): void;
  99326. /**
  99327. * Is this node a descendant of the given node?
  99328. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  99329. * @param ancestor defines the parent node to inspect
  99330. * @returns a boolean indicating if this node is a descendant of the given node
  99331. */
  99332. isDescendantOf(ancestor: Node): boolean;
  99333. /** @hidden */
  99334. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  99335. /**
  99336. * Will return all nodes that have this node as ascendant
  99337. * @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
  99338. * @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
  99339. * @return all children nodes of all types
  99340. */
  99341. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  99342. /**
  99343. * Get all child-meshes of this node
  99344. * @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)
  99345. * @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
  99346. * @returns an array of AbstractMesh
  99347. */
  99348. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  99349. /**
  99350. * Get all direct children of this node
  99351. * @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
  99352. * @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)
  99353. * @returns an array of Node
  99354. */
  99355. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  99356. /** @hidden */
  99357. _setReady(state: boolean): void;
  99358. /**
  99359. * Get an animation by name
  99360. * @param name defines the name of the animation to look for
  99361. * @returns null if not found else the requested animation
  99362. */
  99363. getAnimationByName(name: string): Nullable<Animation>;
  99364. /**
  99365. * Creates an animation range for this node
  99366. * @param name defines the name of the range
  99367. * @param from defines the starting key
  99368. * @param to defines the end key
  99369. */
  99370. createAnimationRange(name: string, from: number, to: number): void;
  99371. /**
  99372. * Delete a specific animation range
  99373. * @param name defines the name of the range to delete
  99374. * @param deleteFrames defines if animation frames from the range must be deleted as well
  99375. */
  99376. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  99377. /**
  99378. * Get an animation range by name
  99379. * @param name defines the name of the animation range to look for
  99380. * @returns null if not found else the requested animation range
  99381. */
  99382. getAnimationRange(name: string): Nullable<AnimationRange>;
  99383. /**
  99384. * Gets the list of all animation ranges defined on this node
  99385. * @returns an array
  99386. */
  99387. getAnimationRanges(): Nullable<AnimationRange>[];
  99388. /**
  99389. * Will start the animation sequence
  99390. * @param name defines the range frames for animation sequence
  99391. * @param loop defines if the animation should loop (false by default)
  99392. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  99393. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  99394. * @returns the object created for this animation. If range does not exist, it will return null
  99395. */
  99396. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  99397. /**
  99398. * Serialize animation ranges into a JSON compatible object
  99399. * @returns serialization object
  99400. */
  99401. serializeAnimationRanges(): any;
  99402. /**
  99403. * Computes the world matrix of the node
  99404. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99405. * @returns the world matrix
  99406. */
  99407. computeWorldMatrix(force?: boolean): Matrix;
  99408. /**
  99409. * Releases resources associated with this node.
  99410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99412. */
  99413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99414. /**
  99415. * Parse animation range data from a serialization object and store them into a given node
  99416. * @param node defines where to store the animation ranges
  99417. * @param parsedNode defines the serialization object to read data from
  99418. * @param scene defines the hosting scene
  99419. */
  99420. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  99421. /**
  99422. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  99423. * @param includeDescendants Include bounding info from descendants as well (true by default)
  99424. * @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
  99425. * @returns the new bounding vectors
  99426. */
  99427. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  99428. min: Vector3;
  99429. max: Vector3;
  99430. };
  99431. }
  99432. }
  99433. declare module BABYLON {
  99434. /**
  99435. * @hidden
  99436. */
  99437. export class _IAnimationState {
  99438. key: number;
  99439. repeatCount: number;
  99440. workValue?: any;
  99441. loopMode?: number;
  99442. offsetValue?: any;
  99443. highLimitValue?: any;
  99444. }
  99445. /**
  99446. * Class used to store any kind of animation
  99447. */
  99448. export class Animation {
  99449. /**Name of the animation */
  99450. name: string;
  99451. /**Property to animate */
  99452. targetProperty: string;
  99453. /**The frames per second of the animation */
  99454. framePerSecond: number;
  99455. /**The data type of the animation */
  99456. dataType: number;
  99457. /**The loop mode of the animation */
  99458. loopMode?: number | undefined;
  99459. /**Specifies if blending should be enabled */
  99460. enableBlending?: boolean | undefined;
  99461. /**
  99462. * Use matrix interpolation instead of using direct key value when animating matrices
  99463. */
  99464. static AllowMatricesInterpolation: boolean;
  99465. /**
  99466. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  99467. */
  99468. static AllowMatrixDecomposeForInterpolation: boolean;
  99469. /**
  99470. * Stores the key frames of the animation
  99471. */
  99472. private _keys;
  99473. /**
  99474. * Stores the easing function of the animation
  99475. */
  99476. private _easingFunction;
  99477. /**
  99478. * @hidden Internal use only
  99479. */
  99480. _runtimeAnimations: RuntimeAnimation[];
  99481. /**
  99482. * The set of event that will be linked to this animation
  99483. */
  99484. private _events;
  99485. /**
  99486. * Stores an array of target property paths
  99487. */
  99488. targetPropertyPath: string[];
  99489. /**
  99490. * Stores the blending speed of the animation
  99491. */
  99492. blendingSpeed: number;
  99493. /**
  99494. * Stores the animation ranges for the animation
  99495. */
  99496. private _ranges;
  99497. /**
  99498. * @hidden Internal use
  99499. */
  99500. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  99501. /**
  99502. * Sets up an animation
  99503. * @param property The property to animate
  99504. * @param animationType The animation type to apply
  99505. * @param framePerSecond The frames per second of the animation
  99506. * @param easingFunction The easing function used in the animation
  99507. * @returns The created animation
  99508. */
  99509. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  99510. /**
  99511. * Create and start an animation on a node
  99512. * @param name defines the name of the global animation that will be run on all nodes
  99513. * @param node defines the root node where the animation will take place
  99514. * @param targetProperty defines property to animate
  99515. * @param framePerSecond defines the number of frame per second yo use
  99516. * @param totalFrame defines the number of frames in total
  99517. * @param from defines the initial value
  99518. * @param to defines the final value
  99519. * @param loopMode defines which loop mode you want to use (off by default)
  99520. * @param easingFunction defines the easing function to use (linear by default)
  99521. * @param onAnimationEnd defines the callback to call when animation end
  99522. * @returns the animatable created for this animation
  99523. */
  99524. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99525. /**
  99526. * Create and start an animation on a node and its descendants
  99527. * @param name defines the name of the global animation that will be run on all nodes
  99528. * @param node defines the root node where the animation will take place
  99529. * @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
  99530. * @param targetProperty defines property to animate
  99531. * @param framePerSecond defines the number of frame per second to use
  99532. * @param totalFrame defines the number of frames in total
  99533. * @param from defines the initial value
  99534. * @param to defines the final value
  99535. * @param loopMode defines which loop mode you want to use (off by default)
  99536. * @param easingFunction defines the easing function to use (linear by default)
  99537. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  99538. * @returns the list of animatables created for all nodes
  99539. * @example https://www.babylonjs-playground.com/#MH0VLI
  99540. */
  99541. 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[]>;
  99542. /**
  99543. * Creates a new animation, merges it with the existing animations and starts it
  99544. * @param name Name of the animation
  99545. * @param node Node which contains the scene that begins the animations
  99546. * @param targetProperty Specifies which property to animate
  99547. * @param framePerSecond The frames per second of the animation
  99548. * @param totalFrame The total number of frames
  99549. * @param from The frame at the beginning of the animation
  99550. * @param to The frame at the end of the animation
  99551. * @param loopMode Specifies the loop mode of the animation
  99552. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  99553. * @param onAnimationEnd Callback to run once the animation is complete
  99554. * @returns Nullable animation
  99555. */
  99556. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99557. /**
  99558. * Transition property of an host to the target Value
  99559. * @param property The property to transition
  99560. * @param targetValue The target Value of the property
  99561. * @param host The object where the property to animate belongs
  99562. * @param scene Scene used to run the animation
  99563. * @param frameRate Framerate (in frame/s) to use
  99564. * @param transition The transition type we want to use
  99565. * @param duration The duration of the animation, in milliseconds
  99566. * @param onAnimationEnd Callback trigger at the end of the animation
  99567. * @returns Nullable animation
  99568. */
  99569. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  99570. /**
  99571. * Return the array of runtime animations currently using this animation
  99572. */
  99573. get runtimeAnimations(): RuntimeAnimation[];
  99574. /**
  99575. * Specifies if any of the runtime animations are currently running
  99576. */
  99577. get hasRunningRuntimeAnimations(): boolean;
  99578. /**
  99579. * Initializes the animation
  99580. * @param name Name of the animation
  99581. * @param targetProperty Property to animate
  99582. * @param framePerSecond The frames per second of the animation
  99583. * @param dataType The data type of the animation
  99584. * @param loopMode The loop mode of the animation
  99585. * @param enableBlending Specifies if blending should be enabled
  99586. */
  99587. constructor(
  99588. /**Name of the animation */
  99589. name: string,
  99590. /**Property to animate */
  99591. targetProperty: string,
  99592. /**The frames per second of the animation */
  99593. framePerSecond: number,
  99594. /**The data type of the animation */
  99595. dataType: number,
  99596. /**The loop mode of the animation */
  99597. loopMode?: number | undefined,
  99598. /**Specifies if blending should be enabled */
  99599. enableBlending?: boolean | undefined);
  99600. /**
  99601. * Converts the animation to a string
  99602. * @param fullDetails support for multiple levels of logging within scene loading
  99603. * @returns String form of the animation
  99604. */
  99605. toString(fullDetails?: boolean): string;
  99606. /**
  99607. * Add an event to this animation
  99608. * @param event Event to add
  99609. */
  99610. addEvent(event: AnimationEvent): void;
  99611. /**
  99612. * Remove all events found at the given frame
  99613. * @param frame The frame to remove events from
  99614. */
  99615. removeEvents(frame: number): void;
  99616. /**
  99617. * Retrieves all the events from the animation
  99618. * @returns Events from the animation
  99619. */
  99620. getEvents(): AnimationEvent[];
  99621. /**
  99622. * Creates an animation range
  99623. * @param name Name of the animation range
  99624. * @param from Starting frame of the animation range
  99625. * @param to Ending frame of the animation
  99626. */
  99627. createRange(name: string, from: number, to: number): void;
  99628. /**
  99629. * Deletes an animation range by name
  99630. * @param name Name of the animation range to delete
  99631. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  99632. */
  99633. deleteRange(name: string, deleteFrames?: boolean): void;
  99634. /**
  99635. * Gets the animation range by name, or null if not defined
  99636. * @param name Name of the animation range
  99637. * @returns Nullable animation range
  99638. */
  99639. getRange(name: string): Nullable<AnimationRange>;
  99640. /**
  99641. * Gets the key frames from the animation
  99642. * @returns The key frames of the animation
  99643. */
  99644. getKeys(): Array<IAnimationKey>;
  99645. /**
  99646. * Gets the highest frame rate of the animation
  99647. * @returns Highest frame rate of the animation
  99648. */
  99649. getHighestFrame(): number;
  99650. /**
  99651. * Gets the easing function of the animation
  99652. * @returns Easing function of the animation
  99653. */
  99654. getEasingFunction(): IEasingFunction;
  99655. /**
  99656. * Sets the easing function of the animation
  99657. * @param easingFunction A custom mathematical formula for animation
  99658. */
  99659. setEasingFunction(easingFunction: EasingFunction): void;
  99660. /**
  99661. * Interpolates a scalar linearly
  99662. * @param startValue Start value of the animation curve
  99663. * @param endValue End value of the animation curve
  99664. * @param gradient Scalar amount to interpolate
  99665. * @returns Interpolated scalar value
  99666. */
  99667. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  99668. /**
  99669. * Interpolates a scalar cubically
  99670. * @param startValue Start value of the animation curve
  99671. * @param outTangent End tangent of the animation
  99672. * @param endValue End value of the animation curve
  99673. * @param inTangent Start tangent of the animation curve
  99674. * @param gradient Scalar amount to interpolate
  99675. * @returns Interpolated scalar value
  99676. */
  99677. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  99678. /**
  99679. * Interpolates a quaternion using a spherical linear interpolation
  99680. * @param startValue Start value of the animation curve
  99681. * @param endValue End value of the animation curve
  99682. * @param gradient Scalar amount to interpolate
  99683. * @returns Interpolated quaternion value
  99684. */
  99685. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  99686. /**
  99687. * Interpolates a quaternion cubically
  99688. * @param startValue Start value of the animation curve
  99689. * @param outTangent End tangent of the animation curve
  99690. * @param endValue End value of the animation curve
  99691. * @param inTangent Start tangent of the animation curve
  99692. * @param gradient Scalar amount to interpolate
  99693. * @returns Interpolated quaternion value
  99694. */
  99695. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  99696. /**
  99697. * Interpolates a Vector3 linearl
  99698. * @param startValue Start value of the animation curve
  99699. * @param endValue End value of the animation curve
  99700. * @param gradient Scalar amount to interpolate
  99701. * @returns Interpolated scalar value
  99702. */
  99703. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  99704. /**
  99705. * Interpolates a Vector3 cubically
  99706. * @param startValue Start value of the animation curve
  99707. * @param outTangent End tangent of the animation
  99708. * @param endValue End value of the animation curve
  99709. * @param inTangent Start tangent of the animation curve
  99710. * @param gradient Scalar amount to interpolate
  99711. * @returns InterpolatedVector3 value
  99712. */
  99713. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  99714. /**
  99715. * Interpolates a Vector2 linearly
  99716. * @param startValue Start value of the animation curve
  99717. * @param endValue End value of the animation curve
  99718. * @param gradient Scalar amount to interpolate
  99719. * @returns Interpolated Vector2 value
  99720. */
  99721. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  99722. /**
  99723. * Interpolates a Vector2 cubically
  99724. * @param startValue Start value of the animation curve
  99725. * @param outTangent End tangent of the animation
  99726. * @param endValue End value of the animation curve
  99727. * @param inTangent Start tangent of the animation curve
  99728. * @param gradient Scalar amount to interpolate
  99729. * @returns Interpolated Vector2 value
  99730. */
  99731. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  99732. /**
  99733. * Interpolates a size linearly
  99734. * @param startValue Start value of the animation curve
  99735. * @param endValue End value of the animation curve
  99736. * @param gradient Scalar amount to interpolate
  99737. * @returns Interpolated Size value
  99738. */
  99739. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  99740. /**
  99741. * Interpolates a Color3 linearly
  99742. * @param startValue Start value of the animation curve
  99743. * @param endValue End value of the animation curve
  99744. * @param gradient Scalar amount to interpolate
  99745. * @returns Interpolated Color3 value
  99746. */
  99747. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  99748. /**
  99749. * Interpolates a Color4 linearly
  99750. * @param startValue Start value of the animation curve
  99751. * @param endValue End value of the animation curve
  99752. * @param gradient Scalar amount to interpolate
  99753. * @returns Interpolated Color3 value
  99754. */
  99755. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  99756. /**
  99757. * @hidden Internal use only
  99758. */
  99759. _getKeyValue(value: any): any;
  99760. /**
  99761. * @hidden Internal use only
  99762. */
  99763. _interpolate(currentFrame: number, state: _IAnimationState): any;
  99764. /**
  99765. * Defines the function to use to interpolate matrices
  99766. * @param startValue defines the start matrix
  99767. * @param endValue defines the end matrix
  99768. * @param gradient defines the gradient between both matrices
  99769. * @param result defines an optional target matrix where to store the interpolation
  99770. * @returns the interpolated matrix
  99771. */
  99772. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  99773. /**
  99774. * Makes a copy of the animation
  99775. * @returns Cloned animation
  99776. */
  99777. clone(): Animation;
  99778. /**
  99779. * Sets the key frames of the animation
  99780. * @param values The animation key frames to set
  99781. */
  99782. setKeys(values: Array<IAnimationKey>): void;
  99783. /**
  99784. * Serializes the animation to an object
  99785. * @returns Serialized object
  99786. */
  99787. serialize(): any;
  99788. /**
  99789. * Float animation type
  99790. */
  99791. static readonly ANIMATIONTYPE_FLOAT: number;
  99792. /**
  99793. * Vector3 animation type
  99794. */
  99795. static readonly ANIMATIONTYPE_VECTOR3: number;
  99796. /**
  99797. * Quaternion animation type
  99798. */
  99799. static readonly ANIMATIONTYPE_QUATERNION: number;
  99800. /**
  99801. * Matrix animation type
  99802. */
  99803. static readonly ANIMATIONTYPE_MATRIX: number;
  99804. /**
  99805. * Color3 animation type
  99806. */
  99807. static readonly ANIMATIONTYPE_COLOR3: number;
  99808. /**
  99809. * Color3 animation type
  99810. */
  99811. static readonly ANIMATIONTYPE_COLOR4: number;
  99812. /**
  99813. * Vector2 animation type
  99814. */
  99815. static readonly ANIMATIONTYPE_VECTOR2: number;
  99816. /**
  99817. * Size animation type
  99818. */
  99819. static readonly ANIMATIONTYPE_SIZE: number;
  99820. /**
  99821. * Relative Loop Mode
  99822. */
  99823. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  99824. /**
  99825. * Cycle Loop Mode
  99826. */
  99827. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  99828. /**
  99829. * Constant Loop Mode
  99830. */
  99831. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  99832. /** @hidden */
  99833. static _UniversalLerp(left: any, right: any, amount: number): any;
  99834. /**
  99835. * Parses an animation object and creates an animation
  99836. * @param parsedAnimation Parsed animation object
  99837. * @returns Animation object
  99838. */
  99839. static Parse(parsedAnimation: any): Animation;
  99840. /**
  99841. * Appends the serialized animations from the source animations
  99842. * @param source Source containing the animations
  99843. * @param destination Target to store the animations
  99844. */
  99845. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99846. }
  99847. }
  99848. declare module BABYLON {
  99849. /**
  99850. * Interface containing an array of animations
  99851. */
  99852. export interface IAnimatable {
  99853. /**
  99854. * Array of animations
  99855. */
  99856. animations: Nullable<Array<Animation>>;
  99857. }
  99858. }
  99859. declare module BABYLON {
  99860. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  99861. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99862. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99863. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99864. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99865. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99866. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99867. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99868. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99869. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99870. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99871. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99872. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99873. /**
  99874. * Decorator used to define property that can be serialized as reference to a camera
  99875. * @param sourceName defines the name of the property to decorate
  99876. */
  99877. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99878. /**
  99879. * Class used to help serialization objects
  99880. */
  99881. export class SerializationHelper {
  99882. /** @hidden */
  99883. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  99884. /** @hidden */
  99885. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  99886. /** @hidden */
  99887. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  99888. /** @hidden */
  99889. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  99890. /**
  99891. * Appends the serialized animations from the source animations
  99892. * @param source Source containing the animations
  99893. * @param destination Target to store the animations
  99894. */
  99895. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99896. /**
  99897. * Static function used to serialized a specific entity
  99898. * @param entity defines the entity to serialize
  99899. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  99900. * @returns a JSON compatible object representing the serialization of the entity
  99901. */
  99902. static Serialize<T>(entity: T, serializationObject?: any): any;
  99903. /**
  99904. * Creates a new entity from a serialization data object
  99905. * @param creationFunction defines a function used to instanciated the new entity
  99906. * @param source defines the source serialization data
  99907. * @param scene defines the hosting scene
  99908. * @param rootUrl defines the root url for resources
  99909. * @returns a new entity
  99910. */
  99911. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  99912. /**
  99913. * Clones an object
  99914. * @param creationFunction defines the function used to instanciate the new object
  99915. * @param source defines the source object
  99916. * @returns the cloned object
  99917. */
  99918. static Clone<T>(creationFunction: () => T, source: T): T;
  99919. /**
  99920. * Instanciates a new object based on a source one (some data will be shared between both object)
  99921. * @param creationFunction defines the function used to instanciate the new object
  99922. * @param source defines the source object
  99923. * @returns the new object
  99924. */
  99925. static Instanciate<T>(creationFunction: () => T, source: T): T;
  99926. }
  99927. }
  99928. declare module BABYLON {
  99929. /**
  99930. * Class used to manipulate GUIDs
  99931. */
  99932. export class GUID {
  99933. /**
  99934. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99935. * Be aware Math.random() could cause collisions, but:
  99936. * "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"
  99937. * @returns a pseudo random id
  99938. */
  99939. static RandomId(): string;
  99940. }
  99941. }
  99942. declare module BABYLON {
  99943. /**
  99944. * Base class of all the textures in babylon.
  99945. * It groups all the common properties the materials, post process, lights... might need
  99946. * in order to make a correct use of the texture.
  99947. */
  99948. export class BaseTexture implements IAnimatable {
  99949. /**
  99950. * Default anisotropic filtering level for the application.
  99951. * It is set to 4 as a good tradeoff between perf and quality.
  99952. */
  99953. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  99954. /**
  99955. * Gets or sets the unique id of the texture
  99956. */
  99957. uniqueId: number;
  99958. /**
  99959. * Define the name of the texture.
  99960. */
  99961. name: string;
  99962. /**
  99963. * Gets or sets an object used to store user defined information.
  99964. */
  99965. metadata: any;
  99966. /**
  99967. * For internal use only. Please do not use.
  99968. */
  99969. reservedDataStore: any;
  99970. private _hasAlpha;
  99971. /**
  99972. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  99973. */
  99974. set hasAlpha(value: boolean);
  99975. get hasAlpha(): boolean;
  99976. /**
  99977. * Defines if the alpha value should be determined via the rgb values.
  99978. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  99979. */
  99980. getAlphaFromRGB: boolean;
  99981. /**
  99982. * Intensity or strength of the texture.
  99983. * It is commonly used by materials to fine tune the intensity of the texture
  99984. */
  99985. level: number;
  99986. /**
  99987. * Define the UV chanel to use starting from 0 and defaulting to 0.
  99988. * This is part of the texture as textures usually maps to one uv set.
  99989. */
  99990. coordinatesIndex: number;
  99991. private _coordinatesMode;
  99992. /**
  99993. * How a texture is mapped.
  99994. *
  99995. * | Value | Type | Description |
  99996. * | ----- | ----------------------------------- | ----------- |
  99997. * | 0 | EXPLICIT_MODE | |
  99998. * | 1 | SPHERICAL_MODE | |
  99999. * | 2 | PLANAR_MODE | |
  100000. * | 3 | CUBIC_MODE | |
  100001. * | 4 | PROJECTION_MODE | |
  100002. * | 5 | SKYBOX_MODE | |
  100003. * | 6 | INVCUBIC_MODE | |
  100004. * | 7 | EQUIRECTANGULAR_MODE | |
  100005. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  100006. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  100007. */
  100008. set coordinatesMode(value: number);
  100009. get coordinatesMode(): number;
  100010. /**
  100011. * | Value | Type | Description |
  100012. * | ----- | ------------------ | ----------- |
  100013. * | 0 | CLAMP_ADDRESSMODE | |
  100014. * | 1 | WRAP_ADDRESSMODE | |
  100015. * | 2 | MIRROR_ADDRESSMODE | |
  100016. */
  100017. wrapU: number;
  100018. /**
  100019. * | Value | Type | Description |
  100020. * | ----- | ------------------ | ----------- |
  100021. * | 0 | CLAMP_ADDRESSMODE | |
  100022. * | 1 | WRAP_ADDRESSMODE | |
  100023. * | 2 | MIRROR_ADDRESSMODE | |
  100024. */
  100025. wrapV: number;
  100026. /**
  100027. * | Value | Type | Description |
  100028. * | ----- | ------------------ | ----------- |
  100029. * | 0 | CLAMP_ADDRESSMODE | |
  100030. * | 1 | WRAP_ADDRESSMODE | |
  100031. * | 2 | MIRROR_ADDRESSMODE | |
  100032. */
  100033. wrapR: number;
  100034. /**
  100035. * With compliant hardware and browser (supporting anisotropic filtering)
  100036. * this defines the level of anisotropic filtering in the texture.
  100037. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100038. */
  100039. anisotropicFilteringLevel: number;
  100040. /**
  100041. * Define if the texture is a cube texture or if false a 2d texture.
  100042. */
  100043. get isCube(): boolean;
  100044. set isCube(value: boolean);
  100045. /**
  100046. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100047. */
  100048. get is3D(): boolean;
  100049. set is3D(value: boolean);
  100050. /**
  100051. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100052. */
  100053. get is2DArray(): boolean;
  100054. set is2DArray(value: boolean);
  100055. /**
  100056. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100057. * HDR texture are usually stored in linear space.
  100058. * This only impacts the PBR and Background materials
  100059. */
  100060. gammaSpace: boolean;
  100061. /**
  100062. * Gets or sets whether or not the texture contains RGBD data.
  100063. */
  100064. get isRGBD(): boolean;
  100065. set isRGBD(value: boolean);
  100066. /**
  100067. * Is Z inverted in the texture (useful in a cube texture).
  100068. */
  100069. invertZ: boolean;
  100070. /**
  100071. * Are mip maps generated for this texture or not.
  100072. */
  100073. get noMipmap(): boolean;
  100074. /**
  100075. * @hidden
  100076. */
  100077. lodLevelInAlpha: boolean;
  100078. /**
  100079. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100080. */
  100081. get lodGenerationOffset(): number;
  100082. set lodGenerationOffset(value: number);
  100083. /**
  100084. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100085. */
  100086. get lodGenerationScale(): number;
  100087. set lodGenerationScale(value: number);
  100088. /**
  100089. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100090. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100091. * average roughness values.
  100092. */
  100093. get linearSpecularLOD(): boolean;
  100094. set linearSpecularLOD(value: boolean);
  100095. /**
  100096. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100097. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100098. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100099. */
  100100. get irradianceTexture(): Nullable<BaseTexture>;
  100101. set irradianceTexture(value: Nullable<BaseTexture>);
  100102. /**
  100103. * Define if the texture is a render target.
  100104. */
  100105. isRenderTarget: boolean;
  100106. /**
  100107. * Define the unique id of the texture in the scene.
  100108. */
  100109. get uid(): string;
  100110. /**
  100111. * Return a string representation of the texture.
  100112. * @returns the texture as a string
  100113. */
  100114. toString(): string;
  100115. /**
  100116. * Get the class name of the texture.
  100117. * @returns "BaseTexture"
  100118. */
  100119. getClassName(): string;
  100120. /**
  100121. * Define the list of animation attached to the texture.
  100122. */
  100123. animations: Animation[];
  100124. /**
  100125. * An event triggered when the texture is disposed.
  100126. */
  100127. onDisposeObservable: Observable<BaseTexture>;
  100128. private _onDisposeObserver;
  100129. /**
  100130. * Callback triggered when the texture has been disposed.
  100131. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100132. */
  100133. set onDispose(callback: () => void);
  100134. /**
  100135. * Define the current state of the loading sequence when in delayed load mode.
  100136. */
  100137. delayLoadState: number;
  100138. private _scene;
  100139. /** @hidden */
  100140. _texture: Nullable<InternalTexture>;
  100141. private _uid;
  100142. /**
  100143. * Define if the texture is preventinga material to render or not.
  100144. * If not and the texture is not ready, the engine will use a default black texture instead.
  100145. */
  100146. get isBlocking(): boolean;
  100147. /**
  100148. * Instantiates a new BaseTexture.
  100149. * Base class of all the textures in babylon.
  100150. * It groups all the common properties the materials, post process, lights... might need
  100151. * in order to make a correct use of the texture.
  100152. * @param scene Define the scene the texture blongs to
  100153. */
  100154. constructor(scene: Nullable<Scene>);
  100155. /**
  100156. * Get the scene the texture belongs to.
  100157. * @returns the scene or null if undefined
  100158. */
  100159. getScene(): Nullable<Scene>;
  100160. /**
  100161. * Get the texture transform matrix used to offset tile the texture for istance.
  100162. * @returns the transformation matrix
  100163. */
  100164. getTextureMatrix(): Matrix;
  100165. /**
  100166. * Get the texture reflection matrix used to rotate/transform the reflection.
  100167. * @returns the reflection matrix
  100168. */
  100169. getReflectionTextureMatrix(): Matrix;
  100170. /**
  100171. * Get the underlying lower level texture from Babylon.
  100172. * @returns the insternal texture
  100173. */
  100174. getInternalTexture(): Nullable<InternalTexture>;
  100175. /**
  100176. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100177. * @returns true if ready or not blocking
  100178. */
  100179. isReadyOrNotBlocking(): boolean;
  100180. /**
  100181. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  100182. * @returns true if fully ready
  100183. */
  100184. isReady(): boolean;
  100185. private _cachedSize;
  100186. /**
  100187. * Get the size of the texture.
  100188. * @returns the texture size.
  100189. */
  100190. getSize(): ISize;
  100191. /**
  100192. * Get the base size of the texture.
  100193. * It can be different from the size if the texture has been resized for POT for instance
  100194. * @returns the base size
  100195. */
  100196. getBaseSize(): ISize;
  100197. /**
  100198. * Update the sampling mode of the texture.
  100199. * Default is Trilinear mode.
  100200. *
  100201. * | Value | Type | Description |
  100202. * | ----- | ------------------ | ----------- |
  100203. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  100204. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  100205. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  100206. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  100207. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  100208. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  100209. * | 7 | NEAREST_LINEAR | |
  100210. * | 8 | NEAREST_NEAREST | |
  100211. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  100212. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  100213. * | 11 | LINEAR_LINEAR | |
  100214. * | 12 | LINEAR_NEAREST | |
  100215. *
  100216. * > _mag_: magnification filter (close to the viewer)
  100217. * > _min_: minification filter (far from the viewer)
  100218. * > _mip_: filter used between mip map levels
  100219. *@param samplingMode Define the new sampling mode of the texture
  100220. */
  100221. updateSamplingMode(samplingMode: number): void;
  100222. /**
  100223. * Scales the texture if is `canRescale()`
  100224. * @param ratio the resize factor we want to use to rescale
  100225. */
  100226. scale(ratio: number): void;
  100227. /**
  100228. * Get if the texture can rescale.
  100229. */
  100230. get canRescale(): boolean;
  100231. /** @hidden */
  100232. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  100233. /** @hidden */
  100234. _rebuild(): void;
  100235. /**
  100236. * Triggers the load sequence in delayed load mode.
  100237. */
  100238. delayLoad(): void;
  100239. /**
  100240. * Clones the texture.
  100241. * @returns the cloned texture
  100242. */
  100243. clone(): Nullable<BaseTexture>;
  100244. /**
  100245. * Get the texture underlying type (INT, FLOAT...)
  100246. */
  100247. get textureType(): number;
  100248. /**
  100249. * Get the texture underlying format (RGB, RGBA...)
  100250. */
  100251. get textureFormat(): number;
  100252. /**
  100253. * Indicates that textures need to be re-calculated for all materials
  100254. */
  100255. protected _markAllSubMeshesAsTexturesDirty(): void;
  100256. /**
  100257. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  100258. * This will returns an RGBA array buffer containing either in values (0-255) or
  100259. * float values (0-1) depending of the underlying buffer type.
  100260. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  100261. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  100262. * @param buffer defines a user defined buffer to fill with data (can be null)
  100263. * @returns The Array buffer containing the pixels data.
  100264. */
  100265. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  100266. /**
  100267. * Release and destroy the underlying lower level texture aka internalTexture.
  100268. */
  100269. releaseInternalTexture(): void;
  100270. /** @hidden */
  100271. get _lodTextureHigh(): Nullable<BaseTexture>;
  100272. /** @hidden */
  100273. get _lodTextureMid(): Nullable<BaseTexture>;
  100274. /** @hidden */
  100275. get _lodTextureLow(): Nullable<BaseTexture>;
  100276. /**
  100277. * Dispose the texture and release its associated resources.
  100278. */
  100279. dispose(): void;
  100280. /**
  100281. * Serialize the texture into a JSON representation that can be parsed later on.
  100282. * @returns the JSON representation of the texture
  100283. */
  100284. serialize(): any;
  100285. /**
  100286. * Helper function to be called back once a list of texture contains only ready textures.
  100287. * @param textures Define the list of textures to wait for
  100288. * @param callback Define the callback triggered once the entire list will be ready
  100289. */
  100290. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  100291. }
  100292. }
  100293. declare module BABYLON {
  100294. /**
  100295. * Options to be used when creating an effect.
  100296. */
  100297. export interface IEffectCreationOptions {
  100298. /**
  100299. * Atrributes that will be used in the shader.
  100300. */
  100301. attributes: string[];
  100302. /**
  100303. * Uniform varible names that will be set in the shader.
  100304. */
  100305. uniformsNames: string[];
  100306. /**
  100307. * Uniform buffer variable names that will be set in the shader.
  100308. */
  100309. uniformBuffersNames: string[];
  100310. /**
  100311. * Sampler texture variable names that will be set in the shader.
  100312. */
  100313. samplers: string[];
  100314. /**
  100315. * Define statements that will be set in the shader.
  100316. */
  100317. defines: any;
  100318. /**
  100319. * Possible fallbacks for this effect to improve performance when needed.
  100320. */
  100321. fallbacks: Nullable<IEffectFallbacks>;
  100322. /**
  100323. * Callback that will be called when the shader is compiled.
  100324. */
  100325. onCompiled: Nullable<(effect: Effect) => void>;
  100326. /**
  100327. * Callback that will be called if an error occurs during shader compilation.
  100328. */
  100329. onError: Nullable<(effect: Effect, errors: string) => void>;
  100330. /**
  100331. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100332. */
  100333. indexParameters?: any;
  100334. /**
  100335. * Max number of lights that can be used in the shader.
  100336. */
  100337. maxSimultaneousLights?: number;
  100338. /**
  100339. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  100340. */
  100341. transformFeedbackVaryings?: Nullable<string[]>;
  100342. }
  100343. /**
  100344. * Effect containing vertex and fragment shader that can be executed on an object.
  100345. */
  100346. export class Effect implements IDisposable {
  100347. /**
  100348. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  100349. */
  100350. static ShadersRepository: string;
  100351. /**
  100352. * Name of the effect.
  100353. */
  100354. name: any;
  100355. /**
  100356. * String container all the define statements that should be set on the shader.
  100357. */
  100358. defines: string;
  100359. /**
  100360. * Callback that will be called when the shader is compiled.
  100361. */
  100362. onCompiled: Nullable<(effect: Effect) => void>;
  100363. /**
  100364. * Callback that will be called if an error occurs during shader compilation.
  100365. */
  100366. onError: Nullable<(effect: Effect, errors: string) => void>;
  100367. /**
  100368. * Callback that will be called when effect is bound.
  100369. */
  100370. onBind: Nullable<(effect: Effect) => void>;
  100371. /**
  100372. * Unique ID of the effect.
  100373. */
  100374. uniqueId: number;
  100375. /**
  100376. * Observable that will be called when the shader is compiled.
  100377. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  100378. */
  100379. onCompileObservable: Observable<Effect>;
  100380. /**
  100381. * Observable that will be called if an error occurs during shader compilation.
  100382. */
  100383. onErrorObservable: Observable<Effect>;
  100384. /** @hidden */
  100385. _onBindObservable: Nullable<Observable<Effect>>;
  100386. /**
  100387. * Observable that will be called when effect is bound.
  100388. */
  100389. get onBindObservable(): Observable<Effect>;
  100390. /** @hidden */
  100391. _bonesComputationForcedToCPU: boolean;
  100392. private static _uniqueIdSeed;
  100393. private _engine;
  100394. private _uniformBuffersNames;
  100395. private _uniformsNames;
  100396. private _samplerList;
  100397. private _samplers;
  100398. private _isReady;
  100399. private _compilationError;
  100400. private _allFallbacksProcessed;
  100401. private _attributesNames;
  100402. private _attributes;
  100403. private _attributeLocationByName;
  100404. private _uniforms;
  100405. /**
  100406. * Key for the effect.
  100407. * @hidden
  100408. */
  100409. _key: string;
  100410. private _indexParameters;
  100411. private _fallbacks;
  100412. private _vertexSourceCode;
  100413. private _fragmentSourceCode;
  100414. private _vertexSourceCodeOverride;
  100415. private _fragmentSourceCodeOverride;
  100416. private _transformFeedbackVaryings;
  100417. /**
  100418. * Compiled shader to webGL program.
  100419. * @hidden
  100420. */
  100421. _pipelineContext: Nullable<IPipelineContext>;
  100422. private _valueCache;
  100423. private static _baseCache;
  100424. /**
  100425. * Instantiates an effect.
  100426. * An effect can be used to create/manage/execute vertex and fragment shaders.
  100427. * @param baseName Name of the effect.
  100428. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  100429. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  100430. * @param samplers List of sampler variables that will be passed to the shader.
  100431. * @param engine Engine to be used to render the effect
  100432. * @param defines Define statements to be added to the shader.
  100433. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  100434. * @param onCompiled Callback that will be called when the shader is compiled.
  100435. * @param onError Callback that will be called if an error occurs during shader compilation.
  100436. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100437. */
  100438. 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);
  100439. private _useFinalCode;
  100440. /**
  100441. * Unique key for this effect
  100442. */
  100443. get key(): string;
  100444. /**
  100445. * If the effect has been compiled and prepared.
  100446. * @returns if the effect is compiled and prepared.
  100447. */
  100448. isReady(): boolean;
  100449. private _isReadyInternal;
  100450. /**
  100451. * The engine the effect was initialized with.
  100452. * @returns the engine.
  100453. */
  100454. getEngine(): Engine;
  100455. /**
  100456. * The pipeline context for this effect
  100457. * @returns the associated pipeline context
  100458. */
  100459. getPipelineContext(): Nullable<IPipelineContext>;
  100460. /**
  100461. * The set of names of attribute variables for the shader.
  100462. * @returns An array of attribute names.
  100463. */
  100464. getAttributesNames(): string[];
  100465. /**
  100466. * Returns the attribute at the given index.
  100467. * @param index The index of the attribute.
  100468. * @returns The location of the attribute.
  100469. */
  100470. getAttributeLocation(index: number): number;
  100471. /**
  100472. * Returns the attribute based on the name of the variable.
  100473. * @param name of the attribute to look up.
  100474. * @returns the attribute location.
  100475. */
  100476. getAttributeLocationByName(name: string): number;
  100477. /**
  100478. * The number of attributes.
  100479. * @returns the numnber of attributes.
  100480. */
  100481. getAttributesCount(): number;
  100482. /**
  100483. * Gets the index of a uniform variable.
  100484. * @param uniformName of the uniform to look up.
  100485. * @returns the index.
  100486. */
  100487. getUniformIndex(uniformName: string): number;
  100488. /**
  100489. * Returns the attribute based on the name of the variable.
  100490. * @param uniformName of the uniform to look up.
  100491. * @returns the location of the uniform.
  100492. */
  100493. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  100494. /**
  100495. * Returns an array of sampler variable names
  100496. * @returns The array of sampler variable neames.
  100497. */
  100498. getSamplers(): string[];
  100499. /**
  100500. * The error from the last compilation.
  100501. * @returns the error string.
  100502. */
  100503. getCompilationError(): string;
  100504. /**
  100505. * Gets a boolean indicating that all fallbacks were used during compilation
  100506. * @returns true if all fallbacks were used
  100507. */
  100508. allFallbacksProcessed(): boolean;
  100509. /**
  100510. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  100511. * @param func The callback to be used.
  100512. */
  100513. executeWhenCompiled(func: (effect: Effect) => void): void;
  100514. private _checkIsReady;
  100515. private _loadShader;
  100516. /**
  100517. * Recompiles the webGL program
  100518. * @param vertexSourceCode The source code for the vertex shader.
  100519. * @param fragmentSourceCode The source code for the fragment shader.
  100520. * @param onCompiled Callback called when completed.
  100521. * @param onError Callback called on error.
  100522. * @hidden
  100523. */
  100524. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  100525. /**
  100526. * Prepares the effect
  100527. * @hidden
  100528. */
  100529. _prepareEffect(): void;
  100530. private _processCompilationErrors;
  100531. /**
  100532. * Checks if the effect is supported. (Must be called after compilation)
  100533. */
  100534. get isSupported(): boolean;
  100535. /**
  100536. * Binds a texture to the engine to be used as output of the shader.
  100537. * @param channel Name of the output variable.
  100538. * @param texture Texture to bind.
  100539. * @hidden
  100540. */
  100541. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  100542. /**
  100543. * Sets a texture on the engine to be used in the shader.
  100544. * @param channel Name of the sampler variable.
  100545. * @param texture Texture to set.
  100546. */
  100547. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  100548. /**
  100549. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  100550. * @param channel Name of the sampler variable.
  100551. * @param texture Texture to set.
  100552. */
  100553. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  100554. /**
  100555. * Sets an array of textures on the engine to be used in the shader.
  100556. * @param channel Name of the variable.
  100557. * @param textures Textures to set.
  100558. */
  100559. setTextureArray(channel: string, textures: BaseTexture[]): void;
  100560. /**
  100561. * 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)
  100562. * @param channel Name of the sampler variable.
  100563. * @param postProcess Post process to get the input texture from.
  100564. */
  100565. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  100566. /**
  100567. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  100568. * 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)
  100569. * @param channel Name of the sampler variable.
  100570. * @param postProcess Post process to get the output texture from.
  100571. */
  100572. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  100573. /** @hidden */
  100574. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  100575. /** @hidden */
  100576. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  100577. /** @hidden */
  100578. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  100579. /** @hidden */
  100580. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  100581. /**
  100582. * Binds a buffer to a uniform.
  100583. * @param buffer Buffer to bind.
  100584. * @param name Name of the uniform variable to bind to.
  100585. */
  100586. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  100587. /**
  100588. * Binds block to a uniform.
  100589. * @param blockName Name of the block to bind.
  100590. * @param index Index to bind.
  100591. */
  100592. bindUniformBlock(blockName: string, index: number): void;
  100593. /**
  100594. * Sets an interger value on a uniform variable.
  100595. * @param uniformName Name of the variable.
  100596. * @param value Value to be set.
  100597. * @returns this effect.
  100598. */
  100599. setInt(uniformName: string, value: number): Effect;
  100600. /**
  100601. * Sets an int array on a uniform variable.
  100602. * @param uniformName Name of the variable.
  100603. * @param array array to be set.
  100604. * @returns this effect.
  100605. */
  100606. setIntArray(uniformName: string, array: Int32Array): Effect;
  100607. /**
  100608. * 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)
  100609. * @param uniformName Name of the variable.
  100610. * @param array array to be set.
  100611. * @returns this effect.
  100612. */
  100613. setIntArray2(uniformName: string, array: Int32Array): Effect;
  100614. /**
  100615. * 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)
  100616. * @param uniformName Name of the variable.
  100617. * @param array array to be set.
  100618. * @returns this effect.
  100619. */
  100620. setIntArray3(uniformName: string, array: Int32Array): Effect;
  100621. /**
  100622. * 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)
  100623. * @param uniformName Name of the variable.
  100624. * @param array array to be set.
  100625. * @returns this effect.
  100626. */
  100627. setIntArray4(uniformName: string, array: Int32Array): Effect;
  100628. /**
  100629. * Sets an float array on a uniform variable.
  100630. * @param uniformName Name of the variable.
  100631. * @param array array to be set.
  100632. * @returns this effect.
  100633. */
  100634. setFloatArray(uniformName: string, array: Float32Array): Effect;
  100635. /**
  100636. * 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)
  100637. * @param uniformName Name of the variable.
  100638. * @param array array to be set.
  100639. * @returns this effect.
  100640. */
  100641. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  100642. /**
  100643. * 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)
  100644. * @param uniformName Name of the variable.
  100645. * @param array array to be set.
  100646. * @returns this effect.
  100647. */
  100648. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  100649. /**
  100650. * 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)
  100651. * @param uniformName Name of the variable.
  100652. * @param array array to be set.
  100653. * @returns this effect.
  100654. */
  100655. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  100656. /**
  100657. * Sets an array on a uniform variable.
  100658. * @param uniformName Name of the variable.
  100659. * @param array array to be set.
  100660. * @returns this effect.
  100661. */
  100662. setArray(uniformName: string, array: number[]): Effect;
  100663. /**
  100664. * 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)
  100665. * @param uniformName Name of the variable.
  100666. * @param array array to be set.
  100667. * @returns this effect.
  100668. */
  100669. setArray2(uniformName: string, array: number[]): Effect;
  100670. /**
  100671. * 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)
  100672. * @param uniformName Name of the variable.
  100673. * @param array array to be set.
  100674. * @returns this effect.
  100675. */
  100676. setArray3(uniformName: string, array: number[]): Effect;
  100677. /**
  100678. * 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)
  100679. * @param uniformName Name of the variable.
  100680. * @param array array to be set.
  100681. * @returns this effect.
  100682. */
  100683. setArray4(uniformName: string, array: number[]): Effect;
  100684. /**
  100685. * Sets matrices on a uniform variable.
  100686. * @param uniformName Name of the variable.
  100687. * @param matrices matrices to be set.
  100688. * @returns this effect.
  100689. */
  100690. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  100691. /**
  100692. * Sets matrix on a uniform variable.
  100693. * @param uniformName Name of the variable.
  100694. * @param matrix matrix to be set.
  100695. * @returns this effect.
  100696. */
  100697. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  100698. /**
  100699. * 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)
  100700. * @param uniformName Name of the variable.
  100701. * @param matrix matrix to be set.
  100702. * @returns this effect.
  100703. */
  100704. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  100705. /**
  100706. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  100707. * @param uniformName Name of the variable.
  100708. * @param matrix matrix to be set.
  100709. * @returns this effect.
  100710. */
  100711. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  100712. /**
  100713. * Sets a float on a uniform variable.
  100714. * @param uniformName Name of the variable.
  100715. * @param value value to be set.
  100716. * @returns this effect.
  100717. */
  100718. setFloat(uniformName: string, value: number): Effect;
  100719. /**
  100720. * Sets a boolean on a uniform variable.
  100721. * @param uniformName Name of the variable.
  100722. * @param bool value to be set.
  100723. * @returns this effect.
  100724. */
  100725. setBool(uniformName: string, bool: boolean): Effect;
  100726. /**
  100727. * Sets a Vector2 on a uniform variable.
  100728. * @param uniformName Name of the variable.
  100729. * @param vector2 vector2 to be set.
  100730. * @returns this effect.
  100731. */
  100732. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  100733. /**
  100734. * Sets a float2 on a uniform variable.
  100735. * @param uniformName Name of the variable.
  100736. * @param x First float in float2.
  100737. * @param y Second float in float2.
  100738. * @returns this effect.
  100739. */
  100740. setFloat2(uniformName: string, x: number, y: number): Effect;
  100741. /**
  100742. * Sets a Vector3 on a uniform variable.
  100743. * @param uniformName Name of the variable.
  100744. * @param vector3 Value to be set.
  100745. * @returns this effect.
  100746. */
  100747. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  100748. /**
  100749. * Sets a float3 on a uniform variable.
  100750. * @param uniformName Name of the variable.
  100751. * @param x First float in float3.
  100752. * @param y Second float in float3.
  100753. * @param z Third float in float3.
  100754. * @returns this effect.
  100755. */
  100756. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  100757. /**
  100758. * Sets a Vector4 on a uniform variable.
  100759. * @param uniformName Name of the variable.
  100760. * @param vector4 Value to be set.
  100761. * @returns this effect.
  100762. */
  100763. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  100764. /**
  100765. * Sets a float4 on a uniform variable.
  100766. * @param uniformName Name of the variable.
  100767. * @param x First float in float4.
  100768. * @param y Second float in float4.
  100769. * @param z Third float in float4.
  100770. * @param w Fourth float in float4.
  100771. * @returns this effect.
  100772. */
  100773. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  100774. /**
  100775. * Sets a Color3 on a uniform variable.
  100776. * @param uniformName Name of the variable.
  100777. * @param color3 Value to be set.
  100778. * @returns this effect.
  100779. */
  100780. setColor3(uniformName: string, color3: IColor3Like): Effect;
  100781. /**
  100782. * Sets a Color4 on a uniform variable.
  100783. * @param uniformName Name of the variable.
  100784. * @param color3 Value to be set.
  100785. * @param alpha Alpha value to be set.
  100786. * @returns this effect.
  100787. */
  100788. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  100789. /**
  100790. * Sets a Color4 on a uniform variable
  100791. * @param uniformName defines the name of the variable
  100792. * @param color4 defines the value to be set
  100793. * @returns this effect.
  100794. */
  100795. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  100796. /** Release all associated resources */
  100797. dispose(): void;
  100798. /**
  100799. * This function will add a new shader to the shader store
  100800. * @param name the name of the shader
  100801. * @param pixelShader optional pixel shader content
  100802. * @param vertexShader optional vertex shader content
  100803. */
  100804. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  100805. /**
  100806. * Store of each shader (The can be looked up using effect.key)
  100807. */
  100808. static ShadersStore: {
  100809. [key: string]: string;
  100810. };
  100811. /**
  100812. * Store of each included file for a shader (The can be looked up using effect.key)
  100813. */
  100814. static IncludesShadersStore: {
  100815. [key: string]: string;
  100816. };
  100817. /**
  100818. * Resets the cache of effects.
  100819. */
  100820. static ResetCache(): void;
  100821. }
  100822. }
  100823. declare module BABYLON {
  100824. /**
  100825. * Interface used to describe the capabilities of the engine relatively to the current browser
  100826. */
  100827. export interface EngineCapabilities {
  100828. /** Maximum textures units per fragment shader */
  100829. maxTexturesImageUnits: number;
  100830. /** Maximum texture units per vertex shader */
  100831. maxVertexTextureImageUnits: number;
  100832. /** Maximum textures units in the entire pipeline */
  100833. maxCombinedTexturesImageUnits: number;
  100834. /** Maximum texture size */
  100835. maxTextureSize: number;
  100836. /** Maximum texture samples */
  100837. maxSamples?: number;
  100838. /** Maximum cube texture size */
  100839. maxCubemapTextureSize: number;
  100840. /** Maximum render texture size */
  100841. maxRenderTextureSize: number;
  100842. /** Maximum number of vertex attributes */
  100843. maxVertexAttribs: number;
  100844. /** Maximum number of varyings */
  100845. maxVaryingVectors: number;
  100846. /** Maximum number of uniforms per vertex shader */
  100847. maxVertexUniformVectors: number;
  100848. /** Maximum number of uniforms per fragment shader */
  100849. maxFragmentUniformVectors: number;
  100850. /** Defines if standard derivates (dx/dy) are supported */
  100851. standardDerivatives: boolean;
  100852. /** Defines if s3tc texture compression is supported */
  100853. s3tc?: WEBGL_compressed_texture_s3tc;
  100854. /** Defines if pvrtc texture compression is supported */
  100855. pvrtc: any;
  100856. /** Defines if etc1 texture compression is supported */
  100857. etc1: any;
  100858. /** Defines if etc2 texture compression is supported */
  100859. etc2: any;
  100860. /** Defines if astc texture compression is supported */
  100861. astc: any;
  100862. /** Defines if float textures are supported */
  100863. textureFloat: boolean;
  100864. /** Defines if vertex array objects are supported */
  100865. vertexArrayObject: boolean;
  100866. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  100867. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  100868. /** Gets the maximum level of anisotropy supported */
  100869. maxAnisotropy: number;
  100870. /** Defines if instancing is supported */
  100871. instancedArrays: boolean;
  100872. /** Defines if 32 bits indices are supported */
  100873. uintIndices: boolean;
  100874. /** Defines if high precision shaders are supported */
  100875. highPrecisionShaderSupported: boolean;
  100876. /** Defines if depth reading in the fragment shader is supported */
  100877. fragmentDepthSupported: boolean;
  100878. /** Defines if float texture linear filtering is supported*/
  100879. textureFloatLinearFiltering: boolean;
  100880. /** Defines if rendering to float textures is supported */
  100881. textureFloatRender: boolean;
  100882. /** Defines if half float textures are supported*/
  100883. textureHalfFloat: boolean;
  100884. /** Defines if half float texture linear filtering is supported*/
  100885. textureHalfFloatLinearFiltering: boolean;
  100886. /** Defines if rendering to half float textures is supported */
  100887. textureHalfFloatRender: boolean;
  100888. /** Defines if textureLOD shader command is supported */
  100889. textureLOD: boolean;
  100890. /** Defines if draw buffers extension is supported */
  100891. drawBuffersExtension: boolean;
  100892. /** Defines if depth textures are supported */
  100893. depthTextureExtension: boolean;
  100894. /** Defines if float color buffer are supported */
  100895. colorBufferFloat: boolean;
  100896. /** Gets disjoint timer query extension (null if not supported) */
  100897. timerQuery?: EXT_disjoint_timer_query;
  100898. /** Defines if timestamp can be used with timer query */
  100899. canUseTimestampForTimerQuery: boolean;
  100900. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  100901. multiview?: any;
  100902. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  100903. oculusMultiview?: any;
  100904. /** Function used to let the system compiles shaders in background */
  100905. parallelShaderCompile?: {
  100906. COMPLETION_STATUS_KHR: number;
  100907. };
  100908. /** Max number of texture samples for MSAA */
  100909. maxMSAASamples: number;
  100910. /** Defines if the blend min max extension is supported */
  100911. blendMinMax: boolean;
  100912. }
  100913. }
  100914. declare module BABYLON {
  100915. /**
  100916. * @hidden
  100917. **/
  100918. export class DepthCullingState {
  100919. private _isDepthTestDirty;
  100920. private _isDepthMaskDirty;
  100921. private _isDepthFuncDirty;
  100922. private _isCullFaceDirty;
  100923. private _isCullDirty;
  100924. private _isZOffsetDirty;
  100925. private _isFrontFaceDirty;
  100926. private _depthTest;
  100927. private _depthMask;
  100928. private _depthFunc;
  100929. private _cull;
  100930. private _cullFace;
  100931. private _zOffset;
  100932. private _frontFace;
  100933. /**
  100934. * Initializes the state.
  100935. */
  100936. constructor();
  100937. get isDirty(): boolean;
  100938. get zOffset(): number;
  100939. set zOffset(value: number);
  100940. get cullFace(): Nullable<number>;
  100941. set cullFace(value: Nullable<number>);
  100942. get cull(): Nullable<boolean>;
  100943. set cull(value: Nullable<boolean>);
  100944. get depthFunc(): Nullable<number>;
  100945. set depthFunc(value: Nullable<number>);
  100946. get depthMask(): boolean;
  100947. set depthMask(value: boolean);
  100948. get depthTest(): boolean;
  100949. set depthTest(value: boolean);
  100950. get frontFace(): Nullable<number>;
  100951. set frontFace(value: Nullable<number>);
  100952. reset(): void;
  100953. apply(gl: WebGLRenderingContext): void;
  100954. }
  100955. }
  100956. declare module BABYLON {
  100957. /**
  100958. * @hidden
  100959. **/
  100960. export class StencilState {
  100961. /** 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 */
  100962. static readonly ALWAYS: number;
  100963. /** Passed to stencilOperation to specify that stencil value must be kept */
  100964. static readonly KEEP: number;
  100965. /** Passed to stencilOperation to specify that stencil value must be replaced */
  100966. static readonly REPLACE: number;
  100967. private _isStencilTestDirty;
  100968. private _isStencilMaskDirty;
  100969. private _isStencilFuncDirty;
  100970. private _isStencilOpDirty;
  100971. private _stencilTest;
  100972. private _stencilMask;
  100973. private _stencilFunc;
  100974. private _stencilFuncRef;
  100975. private _stencilFuncMask;
  100976. private _stencilOpStencilFail;
  100977. private _stencilOpDepthFail;
  100978. private _stencilOpStencilDepthPass;
  100979. get isDirty(): boolean;
  100980. get stencilFunc(): number;
  100981. set stencilFunc(value: number);
  100982. get stencilFuncRef(): number;
  100983. set stencilFuncRef(value: number);
  100984. get stencilFuncMask(): number;
  100985. set stencilFuncMask(value: number);
  100986. get stencilOpStencilFail(): number;
  100987. set stencilOpStencilFail(value: number);
  100988. get stencilOpDepthFail(): number;
  100989. set stencilOpDepthFail(value: number);
  100990. get stencilOpStencilDepthPass(): number;
  100991. set stencilOpStencilDepthPass(value: number);
  100992. get stencilMask(): number;
  100993. set stencilMask(value: number);
  100994. get stencilTest(): boolean;
  100995. set stencilTest(value: boolean);
  100996. constructor();
  100997. reset(): void;
  100998. apply(gl: WebGLRenderingContext): void;
  100999. }
  101000. }
  101001. declare module BABYLON {
  101002. /**
  101003. * @hidden
  101004. **/
  101005. export class AlphaState {
  101006. private _isAlphaBlendDirty;
  101007. private _isBlendFunctionParametersDirty;
  101008. private _isBlendEquationParametersDirty;
  101009. private _isBlendConstantsDirty;
  101010. private _alphaBlend;
  101011. private _blendFunctionParameters;
  101012. private _blendEquationParameters;
  101013. private _blendConstants;
  101014. /**
  101015. * Initializes the state.
  101016. */
  101017. constructor();
  101018. get isDirty(): boolean;
  101019. get alphaBlend(): boolean;
  101020. set alphaBlend(value: boolean);
  101021. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  101022. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  101023. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101024. reset(): void;
  101025. apply(gl: WebGLRenderingContext): void;
  101026. }
  101027. }
  101028. declare module BABYLON {
  101029. /** @hidden */
  101030. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101031. attributeProcessor(attribute: string): string;
  101032. varyingProcessor(varying: string, isFragment: boolean): string;
  101033. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101034. }
  101035. }
  101036. declare module BABYLON {
  101037. /**
  101038. * Interface for attribute information associated with buffer instanciation
  101039. */
  101040. export interface InstancingAttributeInfo {
  101041. /**
  101042. * Name of the GLSL attribute
  101043. * if attribute index is not specified, this is used to retrieve the index from the effect
  101044. */
  101045. attributeName: string;
  101046. /**
  101047. * Index/offset of the attribute in the vertex shader
  101048. * if not specified, this will be computes from the name.
  101049. */
  101050. index?: number;
  101051. /**
  101052. * size of the attribute, 1, 2, 3 or 4
  101053. */
  101054. attributeSize: number;
  101055. /**
  101056. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101057. */
  101058. offset: number;
  101059. /**
  101060. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101061. * default to 1
  101062. */
  101063. divisor?: number;
  101064. /**
  101065. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101066. * default is FLOAT
  101067. */
  101068. attributeType?: number;
  101069. /**
  101070. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101071. */
  101072. normalized?: boolean;
  101073. }
  101074. }
  101075. declare module BABYLON {
  101076. interface ThinEngine {
  101077. /**
  101078. * Update a video texture
  101079. * @param texture defines the texture to update
  101080. * @param video defines the video element to use
  101081. * @param invertY defines if data must be stored with Y axis inverted
  101082. */
  101083. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101084. }
  101085. }
  101086. declare module BABYLON {
  101087. /**
  101088. * Settings for finer control over video usage
  101089. */
  101090. export interface VideoTextureSettings {
  101091. /**
  101092. * Applies `autoplay` to video, if specified
  101093. */
  101094. autoPlay?: boolean;
  101095. /**
  101096. * Applies `loop` to video, if specified
  101097. */
  101098. loop?: boolean;
  101099. /**
  101100. * Automatically updates internal texture from video at every frame in the render loop
  101101. */
  101102. autoUpdateTexture: boolean;
  101103. /**
  101104. * Image src displayed during the video loading or until the user interacts with the video.
  101105. */
  101106. poster?: string;
  101107. }
  101108. /**
  101109. * If you want to display a video in your scene, this is the special texture for that.
  101110. * This special texture works similar to other textures, with the exception of a few parameters.
  101111. * @see https://doc.babylonjs.com/how_to/video_texture
  101112. */
  101113. export class VideoTexture extends Texture {
  101114. /**
  101115. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101116. */
  101117. readonly autoUpdateTexture: boolean;
  101118. /**
  101119. * The video instance used by the texture internally
  101120. */
  101121. readonly video: HTMLVideoElement;
  101122. private _onUserActionRequestedObservable;
  101123. /**
  101124. * Event triggerd when a dom action is required by the user to play the video.
  101125. * This happens due to recent changes in browser policies preventing video to auto start.
  101126. */
  101127. get onUserActionRequestedObservable(): Observable<Texture>;
  101128. private _generateMipMaps;
  101129. private _engine;
  101130. private _stillImageCaptured;
  101131. private _displayingPosterTexture;
  101132. private _settings;
  101133. private _createInternalTextureOnEvent;
  101134. private _frameId;
  101135. /**
  101136. * Creates a video texture.
  101137. * If you want to display a video in your scene, this is the special texture for that.
  101138. * This special texture works similar to other textures, with the exception of a few parameters.
  101139. * @see https://doc.babylonjs.com/how_to/video_texture
  101140. * @param name optional name, will detect from video source, if not defined
  101141. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101142. * @param scene is obviously the current scene.
  101143. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101144. * @param invertY is false by default but can be used to invert video on Y axis
  101145. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101146. * @param settings allows finer control over video usage
  101147. */
  101148. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101149. private _getName;
  101150. private _getVideo;
  101151. private _createInternalTexture;
  101152. private reset;
  101153. /**
  101154. * @hidden Internal method to initiate `update`.
  101155. */
  101156. _rebuild(): void;
  101157. /**
  101158. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101159. */
  101160. update(): void;
  101161. /**
  101162. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101163. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101164. */
  101165. updateTexture(isVisible: boolean): void;
  101166. protected _updateInternalTexture: () => void;
  101167. /**
  101168. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101169. * @param url New url.
  101170. */
  101171. updateURL(url: string): void;
  101172. /**
  101173. * Dispose the texture and release its associated resources.
  101174. */
  101175. dispose(): void;
  101176. /**
  101177. * Creates a video texture straight from a stream.
  101178. * @param scene Define the scene the texture should be created in
  101179. * @param stream Define the stream the texture should be created from
  101180. * @returns The created video texture as a promise
  101181. */
  101182. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  101183. /**
  101184. * Creates a video texture straight from your WebCam video feed.
  101185. * @param scene Define the scene the texture should be created in
  101186. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101187. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101188. * @returns The created video texture as a promise
  101189. */
  101190. static CreateFromWebCamAsync(scene: Scene, constraints: {
  101191. minWidth: number;
  101192. maxWidth: number;
  101193. minHeight: number;
  101194. maxHeight: number;
  101195. deviceId: string;
  101196. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  101197. /**
  101198. * Creates a video texture straight from your WebCam video feed.
  101199. * @param scene Define the scene the texture should be created in
  101200. * @param onReady Define a callback to triggered once the texture will be ready
  101201. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101202. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101203. */
  101204. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  101205. minWidth: number;
  101206. maxWidth: number;
  101207. minHeight: number;
  101208. maxHeight: number;
  101209. deviceId: string;
  101210. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  101211. }
  101212. }
  101213. declare module BABYLON {
  101214. /**
  101215. * Defines the interface used by objects working like Scene
  101216. * @hidden
  101217. */
  101218. interface ISceneLike {
  101219. _addPendingData(data: any): void;
  101220. _removePendingData(data: any): void;
  101221. offlineProvider: IOfflineProvider;
  101222. }
  101223. /** Interface defining initialization parameters for Engine class */
  101224. export interface EngineOptions extends WebGLContextAttributes {
  101225. /**
  101226. * Defines if the engine should no exceed a specified device ratio
  101227. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  101228. */
  101229. limitDeviceRatio?: number;
  101230. /**
  101231. * Defines if webvr should be enabled automatically
  101232. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101233. */
  101234. autoEnableWebVR?: boolean;
  101235. /**
  101236. * Defines if webgl2 should be turned off even if supported
  101237. * @see http://doc.babylonjs.com/features/webgl2
  101238. */
  101239. disableWebGL2Support?: boolean;
  101240. /**
  101241. * Defines if webaudio should be initialized as well
  101242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101243. */
  101244. audioEngine?: boolean;
  101245. /**
  101246. * Defines if animations should run using a deterministic lock step
  101247. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101248. */
  101249. deterministicLockstep?: boolean;
  101250. /** Defines the maximum steps to use with deterministic lock step mode */
  101251. lockstepMaxSteps?: number;
  101252. /** Defines the seconds between each deterministic lock step */
  101253. timeStep?: number;
  101254. /**
  101255. * Defines that engine should ignore context lost events
  101256. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  101257. */
  101258. doNotHandleContextLost?: boolean;
  101259. /**
  101260. * Defines that engine should ignore modifying touch action attribute and style
  101261. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  101262. */
  101263. doNotHandleTouchAction?: boolean;
  101264. /**
  101265. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  101266. */
  101267. useHighPrecisionFloats?: boolean;
  101268. }
  101269. /**
  101270. * The base engine class (root of all engines)
  101271. */
  101272. export class ThinEngine {
  101273. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  101274. static ExceptionList: ({
  101275. key: string;
  101276. capture: string;
  101277. captureConstraint: number;
  101278. targets: string[];
  101279. } | {
  101280. key: string;
  101281. capture: null;
  101282. captureConstraint: null;
  101283. targets: string[];
  101284. })[];
  101285. /** @hidden */
  101286. static _TextureLoaders: IInternalTextureLoader[];
  101287. /**
  101288. * Returns the current npm package of the sdk
  101289. */
  101290. static get NpmPackage(): string;
  101291. /**
  101292. * Returns the current version of the framework
  101293. */
  101294. static get Version(): string;
  101295. /**
  101296. * Returns a string describing the current engine
  101297. */
  101298. get description(): string;
  101299. /**
  101300. * Gets or sets the epsilon value used by collision engine
  101301. */
  101302. static CollisionsEpsilon: number;
  101303. /**
  101304. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101305. */
  101306. static get ShadersRepository(): string;
  101307. static set ShadersRepository(value: string);
  101308. /**
  101309. * Gets or sets the textures that the engine should not attempt to load as compressed
  101310. */
  101311. protected _excludedCompressedTextures: string[];
  101312. /**
  101313. * Filters the compressed texture formats to only include
  101314. * files that are not included in the skippable list
  101315. *
  101316. * @param url the current extension
  101317. * @param textureFormatInUse the current compressed texture format
  101318. * @returns "format" string
  101319. */
  101320. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  101321. /** @hidden */
  101322. _shaderProcessor: IShaderProcessor;
  101323. /**
  101324. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  101325. */
  101326. forcePOTTextures: boolean;
  101327. /**
  101328. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  101329. */
  101330. isFullscreen: boolean;
  101331. /**
  101332. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  101333. */
  101334. cullBackFaces: boolean;
  101335. /**
  101336. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  101337. */
  101338. renderEvenInBackground: boolean;
  101339. /**
  101340. * Gets or sets a boolean indicating that cache can be kept between frames
  101341. */
  101342. preventCacheWipeBetweenFrames: boolean;
  101343. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  101344. validateShaderPrograms: boolean;
  101345. /**
  101346. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  101347. * This can provide greater z depth for distant objects.
  101348. */
  101349. useReverseDepthBuffer: boolean;
  101350. /**
  101351. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  101352. */
  101353. disableUniformBuffers: boolean;
  101354. /** @hidden */
  101355. _uniformBuffers: UniformBuffer[];
  101356. /**
  101357. * Gets a boolean indicating that the engine supports uniform buffers
  101358. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  101359. */
  101360. get supportsUniformBuffers(): boolean;
  101361. /** @hidden */
  101362. _gl: WebGLRenderingContext;
  101363. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  101364. protected _windowIsBackground: boolean;
  101365. protected _webGLVersion: number;
  101366. protected _creationOptions: EngineOptions;
  101367. protected _highPrecisionShadersAllowed: boolean;
  101368. /** @hidden */
  101369. get _shouldUseHighPrecisionShader(): boolean;
  101370. /**
  101371. * Gets a boolean indicating that only power of 2 textures are supported
  101372. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  101373. */
  101374. get needPOTTextures(): boolean;
  101375. /** @hidden */
  101376. _badOS: boolean;
  101377. /** @hidden */
  101378. _badDesktopOS: boolean;
  101379. private _hardwareScalingLevel;
  101380. /** @hidden */
  101381. _caps: EngineCapabilities;
  101382. private _isStencilEnable;
  101383. private _glVersion;
  101384. private _glRenderer;
  101385. private _glVendor;
  101386. /** @hidden */
  101387. _videoTextureSupported: boolean;
  101388. protected _renderingQueueLaunched: boolean;
  101389. protected _activeRenderLoops: (() => void)[];
  101390. /**
  101391. * Observable signaled when a context lost event is raised
  101392. */
  101393. onContextLostObservable: Observable<ThinEngine>;
  101394. /**
  101395. * Observable signaled when a context restored event is raised
  101396. */
  101397. onContextRestoredObservable: Observable<ThinEngine>;
  101398. private _onContextLost;
  101399. private _onContextRestored;
  101400. protected _contextWasLost: boolean;
  101401. /** @hidden */
  101402. _doNotHandleContextLost: boolean;
  101403. /**
  101404. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  101405. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  101406. */
  101407. get doNotHandleContextLost(): boolean;
  101408. set doNotHandleContextLost(value: boolean);
  101409. /**
  101410. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  101411. */
  101412. disableVertexArrayObjects: boolean;
  101413. /** @hidden */
  101414. protected _colorWrite: boolean;
  101415. /** @hidden */
  101416. protected _colorWriteChanged: boolean;
  101417. /** @hidden */
  101418. protected _depthCullingState: DepthCullingState;
  101419. /** @hidden */
  101420. protected _stencilState: StencilState;
  101421. /** @hidden */
  101422. _alphaState: AlphaState;
  101423. /** @hidden */
  101424. _alphaMode: number;
  101425. /** @hidden */
  101426. _alphaEquation: number;
  101427. /** @hidden */
  101428. _internalTexturesCache: InternalTexture[];
  101429. /** @hidden */
  101430. protected _activeChannel: number;
  101431. private _currentTextureChannel;
  101432. /** @hidden */
  101433. protected _boundTexturesCache: {
  101434. [key: string]: Nullable<InternalTexture>;
  101435. };
  101436. /** @hidden */
  101437. protected _currentEffect: Nullable<Effect>;
  101438. /** @hidden */
  101439. protected _currentProgram: Nullable<WebGLProgram>;
  101440. private _compiledEffects;
  101441. private _vertexAttribArraysEnabled;
  101442. /** @hidden */
  101443. protected _cachedViewport: Nullable<IViewportLike>;
  101444. private _cachedVertexArrayObject;
  101445. /** @hidden */
  101446. protected _cachedVertexBuffers: any;
  101447. /** @hidden */
  101448. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  101449. /** @hidden */
  101450. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  101451. /** @hidden */
  101452. _currentRenderTarget: Nullable<InternalTexture>;
  101453. private _uintIndicesCurrentlySet;
  101454. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  101455. /** @hidden */
  101456. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  101457. private _currentBufferPointers;
  101458. private _currentInstanceLocations;
  101459. private _currentInstanceBuffers;
  101460. private _textureUnits;
  101461. /** @hidden */
  101462. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101463. /** @hidden */
  101464. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101465. /** @hidden */
  101466. _boundRenderFunction: any;
  101467. private _vaoRecordInProgress;
  101468. private _mustWipeVertexAttributes;
  101469. private _emptyTexture;
  101470. private _emptyCubeTexture;
  101471. private _emptyTexture3D;
  101472. private _emptyTexture2DArray;
  101473. /** @hidden */
  101474. _frameHandler: number;
  101475. private _nextFreeTextureSlots;
  101476. private _maxSimultaneousTextures;
  101477. private _activeRequests;
  101478. protected _texturesSupported: string[];
  101479. /** @hidden */
  101480. _textureFormatInUse: Nullable<string>;
  101481. protected get _supportsHardwareTextureRescaling(): boolean;
  101482. /**
  101483. * Gets the list of texture formats supported
  101484. */
  101485. get texturesSupported(): Array<string>;
  101486. /**
  101487. * Gets the list of texture formats in use
  101488. */
  101489. get textureFormatInUse(): Nullable<string>;
  101490. /**
  101491. * Gets the current viewport
  101492. */
  101493. get currentViewport(): Nullable<IViewportLike>;
  101494. /**
  101495. * Gets the default empty texture
  101496. */
  101497. get emptyTexture(): InternalTexture;
  101498. /**
  101499. * Gets the default empty 3D texture
  101500. */
  101501. get emptyTexture3D(): InternalTexture;
  101502. /**
  101503. * Gets the default empty 2D array texture
  101504. */
  101505. get emptyTexture2DArray(): InternalTexture;
  101506. /**
  101507. * Gets the default empty cube texture
  101508. */
  101509. get emptyCubeTexture(): InternalTexture;
  101510. /**
  101511. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  101512. */
  101513. readonly premultipliedAlpha: boolean;
  101514. /**
  101515. * Observable event triggered before each texture is initialized
  101516. */
  101517. onBeforeTextureInitObservable: Observable<Texture>;
  101518. /**
  101519. * Creates a new engine
  101520. * @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
  101521. * @param antialias defines enable antialiasing (default: false)
  101522. * @param options defines further options to be sent to the getContext() function
  101523. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101524. */
  101525. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101526. private _rebuildInternalTextures;
  101527. private _rebuildEffects;
  101528. /**
  101529. * Gets a boolean indicating if all created effects are ready
  101530. * @returns true if all effects are ready
  101531. */
  101532. areAllEffectsReady(): boolean;
  101533. protected _rebuildBuffers(): void;
  101534. private _initGLContext;
  101535. /**
  101536. * Gets version of the current webGL context
  101537. */
  101538. get webGLVersion(): number;
  101539. /**
  101540. * Gets a string idenfifying the name of the class
  101541. * @returns "Engine" string
  101542. */
  101543. getClassName(): string;
  101544. /**
  101545. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  101546. */
  101547. get isStencilEnable(): boolean;
  101548. /** @hidden */
  101549. _prepareWorkingCanvas(): void;
  101550. /**
  101551. * Reset the texture cache to empty state
  101552. */
  101553. resetTextureCache(): void;
  101554. /**
  101555. * Gets an object containing information about the current webGL context
  101556. * @returns an object containing the vender, the renderer and the version of the current webGL context
  101557. */
  101558. getGlInfo(): {
  101559. vendor: string;
  101560. renderer: string;
  101561. version: string;
  101562. };
  101563. /**
  101564. * Defines the hardware scaling level.
  101565. * By default the hardware scaling level is computed from the window device ratio.
  101566. * 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.
  101567. * @param level defines the level to use
  101568. */
  101569. setHardwareScalingLevel(level: number): void;
  101570. /**
  101571. * Gets the current hardware scaling level.
  101572. * By default the hardware scaling level is computed from the window device ratio.
  101573. * 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.
  101574. * @returns a number indicating the current hardware scaling level
  101575. */
  101576. getHardwareScalingLevel(): number;
  101577. /**
  101578. * Gets the list of loaded textures
  101579. * @returns an array containing all loaded textures
  101580. */
  101581. getLoadedTexturesCache(): InternalTexture[];
  101582. /**
  101583. * Gets the object containing all engine capabilities
  101584. * @returns the EngineCapabilities object
  101585. */
  101586. getCaps(): EngineCapabilities;
  101587. /**
  101588. * stop executing a render loop function and remove it from the execution array
  101589. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  101590. */
  101591. stopRenderLoop(renderFunction?: () => void): void;
  101592. /** @hidden */
  101593. _renderLoop(): void;
  101594. /**
  101595. * Gets the HTML canvas attached with the current webGL context
  101596. * @returns a HTML canvas
  101597. */
  101598. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  101599. /**
  101600. * Gets host window
  101601. * @returns the host window object
  101602. */
  101603. getHostWindow(): Nullable<Window>;
  101604. /**
  101605. * Gets the current render width
  101606. * @param useScreen defines if screen size must be used (or the current render target if any)
  101607. * @returns a number defining the current render width
  101608. */
  101609. getRenderWidth(useScreen?: boolean): number;
  101610. /**
  101611. * Gets the current render height
  101612. * @param useScreen defines if screen size must be used (or the current render target if any)
  101613. * @returns a number defining the current render height
  101614. */
  101615. getRenderHeight(useScreen?: boolean): number;
  101616. /**
  101617. * Can be used to override the current requestAnimationFrame requester.
  101618. * @hidden
  101619. */
  101620. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  101621. /**
  101622. * Register and execute a render loop. The engine can have more than one render function
  101623. * @param renderFunction defines the function to continuously execute
  101624. */
  101625. runRenderLoop(renderFunction: () => void): void;
  101626. /**
  101627. * Clear the current render buffer or the current render target (if any is set up)
  101628. * @param color defines the color to use
  101629. * @param backBuffer defines if the back buffer must be cleared
  101630. * @param depth defines if the depth buffer must be cleared
  101631. * @param stencil defines if the stencil buffer must be cleared
  101632. */
  101633. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101634. private _viewportCached;
  101635. /** @hidden */
  101636. _viewport(x: number, y: number, width: number, height: number): void;
  101637. /**
  101638. * Set the WebGL's viewport
  101639. * @param viewport defines the viewport element to be used
  101640. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  101641. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  101642. */
  101643. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  101644. /**
  101645. * Begin a new frame
  101646. */
  101647. beginFrame(): void;
  101648. /**
  101649. * Enf the current frame
  101650. */
  101651. endFrame(): void;
  101652. /**
  101653. * Resize the view according to the canvas' size
  101654. */
  101655. resize(): void;
  101656. /**
  101657. * Force a specific size of the canvas
  101658. * @param width defines the new canvas' width
  101659. * @param height defines the new canvas' height
  101660. */
  101661. setSize(width: number, height: number): void;
  101662. /**
  101663. * Binds the frame buffer to the specified texture.
  101664. * @param texture The texture to render to or null for the default canvas
  101665. * @param faceIndex The face of the texture to render to in case of cube texture
  101666. * @param requiredWidth The width of the target to render to
  101667. * @param requiredHeight The height of the target to render to
  101668. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  101669. * @param depthStencilTexture The depth stencil texture to use to render
  101670. * @param lodLevel defines le lod level to bind to the frame buffer
  101671. */
  101672. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  101673. /** @hidden */
  101674. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  101675. /**
  101676. * Unbind the current render target texture from the webGL context
  101677. * @param texture defines the render target texture to unbind
  101678. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101679. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101680. */
  101681. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101682. /**
  101683. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  101684. */
  101685. flushFramebuffer(): void;
  101686. /**
  101687. * Unbind the current render target and bind the default framebuffer
  101688. */
  101689. restoreDefaultFramebuffer(): void;
  101690. /** @hidden */
  101691. protected _resetVertexBufferBinding(): void;
  101692. /**
  101693. * Creates a vertex buffer
  101694. * @param data the data for the vertex buffer
  101695. * @returns the new WebGL static buffer
  101696. */
  101697. createVertexBuffer(data: DataArray): DataBuffer;
  101698. private _createVertexBuffer;
  101699. /**
  101700. * Creates a dynamic vertex buffer
  101701. * @param data the data for the dynamic vertex buffer
  101702. * @returns the new WebGL dynamic buffer
  101703. */
  101704. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  101705. protected _resetIndexBufferBinding(): void;
  101706. /**
  101707. * Creates a new index buffer
  101708. * @param indices defines the content of the index buffer
  101709. * @param updatable defines if the index buffer must be updatable
  101710. * @returns a new webGL buffer
  101711. */
  101712. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  101713. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  101714. /**
  101715. * Bind a webGL buffer to the webGL context
  101716. * @param buffer defines the buffer to bind
  101717. */
  101718. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  101719. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  101720. private bindBuffer;
  101721. /**
  101722. * update the bound buffer with the given data
  101723. * @param data defines the data to update
  101724. */
  101725. updateArrayBuffer(data: Float32Array): void;
  101726. private _vertexAttribPointer;
  101727. private _bindIndexBufferWithCache;
  101728. private _bindVertexBuffersAttributes;
  101729. /**
  101730. * Records a vertex array object
  101731. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101732. * @param vertexBuffers defines the list of vertex buffers to store
  101733. * @param indexBuffer defines the index buffer to store
  101734. * @param effect defines the effect to store
  101735. * @returns the new vertex array object
  101736. */
  101737. recordVertexArrayObject(vertexBuffers: {
  101738. [key: string]: VertexBuffer;
  101739. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  101740. /**
  101741. * Bind a specific vertex array object
  101742. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101743. * @param vertexArrayObject defines the vertex array object to bind
  101744. * @param indexBuffer defines the index buffer to bind
  101745. */
  101746. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  101747. /**
  101748. * Bind webGl buffers directly to the webGL context
  101749. * @param vertexBuffer defines the vertex buffer to bind
  101750. * @param indexBuffer defines the index buffer to bind
  101751. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  101752. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  101753. * @param effect defines the effect associated with the vertex buffer
  101754. */
  101755. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  101756. private _unbindVertexArrayObject;
  101757. /**
  101758. * Bind a list of vertex buffers to the webGL context
  101759. * @param vertexBuffers defines the list of vertex buffers to bind
  101760. * @param indexBuffer defines the index buffer to bind
  101761. * @param effect defines the effect associated with the vertex buffers
  101762. */
  101763. bindBuffers(vertexBuffers: {
  101764. [key: string]: Nullable<VertexBuffer>;
  101765. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  101766. /**
  101767. * Unbind all instance attributes
  101768. */
  101769. unbindInstanceAttributes(): void;
  101770. /**
  101771. * Release and free the memory of a vertex array object
  101772. * @param vao defines the vertex array object to delete
  101773. */
  101774. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  101775. /** @hidden */
  101776. _releaseBuffer(buffer: DataBuffer): boolean;
  101777. protected _deleteBuffer(buffer: DataBuffer): void;
  101778. /**
  101779. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  101780. * @param instancesBuffer defines the webGL buffer to update and bind
  101781. * @param data defines the data to store in the buffer
  101782. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  101783. */
  101784. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  101785. /**
  101786. * Bind the content of a webGL buffer used with instanciation
  101787. * @param instancesBuffer defines the webGL buffer to bind
  101788. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  101789. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  101790. */
  101791. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  101792. /**
  101793. * Disable the instance attribute corresponding to the name in parameter
  101794. * @param name defines the name of the attribute to disable
  101795. */
  101796. disableInstanceAttributeByName(name: string): void;
  101797. /**
  101798. * Disable the instance attribute corresponding to the location in parameter
  101799. * @param attributeLocation defines the attribute location of the attribute to disable
  101800. */
  101801. disableInstanceAttribute(attributeLocation: number): void;
  101802. /**
  101803. * Disable the attribute corresponding to the location in parameter
  101804. * @param attributeLocation defines the attribute location of the attribute to disable
  101805. */
  101806. disableAttributeByIndex(attributeLocation: number): void;
  101807. /**
  101808. * Send a draw order
  101809. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101810. * @param indexStart defines the starting index
  101811. * @param indexCount defines the number of index to draw
  101812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101813. */
  101814. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101815. /**
  101816. * Draw a list of points
  101817. * @param verticesStart defines the index of first vertex to draw
  101818. * @param verticesCount defines the count of vertices to draw
  101819. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101820. */
  101821. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101822. /**
  101823. * Draw a list of unindexed primitives
  101824. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101825. * @param verticesStart defines the index of first vertex to draw
  101826. * @param verticesCount defines the count of vertices to draw
  101827. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101828. */
  101829. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101830. /**
  101831. * Draw a list of indexed primitives
  101832. * @param fillMode defines the primitive to use
  101833. * @param indexStart defines the starting index
  101834. * @param indexCount defines the number of index to draw
  101835. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101836. */
  101837. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101838. /**
  101839. * Draw a list of unindexed primitives
  101840. * @param fillMode defines the primitive to use
  101841. * @param verticesStart defines the index of first vertex to draw
  101842. * @param verticesCount defines the count of vertices to draw
  101843. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101844. */
  101845. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101846. private _drawMode;
  101847. /** @hidden */
  101848. protected _reportDrawCall(): void;
  101849. /** @hidden */
  101850. _releaseEffect(effect: Effect): void;
  101851. /** @hidden */
  101852. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  101853. /**
  101854. * Create a new effect (used to store vertex/fragment shaders)
  101855. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  101856. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  101857. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  101858. * @param samplers defines an array of string used to represent textures
  101859. * @param defines defines the string containing the defines to use to compile the shaders
  101860. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  101861. * @param onCompiled defines a function to call when the effect creation is successful
  101862. * @param onError defines a function to call when the effect creation has failed
  101863. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  101864. * @returns the new Effect
  101865. */
  101866. 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;
  101867. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  101868. private _compileShader;
  101869. private _compileRawShader;
  101870. /**
  101871. * Directly 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 context defines the webGL context to use (if not set, the current one will be used)
  101876. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101877. * @returns the new webGL program
  101878. */
  101879. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101880. /**
  101881. * Creates a webGL program
  101882. * @param pipelineContext defines the pipeline context to attach to
  101883. * @param vertexCode defines the vertex shader code to use
  101884. * @param fragmentCode defines the fragment shader code to use
  101885. * @param defines defines the string containing the defines to use to compile the shaders
  101886. * @param context defines the webGL context to use (if not set, the current one will be used)
  101887. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101888. * @returns the new webGL program
  101889. */
  101890. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101891. /**
  101892. * Creates a new pipeline context
  101893. * @returns the new pipeline
  101894. */
  101895. createPipelineContext(): IPipelineContext;
  101896. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101897. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  101898. /** @hidden */
  101899. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  101900. /** @hidden */
  101901. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  101902. /** @hidden */
  101903. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  101904. /**
  101905. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  101906. * @param pipelineContext defines the pipeline context to use
  101907. * @param uniformsNames defines the list of uniform names
  101908. * @returns an array of webGL uniform locations
  101909. */
  101910. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101911. /**
  101912. * Gets the lsit of active attributes for a given webGL program
  101913. * @param pipelineContext defines the pipeline context to use
  101914. * @param attributesNames defines the list of attribute names to get
  101915. * @returns an array of indices indicating the offset of each attribute
  101916. */
  101917. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101918. /**
  101919. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  101920. * @param effect defines the effect to activate
  101921. */
  101922. enableEffect(effect: Nullable<Effect>): void;
  101923. /**
  101924. * Set the value of an uniform to a number (int)
  101925. * @param uniform defines the webGL uniform location where to store the value
  101926. * @param value defines the int number to store
  101927. */
  101928. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101929. /**
  101930. * Set the value of an uniform to an array of int32
  101931. * @param uniform defines the webGL uniform location where to store the value
  101932. * @param array defines the array of int32 to store
  101933. */
  101934. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101935. /**
  101936. * Set the value of an uniform to an array of int32 (stored as vec2)
  101937. * @param uniform defines the webGL uniform location where to store the value
  101938. * @param array defines the array of int32 to store
  101939. */
  101940. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101941. /**
  101942. * Set the value of an uniform to an array of int32 (stored as vec3)
  101943. * @param uniform defines the webGL uniform location where to store the value
  101944. * @param array defines the array of int32 to store
  101945. */
  101946. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101947. /**
  101948. * Set the value of an uniform to an array of int32 (stored as vec4)
  101949. * @param uniform defines the webGL uniform location where to store the value
  101950. * @param array defines the array of int32 to store
  101951. */
  101952. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101953. /**
  101954. * Set the value of an uniform to an array of number
  101955. * @param uniform defines the webGL uniform location where to store the value
  101956. * @param array defines the array of number to store
  101957. */
  101958. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101959. /**
  101960. * Set the value of an uniform to an array of number (stored as vec2)
  101961. * @param uniform defines the webGL uniform location where to store the value
  101962. * @param array defines the array of number to store
  101963. */
  101964. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101965. /**
  101966. * Set the value of an uniform to an array of number (stored as vec3)
  101967. * @param uniform defines the webGL uniform location where to store the value
  101968. * @param array defines the array of number to store
  101969. */
  101970. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101971. /**
  101972. * Set the value of an uniform to an array of number (stored as vec4)
  101973. * @param uniform defines the webGL uniform location where to store the value
  101974. * @param array defines the array of number to store
  101975. */
  101976. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101977. /**
  101978. * Set the value of an uniform to an array of float32 (stored as matrices)
  101979. * @param uniform defines the webGL uniform location where to store the value
  101980. * @param matrices defines the array of float32 to store
  101981. */
  101982. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  101983. /**
  101984. * Set the value of an uniform to a matrix (3x3)
  101985. * @param uniform defines the webGL uniform location where to store the value
  101986. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  101987. */
  101988. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101989. /**
  101990. * Set the value of an uniform to a matrix (2x2)
  101991. * @param uniform defines the webGL uniform location where to store the value
  101992. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  101993. */
  101994. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101995. /**
  101996. * Set the value of an uniform to a number (float)
  101997. * @param uniform defines the webGL uniform location where to store the value
  101998. * @param value defines the float number to store
  101999. */
  102000. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102001. /**
  102002. * Set the value of an uniform to a vec2
  102003. * @param uniform defines the webGL uniform location where to store the value
  102004. * @param x defines the 1st component of the value
  102005. * @param y defines the 2nd component of the value
  102006. */
  102007. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  102008. /**
  102009. * Set the value of an uniform to a vec3
  102010. * @param uniform defines the webGL uniform location where to store the value
  102011. * @param x defines the 1st component of the value
  102012. * @param y defines the 2nd component of the value
  102013. * @param z defines the 3rd component of the value
  102014. */
  102015. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  102016. /**
  102017. * Set the value of an uniform to a vec4
  102018. * @param uniform defines the webGL uniform location where to store the value
  102019. * @param x defines the 1st component of the value
  102020. * @param y defines the 2nd component of the value
  102021. * @param z defines the 3rd component of the value
  102022. * @param w defines the 4th component of the value
  102023. */
  102024. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102025. /**
  102026. * Apply all cached states (depth, culling, stencil and alpha)
  102027. */
  102028. applyStates(): void;
  102029. /**
  102030. * Enable or disable color writing
  102031. * @param enable defines the state to set
  102032. */
  102033. setColorWrite(enable: boolean): void;
  102034. /**
  102035. * Gets a boolean indicating if color writing is enabled
  102036. * @returns the current color writing state
  102037. */
  102038. getColorWrite(): boolean;
  102039. /**
  102040. * Gets the depth culling state manager
  102041. */
  102042. get depthCullingState(): DepthCullingState;
  102043. /**
  102044. * Gets the alpha state manager
  102045. */
  102046. get alphaState(): AlphaState;
  102047. /**
  102048. * Gets the stencil state manager
  102049. */
  102050. get stencilState(): StencilState;
  102051. /**
  102052. * Clears the list of texture accessible through engine.
  102053. * This can help preventing texture load conflict due to name collision.
  102054. */
  102055. clearInternalTexturesCache(): void;
  102056. /**
  102057. * Force the entire cache to be cleared
  102058. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102059. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102060. */
  102061. wipeCaches(bruteForce?: boolean): void;
  102062. /** @hidden */
  102063. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102064. min: number;
  102065. mag: number;
  102066. };
  102067. /** @hidden */
  102068. _createTexture(): WebGLTexture;
  102069. /**
  102070. * Usually called from Texture.ts.
  102071. * Passed information to create a WebGLTexture
  102072. * @param urlArg defines a value which contains one of the following:
  102073. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102074. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102075. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102076. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102077. * @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)
  102078. * @param scene needed for loading to the correct scene
  102079. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102080. * @param onLoad optional callback to be called upon successful completion
  102081. * @param onError optional callback to be called upon failure
  102082. * @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
  102083. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102084. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102085. * @param forcedExtension defines the extension to use to pick the right loader
  102086. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102087. * @param mimeType defines an optional mime type
  102088. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102089. */
  102090. 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;
  102091. /**
  102092. * @hidden
  102093. */
  102094. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102095. /**
  102096. * Creates a raw texture
  102097. * @param data defines the data to store in the texture
  102098. * @param width defines the width of the texture
  102099. * @param height defines the height of the texture
  102100. * @param format defines the format of the data
  102101. * @param generateMipMaps defines if the engine should generate the mip levels
  102102. * @param invertY defines if data must be stored with Y axis inverted
  102103. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102104. * @param compression defines the compression used (null by default)
  102105. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102106. * @returns the raw texture inside an InternalTexture
  102107. */
  102108. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102109. /**
  102110. * Creates a new raw cube texture
  102111. * @param data defines the array of data to use to create each face
  102112. * @param size defines the size of the textures
  102113. * @param format defines the format of the data
  102114. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102115. * @param generateMipMaps defines if the engine should generate the mip levels
  102116. * @param invertY defines if data must be stored with Y axis inverted
  102117. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102118. * @param compression defines the compression used (null by default)
  102119. * @returns the cube texture as an InternalTexture
  102120. */
  102121. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102122. /**
  102123. * Creates a new raw 3D texture
  102124. * @param data defines the data used to create the texture
  102125. * @param width defines the width of the texture
  102126. * @param height defines the height of the texture
  102127. * @param depth defines the depth of the texture
  102128. * @param format defines the format of the texture
  102129. * @param generateMipMaps defines if the engine must generate mip levels
  102130. * @param invertY defines if data must be stored with Y axis inverted
  102131. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102132. * @param compression defines the compressed used (can be null)
  102133. * @param textureType defines the compressed used (can be null)
  102134. * @returns a new raw 3D texture (stored in an InternalTexture)
  102135. */
  102136. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102137. /**
  102138. * Creates a new raw 2D array texture
  102139. * @param data defines the data used to create the texture
  102140. * @param width defines the width of the texture
  102141. * @param height defines the height of the texture
  102142. * @param depth defines the number of layers of the texture
  102143. * @param format defines the format of the texture
  102144. * @param generateMipMaps defines if the engine must generate mip levels
  102145. * @param invertY defines if data must be stored with Y axis inverted
  102146. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102147. * @param compression defines the compressed used (can be null)
  102148. * @param textureType defines the compressed used (can be null)
  102149. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102150. */
  102151. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102152. private _unpackFlipYCached;
  102153. /**
  102154. * In case you are sharing the context with other applications, it might
  102155. * be interested to not cache the unpack flip y state to ensure a consistent
  102156. * value would be set.
  102157. */
  102158. enableUnpackFlipYCached: boolean;
  102159. /** @hidden */
  102160. _unpackFlipY(value: boolean): void;
  102161. /** @hidden */
  102162. _getUnpackAlignement(): number;
  102163. private _getTextureTarget;
  102164. /**
  102165. * Update the sampling mode of a given texture
  102166. * @param samplingMode defines the required sampling mode
  102167. * @param texture defines the texture to update
  102168. * @param generateMipMaps defines whether to generate mipmaps for the texture
  102169. */
  102170. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  102171. /**
  102172. * Update the sampling mode of a given texture
  102173. * @param texture defines the texture to update
  102174. * @param wrapU defines the texture wrap mode of the u coordinates
  102175. * @param wrapV defines the texture wrap mode of the v coordinates
  102176. * @param wrapR defines the texture wrap mode of the r coordinates
  102177. */
  102178. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  102179. /** @hidden */
  102180. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  102181. width: number;
  102182. height: number;
  102183. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  102184. /** @hidden */
  102185. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102186. /** @hidden */
  102187. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  102188. /** @hidden */
  102189. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102190. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  102191. private _prepareWebGLTexture;
  102192. /** @hidden */
  102193. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  102194. private _getDepthStencilBuffer;
  102195. /** @hidden */
  102196. _releaseFramebufferObjects(texture: InternalTexture): void;
  102197. /** @hidden */
  102198. _releaseTexture(texture: InternalTexture): void;
  102199. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  102200. protected _setProgram(program: WebGLProgram): void;
  102201. protected _boundUniforms: {
  102202. [key: number]: WebGLUniformLocation;
  102203. };
  102204. /**
  102205. * Binds an effect to the webGL context
  102206. * @param effect defines the effect to bind
  102207. */
  102208. bindSamplers(effect: Effect): void;
  102209. private _activateCurrentTexture;
  102210. /** @hidden */
  102211. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  102212. /** @hidden */
  102213. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  102214. /**
  102215. * Unbind all textures from the webGL context
  102216. */
  102217. unbindAllTextures(): void;
  102218. /**
  102219. * Sets a texture to the according uniform.
  102220. * @param channel The texture channel
  102221. * @param uniform The uniform to set
  102222. * @param texture The texture to apply
  102223. */
  102224. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  102225. private _bindSamplerUniformToChannel;
  102226. private _getTextureWrapMode;
  102227. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  102228. /**
  102229. * Sets an array of texture to the webGL context
  102230. * @param channel defines the channel where the texture array must be set
  102231. * @param uniform defines the associated uniform location
  102232. * @param textures defines the array of textures to bind
  102233. */
  102234. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  102235. /** @hidden */
  102236. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  102237. private _setTextureParameterFloat;
  102238. private _setTextureParameterInteger;
  102239. /**
  102240. * Unbind all vertex attributes from the webGL context
  102241. */
  102242. unbindAllAttributes(): void;
  102243. /**
  102244. * 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
  102245. */
  102246. releaseEffects(): void;
  102247. /**
  102248. * Dispose and release all associated resources
  102249. */
  102250. dispose(): void;
  102251. /**
  102252. * Attach a new callback raised when context lost event is fired
  102253. * @param callback defines the callback to call
  102254. */
  102255. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102256. /**
  102257. * Attach a new callback raised when context restored event is fired
  102258. * @param callback defines the callback to call
  102259. */
  102260. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102261. /**
  102262. * Get the current error code of the webGL context
  102263. * @returns the error code
  102264. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  102265. */
  102266. getError(): number;
  102267. private _canRenderToFloatFramebuffer;
  102268. private _canRenderToHalfFloatFramebuffer;
  102269. private _canRenderToFramebuffer;
  102270. /** @hidden */
  102271. _getWebGLTextureType(type: number): number;
  102272. /** @hidden */
  102273. _getInternalFormat(format: number): number;
  102274. /** @hidden */
  102275. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  102276. /** @hidden */
  102277. _getRGBAMultiSampleBufferFormat(type: number): number;
  102278. /** @hidden */
  102279. _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;
  102280. /**
  102281. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102282. * @param x defines the x coordinate of the rectangle where pixels must be read
  102283. * @param y defines the y coordinate of the rectangle where pixels must be read
  102284. * @param width defines the width of the rectangle where pixels must be read
  102285. * @param height defines the height of the rectangle where pixels must be read
  102286. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  102287. * @returns a Uint8Array containing RGBA colors
  102288. */
  102289. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  102290. private static _isSupported;
  102291. /**
  102292. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  102293. * @returns true if the engine can be created
  102294. * @ignorenaming
  102295. */
  102296. static isSupported(): boolean;
  102297. /**
  102298. * Find the next highest power of two.
  102299. * @param x Number to start search from.
  102300. * @return Next highest power of two.
  102301. */
  102302. static CeilingPOT(x: number): number;
  102303. /**
  102304. * Find the next lowest power of two.
  102305. * @param x Number to start search from.
  102306. * @return Next lowest power of two.
  102307. */
  102308. static FloorPOT(x: number): number;
  102309. /**
  102310. * Find the nearest power of two.
  102311. * @param x Number to start search from.
  102312. * @return Next nearest power of two.
  102313. */
  102314. static NearestPOT(x: number): number;
  102315. /**
  102316. * Get the closest exponent of two
  102317. * @param value defines the value to approximate
  102318. * @param max defines the maximum value to return
  102319. * @param mode defines how to define the closest value
  102320. * @returns closest exponent of two of the given value
  102321. */
  102322. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  102323. /**
  102324. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  102325. * @param func - the function to be called
  102326. * @param requester - the object that will request the next frame. Falls back to window.
  102327. * @returns frame number
  102328. */
  102329. static QueueNewFrame(func: () => void, requester?: any): number;
  102330. /**
  102331. * Gets host document
  102332. * @returns the host document object
  102333. */
  102334. getHostDocument(): Nullable<Document>;
  102335. }
  102336. }
  102337. declare module BABYLON {
  102338. /**
  102339. * Class representing spherical harmonics coefficients to the 3rd degree
  102340. */
  102341. export class SphericalHarmonics {
  102342. /**
  102343. * Defines whether or not the harmonics have been prescaled for rendering.
  102344. */
  102345. preScaled: boolean;
  102346. /**
  102347. * The l0,0 coefficients of the spherical harmonics
  102348. */
  102349. l00: Vector3;
  102350. /**
  102351. * The l1,-1 coefficients of the spherical harmonics
  102352. */
  102353. l1_1: Vector3;
  102354. /**
  102355. * The l1,0 coefficients of the spherical harmonics
  102356. */
  102357. l10: Vector3;
  102358. /**
  102359. * The l1,1 coefficients of the spherical harmonics
  102360. */
  102361. l11: Vector3;
  102362. /**
  102363. * The l2,-2 coefficients of the spherical harmonics
  102364. */
  102365. l2_2: Vector3;
  102366. /**
  102367. * The l2,-1 coefficients of the spherical harmonics
  102368. */
  102369. l2_1: Vector3;
  102370. /**
  102371. * The l2,0 coefficients of the spherical harmonics
  102372. */
  102373. l20: Vector3;
  102374. /**
  102375. * The l2,1 coefficients of the spherical harmonics
  102376. */
  102377. l21: Vector3;
  102378. /**
  102379. * The l2,2 coefficients of the spherical harmonics
  102380. */
  102381. l22: Vector3;
  102382. /**
  102383. * Adds a light to the spherical harmonics
  102384. * @param direction the direction of the light
  102385. * @param color the color of the light
  102386. * @param deltaSolidAngle the delta solid angle of the light
  102387. */
  102388. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  102389. /**
  102390. * Scales the spherical harmonics by the given amount
  102391. * @param scale the amount to scale
  102392. */
  102393. scaleInPlace(scale: number): void;
  102394. /**
  102395. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  102396. *
  102397. * ```
  102398. * E_lm = A_l * L_lm
  102399. * ```
  102400. *
  102401. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  102402. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  102403. * the scaling factors are given in equation 9.
  102404. */
  102405. convertIncidentRadianceToIrradiance(): void;
  102406. /**
  102407. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  102408. *
  102409. * ```
  102410. * L = (1/pi) * E * rho
  102411. * ```
  102412. *
  102413. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  102414. */
  102415. convertIrradianceToLambertianRadiance(): void;
  102416. /**
  102417. * Integrates the reconstruction coefficients directly in to the SH preventing further
  102418. * required operations at run time.
  102419. *
  102420. * This is simply done by scaling back the SH with Ylm constants parameter.
  102421. * The trigonometric part being applied by the shader at run time.
  102422. */
  102423. preScaleForRendering(): void;
  102424. /**
  102425. * Constructs a spherical harmonics from an array.
  102426. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  102427. * @returns the spherical harmonics
  102428. */
  102429. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  102430. /**
  102431. * Gets the spherical harmonics from polynomial
  102432. * @param polynomial the spherical polynomial
  102433. * @returns the spherical harmonics
  102434. */
  102435. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  102436. }
  102437. /**
  102438. * Class representing spherical polynomial coefficients to the 3rd degree
  102439. */
  102440. export class SphericalPolynomial {
  102441. private _harmonics;
  102442. /**
  102443. * The spherical harmonics used to create the polynomials.
  102444. */
  102445. get preScaledHarmonics(): SphericalHarmonics;
  102446. /**
  102447. * The x coefficients of the spherical polynomial
  102448. */
  102449. x: Vector3;
  102450. /**
  102451. * The y coefficients of the spherical polynomial
  102452. */
  102453. y: Vector3;
  102454. /**
  102455. * The z coefficients of the spherical polynomial
  102456. */
  102457. z: Vector3;
  102458. /**
  102459. * The xx coefficients of the spherical polynomial
  102460. */
  102461. xx: Vector3;
  102462. /**
  102463. * The yy coefficients of the spherical polynomial
  102464. */
  102465. yy: Vector3;
  102466. /**
  102467. * The zz coefficients of the spherical polynomial
  102468. */
  102469. zz: Vector3;
  102470. /**
  102471. * The xy coefficients of the spherical polynomial
  102472. */
  102473. xy: Vector3;
  102474. /**
  102475. * The yz coefficients of the spherical polynomial
  102476. */
  102477. yz: Vector3;
  102478. /**
  102479. * The zx coefficients of the spherical polynomial
  102480. */
  102481. zx: Vector3;
  102482. /**
  102483. * Adds an ambient color to the spherical polynomial
  102484. * @param color the color to add
  102485. */
  102486. addAmbient(color: Color3): void;
  102487. /**
  102488. * Scales the spherical polynomial by the given amount
  102489. * @param scale the amount to scale
  102490. */
  102491. scaleInPlace(scale: number): void;
  102492. /**
  102493. * Gets the spherical polynomial from harmonics
  102494. * @param harmonics the spherical harmonics
  102495. * @returns the spherical polynomial
  102496. */
  102497. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102498. /**
  102499. * Constructs a spherical polynomial from an array.
  102500. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102501. * @returns the spherical polynomial
  102502. */
  102503. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102504. }
  102505. }
  102506. declare module BABYLON {
  102507. /**
  102508. * Defines the source of the internal texture
  102509. */
  102510. export enum InternalTextureSource {
  102511. /**
  102512. * The source of the texture data is unknown
  102513. */
  102514. Unknown = 0,
  102515. /**
  102516. * Texture data comes from an URL
  102517. */
  102518. Url = 1,
  102519. /**
  102520. * Texture data is only used for temporary storage
  102521. */
  102522. Temp = 2,
  102523. /**
  102524. * Texture data comes from raw data (ArrayBuffer)
  102525. */
  102526. Raw = 3,
  102527. /**
  102528. * Texture content is dynamic (video or dynamic texture)
  102529. */
  102530. Dynamic = 4,
  102531. /**
  102532. * Texture content is generated by rendering to it
  102533. */
  102534. RenderTarget = 5,
  102535. /**
  102536. * Texture content is part of a multi render target process
  102537. */
  102538. MultiRenderTarget = 6,
  102539. /**
  102540. * Texture data comes from a cube data file
  102541. */
  102542. Cube = 7,
  102543. /**
  102544. * Texture data comes from a raw cube data
  102545. */
  102546. CubeRaw = 8,
  102547. /**
  102548. * Texture data come from a prefiltered cube data file
  102549. */
  102550. CubePrefiltered = 9,
  102551. /**
  102552. * Texture content is raw 3D data
  102553. */
  102554. Raw3D = 10,
  102555. /**
  102556. * Texture content is raw 2D array data
  102557. */
  102558. Raw2DArray = 11,
  102559. /**
  102560. * Texture content is a depth texture
  102561. */
  102562. Depth = 12,
  102563. /**
  102564. * Texture data comes from a raw cube data encoded with RGBD
  102565. */
  102566. CubeRawRGBD = 13
  102567. }
  102568. /**
  102569. * Class used to store data associated with WebGL texture data for the engine
  102570. * This class should not be used directly
  102571. */
  102572. export class InternalTexture {
  102573. /** @hidden */
  102574. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  102575. /**
  102576. * Defines if the texture is ready
  102577. */
  102578. isReady: boolean;
  102579. /**
  102580. * Defines if the texture is a cube texture
  102581. */
  102582. isCube: boolean;
  102583. /**
  102584. * Defines if the texture contains 3D data
  102585. */
  102586. is3D: boolean;
  102587. /**
  102588. * Defines if the texture contains 2D array data
  102589. */
  102590. is2DArray: boolean;
  102591. /**
  102592. * Defines if the texture contains multiview data
  102593. */
  102594. isMultiview: boolean;
  102595. /**
  102596. * Gets the URL used to load this texture
  102597. */
  102598. url: string;
  102599. /**
  102600. * Gets the sampling mode of the texture
  102601. */
  102602. samplingMode: number;
  102603. /**
  102604. * Gets a boolean indicating if the texture needs mipmaps generation
  102605. */
  102606. generateMipMaps: boolean;
  102607. /**
  102608. * Gets the number of samples used by the texture (WebGL2+ only)
  102609. */
  102610. samples: number;
  102611. /**
  102612. * Gets the type of the texture (int, float...)
  102613. */
  102614. type: number;
  102615. /**
  102616. * Gets the format of the texture (RGB, RGBA...)
  102617. */
  102618. format: number;
  102619. /**
  102620. * Observable called when the texture is loaded
  102621. */
  102622. onLoadedObservable: Observable<InternalTexture>;
  102623. /**
  102624. * Gets the width of the texture
  102625. */
  102626. width: number;
  102627. /**
  102628. * Gets the height of the texture
  102629. */
  102630. height: number;
  102631. /**
  102632. * Gets the depth of the texture
  102633. */
  102634. depth: number;
  102635. /**
  102636. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  102637. */
  102638. baseWidth: number;
  102639. /**
  102640. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  102641. */
  102642. baseHeight: number;
  102643. /**
  102644. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  102645. */
  102646. baseDepth: number;
  102647. /**
  102648. * Gets a boolean indicating if the texture is inverted on Y axis
  102649. */
  102650. invertY: boolean;
  102651. /** @hidden */
  102652. _invertVScale: boolean;
  102653. /** @hidden */
  102654. _associatedChannel: number;
  102655. /** @hidden */
  102656. _source: InternalTextureSource;
  102657. /** @hidden */
  102658. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102659. /** @hidden */
  102660. _bufferView: Nullable<ArrayBufferView>;
  102661. /** @hidden */
  102662. _bufferViewArray: Nullable<ArrayBufferView[]>;
  102663. /** @hidden */
  102664. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  102665. /** @hidden */
  102666. _size: number;
  102667. /** @hidden */
  102668. _extension: string;
  102669. /** @hidden */
  102670. _files: Nullable<string[]>;
  102671. /** @hidden */
  102672. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102673. /** @hidden */
  102674. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102675. /** @hidden */
  102676. _framebuffer: Nullable<WebGLFramebuffer>;
  102677. /** @hidden */
  102678. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  102679. /** @hidden */
  102680. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  102681. /** @hidden */
  102682. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  102683. /** @hidden */
  102684. _attachments: Nullable<number[]>;
  102685. /** @hidden */
  102686. _cachedCoordinatesMode: Nullable<number>;
  102687. /** @hidden */
  102688. _cachedWrapU: Nullable<number>;
  102689. /** @hidden */
  102690. _cachedWrapV: Nullable<number>;
  102691. /** @hidden */
  102692. _cachedWrapR: Nullable<number>;
  102693. /** @hidden */
  102694. _cachedAnisotropicFilteringLevel: Nullable<number>;
  102695. /** @hidden */
  102696. _isDisabled: boolean;
  102697. /** @hidden */
  102698. _compression: Nullable<string>;
  102699. /** @hidden */
  102700. _generateStencilBuffer: boolean;
  102701. /** @hidden */
  102702. _generateDepthBuffer: boolean;
  102703. /** @hidden */
  102704. _comparisonFunction: number;
  102705. /** @hidden */
  102706. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  102707. /** @hidden */
  102708. _lodGenerationScale: number;
  102709. /** @hidden */
  102710. _lodGenerationOffset: number;
  102711. /** @hidden */
  102712. _colorTextureArray: Nullable<WebGLTexture>;
  102713. /** @hidden */
  102714. _depthStencilTextureArray: Nullable<WebGLTexture>;
  102715. /** @hidden */
  102716. _lodTextureHigh: Nullable<BaseTexture>;
  102717. /** @hidden */
  102718. _lodTextureMid: Nullable<BaseTexture>;
  102719. /** @hidden */
  102720. _lodTextureLow: Nullable<BaseTexture>;
  102721. /** @hidden */
  102722. _isRGBD: boolean;
  102723. /** @hidden */
  102724. _linearSpecularLOD: boolean;
  102725. /** @hidden */
  102726. _irradianceTexture: Nullable<BaseTexture>;
  102727. /** @hidden */
  102728. _webGLTexture: Nullable<WebGLTexture>;
  102729. /** @hidden */
  102730. _references: number;
  102731. private _engine;
  102732. /**
  102733. * Gets the Engine the texture belongs to.
  102734. * @returns The babylon engine
  102735. */
  102736. getEngine(): ThinEngine;
  102737. /**
  102738. * Gets the data source type of the texture
  102739. */
  102740. get source(): InternalTextureSource;
  102741. /**
  102742. * Creates a new InternalTexture
  102743. * @param engine defines the engine to use
  102744. * @param source defines the type of data that will be used
  102745. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102746. */
  102747. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  102748. /**
  102749. * Increments the number of references (ie. the number of Texture that point to it)
  102750. */
  102751. incrementReferences(): void;
  102752. /**
  102753. * Change the size of the texture (not the size of the content)
  102754. * @param width defines the new width
  102755. * @param height defines the new height
  102756. * @param depth defines the new depth (1 by default)
  102757. */
  102758. updateSize(width: int, height: int, depth?: int): void;
  102759. /** @hidden */
  102760. _rebuild(): void;
  102761. /** @hidden */
  102762. _swapAndDie(target: InternalTexture): void;
  102763. /**
  102764. * Dispose the current allocated resources
  102765. */
  102766. dispose(): void;
  102767. }
  102768. }
  102769. declare module BABYLON {
  102770. /**
  102771. * Class used to work with sound analyzer using fast fourier transform (FFT)
  102772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102773. */
  102774. export class Analyser {
  102775. /**
  102776. * Gets or sets the smoothing
  102777. * @ignorenaming
  102778. */
  102779. SMOOTHING: number;
  102780. /**
  102781. * Gets or sets the FFT table size
  102782. * @ignorenaming
  102783. */
  102784. FFT_SIZE: number;
  102785. /**
  102786. * Gets or sets the bar graph amplitude
  102787. * @ignorenaming
  102788. */
  102789. BARGRAPHAMPLITUDE: number;
  102790. /**
  102791. * Gets or sets the position of the debug canvas
  102792. * @ignorenaming
  102793. */
  102794. DEBUGCANVASPOS: {
  102795. x: number;
  102796. y: number;
  102797. };
  102798. /**
  102799. * Gets or sets the debug canvas size
  102800. * @ignorenaming
  102801. */
  102802. DEBUGCANVASSIZE: {
  102803. width: number;
  102804. height: number;
  102805. };
  102806. private _byteFreqs;
  102807. private _byteTime;
  102808. private _floatFreqs;
  102809. private _webAudioAnalyser;
  102810. private _debugCanvas;
  102811. private _debugCanvasContext;
  102812. private _scene;
  102813. private _registerFunc;
  102814. private _audioEngine;
  102815. /**
  102816. * Creates a new analyser
  102817. * @param scene defines hosting scene
  102818. */
  102819. constructor(scene: Scene);
  102820. /**
  102821. * Get the number of data values you will have to play with for the visualization
  102822. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  102823. * @returns a number
  102824. */
  102825. getFrequencyBinCount(): number;
  102826. /**
  102827. * Gets the current frequency data as a byte array
  102828. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102829. * @returns a Uint8Array
  102830. */
  102831. getByteFrequencyData(): Uint8Array;
  102832. /**
  102833. * Gets the current waveform as a byte array
  102834. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  102835. * @returns a Uint8Array
  102836. */
  102837. getByteTimeDomainData(): Uint8Array;
  102838. /**
  102839. * Gets the current frequency data as a float array
  102840. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102841. * @returns a Float32Array
  102842. */
  102843. getFloatFrequencyData(): Float32Array;
  102844. /**
  102845. * Renders the debug canvas
  102846. */
  102847. drawDebugCanvas(): void;
  102848. /**
  102849. * Stops rendering the debug canvas and removes it
  102850. */
  102851. stopDebugCanvas(): void;
  102852. /**
  102853. * Connects two audio nodes
  102854. * @param inputAudioNode defines first node to connect
  102855. * @param outputAudioNode defines second node to connect
  102856. */
  102857. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  102858. /**
  102859. * Releases all associated resources
  102860. */
  102861. dispose(): void;
  102862. }
  102863. }
  102864. declare module BABYLON {
  102865. /**
  102866. * This represents an audio engine and it is responsible
  102867. * to play, synchronize and analyse sounds throughout the application.
  102868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102869. */
  102870. export interface IAudioEngine extends IDisposable {
  102871. /**
  102872. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102873. */
  102874. readonly canUseWebAudio: boolean;
  102875. /**
  102876. * Gets the current AudioContext if available.
  102877. */
  102878. readonly audioContext: Nullable<AudioContext>;
  102879. /**
  102880. * The master gain node defines the global audio volume of your audio engine.
  102881. */
  102882. readonly masterGain: GainNode;
  102883. /**
  102884. * Gets whether or not mp3 are supported by your browser.
  102885. */
  102886. readonly isMP3supported: boolean;
  102887. /**
  102888. * Gets whether or not ogg are supported by your browser.
  102889. */
  102890. readonly isOGGsupported: boolean;
  102891. /**
  102892. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102893. * @ignoreNaming
  102894. */
  102895. WarnedWebAudioUnsupported: boolean;
  102896. /**
  102897. * Defines if the audio engine relies on a custom unlocked button.
  102898. * In this case, the embedded button will not be displayed.
  102899. */
  102900. useCustomUnlockedButton: boolean;
  102901. /**
  102902. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  102903. */
  102904. readonly unlocked: boolean;
  102905. /**
  102906. * Event raised when audio has been unlocked on the browser.
  102907. */
  102908. onAudioUnlockedObservable: Observable<AudioEngine>;
  102909. /**
  102910. * Event raised when audio has been locked on the browser.
  102911. */
  102912. onAudioLockedObservable: Observable<AudioEngine>;
  102913. /**
  102914. * Flags the audio engine in Locked state.
  102915. * This happens due to new browser policies preventing audio to autoplay.
  102916. */
  102917. lock(): void;
  102918. /**
  102919. * Unlocks the audio engine once a user action has been done on the dom.
  102920. * This is helpful to resume play once browser policies have been satisfied.
  102921. */
  102922. unlock(): void;
  102923. }
  102924. /**
  102925. * This represents the default audio engine used in babylon.
  102926. * It is responsible to play, synchronize and analyse sounds throughout the application.
  102927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102928. */
  102929. export class AudioEngine implements IAudioEngine {
  102930. private _audioContext;
  102931. private _audioContextInitialized;
  102932. private _muteButton;
  102933. private _hostElement;
  102934. /**
  102935. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102936. */
  102937. canUseWebAudio: boolean;
  102938. /**
  102939. * The master gain node defines the global audio volume of your audio engine.
  102940. */
  102941. masterGain: GainNode;
  102942. /**
  102943. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102944. * @ignoreNaming
  102945. */
  102946. WarnedWebAudioUnsupported: boolean;
  102947. /**
  102948. * Gets whether or not mp3 are supported by your browser.
  102949. */
  102950. isMP3supported: boolean;
  102951. /**
  102952. * Gets whether or not ogg are supported by your browser.
  102953. */
  102954. isOGGsupported: boolean;
  102955. /**
  102956. * Gets whether audio has been unlocked on the device.
  102957. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  102958. * a user interaction has happened.
  102959. */
  102960. unlocked: boolean;
  102961. /**
  102962. * Defines if the audio engine relies on a custom unlocked button.
  102963. * In this case, the embedded button will not be displayed.
  102964. */
  102965. useCustomUnlockedButton: boolean;
  102966. /**
  102967. * Event raised when audio has been unlocked on the browser.
  102968. */
  102969. onAudioUnlockedObservable: Observable<AudioEngine>;
  102970. /**
  102971. * Event raised when audio has been locked on the browser.
  102972. */
  102973. onAudioLockedObservable: Observable<AudioEngine>;
  102974. /**
  102975. * Gets the current AudioContext if available.
  102976. */
  102977. get audioContext(): Nullable<AudioContext>;
  102978. private _connectedAnalyser;
  102979. /**
  102980. * Instantiates a new audio engine.
  102981. *
  102982. * There should be only one per page as some browsers restrict the number
  102983. * of audio contexts you can create.
  102984. * @param hostElement defines the host element where to display the mute icon if necessary
  102985. */
  102986. constructor(hostElement?: Nullable<HTMLElement>);
  102987. /**
  102988. * Flags the audio engine in Locked state.
  102989. * This happens due to new browser policies preventing audio to autoplay.
  102990. */
  102991. lock(): void;
  102992. /**
  102993. * Unlocks the audio engine once a user action has been done on the dom.
  102994. * This is helpful to resume play once browser policies have been satisfied.
  102995. */
  102996. unlock(): void;
  102997. private _resumeAudioContext;
  102998. private _initializeAudioContext;
  102999. private _tryToRun;
  103000. private _triggerRunningState;
  103001. private _triggerSuspendedState;
  103002. private _displayMuteButton;
  103003. private _moveButtonToTopLeft;
  103004. private _onResize;
  103005. private _hideMuteButton;
  103006. /**
  103007. * Destroy and release the resources associated with the audio ccontext.
  103008. */
  103009. dispose(): void;
  103010. /**
  103011. * Gets the global volume sets on the master gain.
  103012. * @returns the global volume if set or -1 otherwise
  103013. */
  103014. getGlobalVolume(): number;
  103015. /**
  103016. * Sets the global volume of your experience (sets on the master gain).
  103017. * @param newVolume Defines the new global volume of the application
  103018. */
  103019. setGlobalVolume(newVolume: number): void;
  103020. /**
  103021. * Connect the audio engine to an audio analyser allowing some amazing
  103022. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103023. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103024. * @param analyser The analyser to connect to the engine
  103025. */
  103026. connectToAnalyser(analyser: Analyser): void;
  103027. }
  103028. }
  103029. declare module BABYLON {
  103030. /**
  103031. * Interface used to present a loading screen while loading a scene
  103032. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103033. */
  103034. export interface ILoadingScreen {
  103035. /**
  103036. * Function called to display the loading screen
  103037. */
  103038. displayLoadingUI: () => void;
  103039. /**
  103040. * Function called to hide the loading screen
  103041. */
  103042. hideLoadingUI: () => void;
  103043. /**
  103044. * Gets or sets the color to use for the background
  103045. */
  103046. loadingUIBackgroundColor: string;
  103047. /**
  103048. * Gets or sets the text to display while loading
  103049. */
  103050. loadingUIText: string;
  103051. }
  103052. /**
  103053. * Class used for the default loading screen
  103054. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103055. */
  103056. export class DefaultLoadingScreen implements ILoadingScreen {
  103057. private _renderingCanvas;
  103058. private _loadingText;
  103059. private _loadingDivBackgroundColor;
  103060. private _loadingDiv;
  103061. private _loadingTextDiv;
  103062. /** Gets or sets the logo url to use for the default loading screen */
  103063. static DefaultLogoUrl: string;
  103064. /** Gets or sets the spinner url to use for the default loading screen */
  103065. static DefaultSpinnerUrl: string;
  103066. /**
  103067. * Creates a new default loading screen
  103068. * @param _renderingCanvas defines the canvas used to render the scene
  103069. * @param _loadingText defines the default text to display
  103070. * @param _loadingDivBackgroundColor defines the default background color
  103071. */
  103072. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103073. /**
  103074. * Function called to display the loading screen
  103075. */
  103076. displayLoadingUI(): void;
  103077. /**
  103078. * Function called to hide the loading screen
  103079. */
  103080. hideLoadingUI(): void;
  103081. /**
  103082. * Gets or sets the text to display while loading
  103083. */
  103084. set loadingUIText(text: string);
  103085. get loadingUIText(): string;
  103086. /**
  103087. * Gets or sets the color to use for the background
  103088. */
  103089. get loadingUIBackgroundColor(): string;
  103090. set loadingUIBackgroundColor(color: string);
  103091. private _resizeLoadingUI;
  103092. }
  103093. }
  103094. declare module BABYLON {
  103095. /**
  103096. * Interface for any object that can request an animation frame
  103097. */
  103098. export interface ICustomAnimationFrameRequester {
  103099. /**
  103100. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103101. */
  103102. renderFunction?: Function;
  103103. /**
  103104. * Called to request the next frame to render to
  103105. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103106. */
  103107. requestAnimationFrame: Function;
  103108. /**
  103109. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103110. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103111. */
  103112. requestID?: number;
  103113. }
  103114. }
  103115. declare module BABYLON {
  103116. /**
  103117. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103118. */
  103119. export class PerformanceMonitor {
  103120. private _enabled;
  103121. private _rollingFrameTime;
  103122. private _lastFrameTimeMs;
  103123. /**
  103124. * constructor
  103125. * @param frameSampleSize The number of samples required to saturate the sliding window
  103126. */
  103127. constructor(frameSampleSize?: number);
  103128. /**
  103129. * Samples current frame
  103130. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103131. */
  103132. sampleFrame(timeMs?: number): void;
  103133. /**
  103134. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103135. */
  103136. get averageFrameTime(): number;
  103137. /**
  103138. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103139. */
  103140. get averageFrameTimeVariance(): number;
  103141. /**
  103142. * Returns the frame time of the most recent frame
  103143. */
  103144. get instantaneousFrameTime(): number;
  103145. /**
  103146. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  103147. */
  103148. get averageFPS(): number;
  103149. /**
  103150. * Returns the average framerate in frames per second using the most recent frame time
  103151. */
  103152. get instantaneousFPS(): number;
  103153. /**
  103154. * Returns true if enough samples have been taken to completely fill the sliding window
  103155. */
  103156. get isSaturated(): boolean;
  103157. /**
  103158. * Enables contributions to the sliding window sample set
  103159. */
  103160. enable(): void;
  103161. /**
  103162. * Disables contributions to the sliding window sample set
  103163. * Samples will not be interpolated over the disabled period
  103164. */
  103165. disable(): void;
  103166. /**
  103167. * Returns true if sampling is enabled
  103168. */
  103169. get isEnabled(): boolean;
  103170. /**
  103171. * Resets performance monitor
  103172. */
  103173. reset(): void;
  103174. }
  103175. /**
  103176. * RollingAverage
  103177. *
  103178. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  103179. */
  103180. export class RollingAverage {
  103181. /**
  103182. * Current average
  103183. */
  103184. average: number;
  103185. /**
  103186. * Current variance
  103187. */
  103188. variance: number;
  103189. protected _samples: Array<number>;
  103190. protected _sampleCount: number;
  103191. protected _pos: number;
  103192. protected _m2: number;
  103193. /**
  103194. * constructor
  103195. * @param length The number of samples required to saturate the sliding window
  103196. */
  103197. constructor(length: number);
  103198. /**
  103199. * Adds a sample to the sample set
  103200. * @param v The sample value
  103201. */
  103202. add(v: number): void;
  103203. /**
  103204. * Returns previously added values or null if outside of history or outside the sliding window domain
  103205. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  103206. * @return Value previously recorded with add() or null if outside of range
  103207. */
  103208. history(i: number): number;
  103209. /**
  103210. * Returns true if enough samples have been taken to completely fill the sliding window
  103211. * @return true if sample-set saturated
  103212. */
  103213. isSaturated(): boolean;
  103214. /**
  103215. * Resets the rolling average (equivalent to 0 samples taken so far)
  103216. */
  103217. reset(): void;
  103218. /**
  103219. * Wraps a value around the sample range boundaries
  103220. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  103221. * @return Wrapped position in sample range
  103222. */
  103223. protected _wrapPosition(i: number): number;
  103224. }
  103225. }
  103226. declare module BABYLON {
  103227. /**
  103228. * This class is used to track a performance counter which is number based.
  103229. * The user has access to many properties which give statistics of different nature.
  103230. *
  103231. * The implementer can track two kinds of Performance Counter: time and count.
  103232. * 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.
  103233. * 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.
  103234. */
  103235. export class PerfCounter {
  103236. /**
  103237. * Gets or sets a global boolean to turn on and off all the counters
  103238. */
  103239. static Enabled: boolean;
  103240. /**
  103241. * Returns the smallest value ever
  103242. */
  103243. get min(): number;
  103244. /**
  103245. * Returns the biggest value ever
  103246. */
  103247. get max(): number;
  103248. /**
  103249. * Returns the average value since the performance counter is running
  103250. */
  103251. get average(): number;
  103252. /**
  103253. * Returns the average value of the last second the counter was monitored
  103254. */
  103255. get lastSecAverage(): number;
  103256. /**
  103257. * Returns the current value
  103258. */
  103259. get current(): number;
  103260. /**
  103261. * Gets the accumulated total
  103262. */
  103263. get total(): number;
  103264. /**
  103265. * Gets the total value count
  103266. */
  103267. get count(): number;
  103268. /**
  103269. * Creates a new counter
  103270. */
  103271. constructor();
  103272. /**
  103273. * Call this method to start monitoring a new frame.
  103274. * 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.
  103275. */
  103276. fetchNewFrame(): void;
  103277. /**
  103278. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103279. * @param newCount the count value to add to the monitored count
  103280. * @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.
  103281. */
  103282. addCount(newCount: number, fetchResult: boolean): void;
  103283. /**
  103284. * Start monitoring this performance counter
  103285. */
  103286. beginMonitoring(): void;
  103287. /**
  103288. * Compute the time lapsed since the previous beginMonitoring() call.
  103289. * @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
  103290. */
  103291. endMonitoring(newFrame?: boolean): void;
  103292. private _fetchResult;
  103293. private _startMonitoringTime;
  103294. private _min;
  103295. private _max;
  103296. private _average;
  103297. private _current;
  103298. private _totalValueCount;
  103299. private _totalAccumulated;
  103300. private _lastSecAverage;
  103301. private _lastSecAccumulated;
  103302. private _lastSecTime;
  103303. private _lastSecValueCount;
  103304. }
  103305. }
  103306. declare module BABYLON {
  103307. interface ThinEngine {
  103308. /**
  103309. * Sets alpha constants used by some alpha blending modes
  103310. * @param r defines the red component
  103311. * @param g defines the green component
  103312. * @param b defines the blue component
  103313. * @param a defines the alpha component
  103314. */
  103315. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  103316. /**
  103317. * Sets the current alpha mode
  103318. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  103319. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  103320. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103321. */
  103322. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103323. /**
  103324. * Gets the current alpha mode
  103325. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103326. * @returns the current alpha mode
  103327. */
  103328. getAlphaMode(): number;
  103329. /**
  103330. * Sets the current alpha equation
  103331. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  103332. */
  103333. setAlphaEquation(equation: number): void;
  103334. /**
  103335. * Gets the current alpha equation.
  103336. * @returns the current alpha equation
  103337. */
  103338. getAlphaEquation(): number;
  103339. }
  103340. }
  103341. declare module BABYLON {
  103342. /**
  103343. * Defines the interface used by display changed events
  103344. */
  103345. export interface IDisplayChangedEventArgs {
  103346. /** Gets the vrDisplay object (if any) */
  103347. vrDisplay: Nullable<any>;
  103348. /** Gets a boolean indicating if webVR is supported */
  103349. vrSupported: boolean;
  103350. }
  103351. /**
  103352. * Defines the interface used by objects containing a viewport (like a camera)
  103353. */
  103354. interface IViewportOwnerLike {
  103355. /**
  103356. * Gets or sets the viewport
  103357. */
  103358. viewport: IViewportLike;
  103359. }
  103360. /**
  103361. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  103362. */
  103363. export class Engine extends ThinEngine {
  103364. /** Defines that alpha blending is disabled */
  103365. static readonly ALPHA_DISABLE: number;
  103366. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  103367. static readonly ALPHA_ADD: number;
  103368. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  103369. static readonly ALPHA_COMBINE: number;
  103370. /** Defines that alpha blending to DEST - SRC * DEST */
  103371. static readonly ALPHA_SUBTRACT: number;
  103372. /** Defines that alpha blending to SRC * DEST */
  103373. static readonly ALPHA_MULTIPLY: number;
  103374. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  103375. static readonly ALPHA_MAXIMIZED: number;
  103376. /** Defines that alpha blending to SRC + DEST */
  103377. static readonly ALPHA_ONEONE: number;
  103378. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  103379. static readonly ALPHA_PREMULTIPLIED: number;
  103380. /**
  103381. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  103382. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  103383. */
  103384. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  103385. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  103386. static readonly ALPHA_INTERPOLATE: number;
  103387. /**
  103388. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  103389. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  103390. */
  103391. static readonly ALPHA_SCREENMODE: number;
  103392. /** Defines that the ressource is not delayed*/
  103393. static readonly DELAYLOADSTATE_NONE: number;
  103394. /** Defines that the ressource was successfully delay loaded */
  103395. static readonly DELAYLOADSTATE_LOADED: number;
  103396. /** Defines that the ressource is currently delay loading */
  103397. static readonly DELAYLOADSTATE_LOADING: number;
  103398. /** Defines that the ressource is delayed and has not started loading */
  103399. static readonly DELAYLOADSTATE_NOTLOADED: number;
  103400. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  103401. static readonly NEVER: number;
  103402. /** 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 */
  103403. static readonly ALWAYS: number;
  103404. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  103405. static readonly LESS: number;
  103406. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  103407. static readonly EQUAL: number;
  103408. /** 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 */
  103409. static readonly LEQUAL: number;
  103410. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  103411. static readonly GREATER: number;
  103412. /** 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 */
  103413. static readonly GEQUAL: number;
  103414. /** 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 */
  103415. static readonly NOTEQUAL: number;
  103416. /** Passed to stencilOperation to specify that stencil value must be kept */
  103417. static readonly KEEP: number;
  103418. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103419. static readonly REPLACE: number;
  103420. /** Passed to stencilOperation to specify that stencil value must be incremented */
  103421. static readonly INCR: number;
  103422. /** Passed to stencilOperation to specify that stencil value must be decremented */
  103423. static readonly DECR: number;
  103424. /** Passed to stencilOperation to specify that stencil value must be inverted */
  103425. static readonly INVERT: number;
  103426. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  103427. static readonly INCR_WRAP: number;
  103428. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  103429. static readonly DECR_WRAP: number;
  103430. /** Texture is not repeating outside of 0..1 UVs */
  103431. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  103432. /** Texture is repeating outside of 0..1 UVs */
  103433. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  103434. /** Texture is repeating and mirrored */
  103435. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  103436. /** ALPHA */
  103437. static readonly TEXTUREFORMAT_ALPHA: number;
  103438. /** LUMINANCE */
  103439. static readonly TEXTUREFORMAT_LUMINANCE: number;
  103440. /** LUMINANCE_ALPHA */
  103441. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  103442. /** RGB */
  103443. static readonly TEXTUREFORMAT_RGB: number;
  103444. /** RGBA */
  103445. static readonly TEXTUREFORMAT_RGBA: number;
  103446. /** RED */
  103447. static readonly TEXTUREFORMAT_RED: number;
  103448. /** RED (2nd reference) */
  103449. static readonly TEXTUREFORMAT_R: number;
  103450. /** RG */
  103451. static readonly TEXTUREFORMAT_RG: number;
  103452. /** RED_INTEGER */
  103453. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  103454. /** RED_INTEGER (2nd reference) */
  103455. static readonly TEXTUREFORMAT_R_INTEGER: number;
  103456. /** RG_INTEGER */
  103457. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  103458. /** RGB_INTEGER */
  103459. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  103460. /** RGBA_INTEGER */
  103461. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  103462. /** UNSIGNED_BYTE */
  103463. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  103464. /** UNSIGNED_BYTE (2nd reference) */
  103465. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  103466. /** FLOAT */
  103467. static readonly TEXTURETYPE_FLOAT: number;
  103468. /** HALF_FLOAT */
  103469. static readonly TEXTURETYPE_HALF_FLOAT: number;
  103470. /** BYTE */
  103471. static readonly TEXTURETYPE_BYTE: number;
  103472. /** SHORT */
  103473. static readonly TEXTURETYPE_SHORT: number;
  103474. /** UNSIGNED_SHORT */
  103475. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  103476. /** INT */
  103477. static readonly TEXTURETYPE_INT: number;
  103478. /** UNSIGNED_INT */
  103479. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  103480. /** UNSIGNED_SHORT_4_4_4_4 */
  103481. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  103482. /** UNSIGNED_SHORT_5_5_5_1 */
  103483. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  103484. /** UNSIGNED_SHORT_5_6_5 */
  103485. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  103486. /** UNSIGNED_INT_2_10_10_10_REV */
  103487. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  103488. /** UNSIGNED_INT_24_8 */
  103489. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  103490. /** UNSIGNED_INT_10F_11F_11F_REV */
  103491. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  103492. /** UNSIGNED_INT_5_9_9_9_REV */
  103493. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  103494. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  103495. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  103496. /** nearest is mag = nearest and min = nearest and mip = linear */
  103497. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  103498. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103499. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  103500. /** Trilinear is mag = linear and min = linear and mip = linear */
  103501. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  103502. /** nearest is mag = nearest and min = nearest and mip = linear */
  103503. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  103504. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103505. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  103506. /** Trilinear is mag = linear and min = linear and mip = linear */
  103507. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  103508. /** mag = nearest and min = nearest and mip = nearest */
  103509. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  103510. /** mag = nearest and min = linear and mip = nearest */
  103511. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  103512. /** mag = nearest and min = linear and mip = linear */
  103513. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  103514. /** mag = nearest and min = linear and mip = none */
  103515. static readonly TEXTURE_NEAREST_LINEAR: number;
  103516. /** mag = nearest and min = nearest and mip = none */
  103517. static readonly TEXTURE_NEAREST_NEAREST: number;
  103518. /** mag = linear and min = nearest and mip = nearest */
  103519. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  103520. /** mag = linear and min = nearest and mip = linear */
  103521. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  103522. /** mag = linear and min = linear and mip = none */
  103523. static readonly TEXTURE_LINEAR_LINEAR: number;
  103524. /** mag = linear and min = nearest and mip = none */
  103525. static readonly TEXTURE_LINEAR_NEAREST: number;
  103526. /** Explicit coordinates mode */
  103527. static readonly TEXTURE_EXPLICIT_MODE: number;
  103528. /** Spherical coordinates mode */
  103529. static readonly TEXTURE_SPHERICAL_MODE: number;
  103530. /** Planar coordinates mode */
  103531. static readonly TEXTURE_PLANAR_MODE: number;
  103532. /** Cubic coordinates mode */
  103533. static readonly TEXTURE_CUBIC_MODE: number;
  103534. /** Projection coordinates mode */
  103535. static readonly TEXTURE_PROJECTION_MODE: number;
  103536. /** Skybox coordinates mode */
  103537. static readonly TEXTURE_SKYBOX_MODE: number;
  103538. /** Inverse Cubic coordinates mode */
  103539. static readonly TEXTURE_INVCUBIC_MODE: number;
  103540. /** Equirectangular coordinates mode */
  103541. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  103542. /** Equirectangular Fixed coordinates mode */
  103543. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  103544. /** Equirectangular Fixed Mirrored coordinates mode */
  103545. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103546. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  103547. static readonly SCALEMODE_FLOOR: number;
  103548. /** Defines that texture rescaling will look for the nearest power of 2 size */
  103549. static readonly SCALEMODE_NEAREST: number;
  103550. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  103551. static readonly SCALEMODE_CEILING: number;
  103552. /**
  103553. * Returns the current npm package of the sdk
  103554. */
  103555. static get NpmPackage(): string;
  103556. /**
  103557. * Returns the current version of the framework
  103558. */
  103559. static get Version(): string;
  103560. /** Gets the list of created engines */
  103561. static get Instances(): Engine[];
  103562. /**
  103563. * Gets the latest created engine
  103564. */
  103565. static get LastCreatedEngine(): Nullable<Engine>;
  103566. /**
  103567. * Gets the latest created scene
  103568. */
  103569. static get LastCreatedScene(): Nullable<Scene>;
  103570. /**
  103571. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  103572. * @param flag defines which part of the materials must be marked as dirty
  103573. * @param predicate defines a predicate used to filter which materials should be affected
  103574. */
  103575. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103576. /**
  103577. * Method called to create the default loading screen.
  103578. * This can be overriden in your own app.
  103579. * @param canvas The rendering canvas element
  103580. * @returns The loading screen
  103581. */
  103582. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  103583. /**
  103584. * Method called to create the default rescale post process on each engine.
  103585. */
  103586. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  103587. /**
  103588. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  103589. **/
  103590. enableOfflineSupport: boolean;
  103591. /**
  103592. * 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)
  103593. **/
  103594. disableManifestCheck: boolean;
  103595. /**
  103596. * Gets the list of created scenes
  103597. */
  103598. scenes: Scene[];
  103599. /**
  103600. * Event raised when a new scene is created
  103601. */
  103602. onNewSceneAddedObservable: Observable<Scene>;
  103603. /**
  103604. * Gets the list of created postprocesses
  103605. */
  103606. postProcesses: PostProcess[];
  103607. /**
  103608. * Gets a boolean indicating if the pointer is currently locked
  103609. */
  103610. isPointerLock: boolean;
  103611. /**
  103612. * Observable event triggered each time the rendering canvas is resized
  103613. */
  103614. onResizeObservable: Observable<Engine>;
  103615. /**
  103616. * Observable event triggered each time the canvas loses focus
  103617. */
  103618. onCanvasBlurObservable: Observable<Engine>;
  103619. /**
  103620. * Observable event triggered each time the canvas gains focus
  103621. */
  103622. onCanvasFocusObservable: Observable<Engine>;
  103623. /**
  103624. * Observable event triggered each time the canvas receives pointerout event
  103625. */
  103626. onCanvasPointerOutObservable: Observable<PointerEvent>;
  103627. /**
  103628. * Observable raised when the engine begins a new frame
  103629. */
  103630. onBeginFrameObservable: Observable<Engine>;
  103631. /**
  103632. * If set, will be used to request the next animation frame for the render loop
  103633. */
  103634. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  103635. /**
  103636. * Observable raised when the engine ends the current frame
  103637. */
  103638. onEndFrameObservable: Observable<Engine>;
  103639. /**
  103640. * Observable raised when the engine is about to compile a shader
  103641. */
  103642. onBeforeShaderCompilationObservable: Observable<Engine>;
  103643. /**
  103644. * Observable raised when the engine has jsut compiled a shader
  103645. */
  103646. onAfterShaderCompilationObservable: Observable<Engine>;
  103647. /**
  103648. * Gets the audio engine
  103649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103650. * @ignorenaming
  103651. */
  103652. static audioEngine: IAudioEngine;
  103653. /**
  103654. * Default AudioEngine factory responsible of creating the Audio Engine.
  103655. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  103656. */
  103657. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  103658. /**
  103659. * Default offline support factory responsible of creating a tool used to store data locally.
  103660. * By default, this will create a Database object if the workload has been embedded.
  103661. */
  103662. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  103663. private _loadingScreen;
  103664. private _pointerLockRequested;
  103665. private _dummyFramebuffer;
  103666. private _rescalePostProcess;
  103667. private _deterministicLockstep;
  103668. private _lockstepMaxSteps;
  103669. private _timeStep;
  103670. protected get _supportsHardwareTextureRescaling(): boolean;
  103671. private _fps;
  103672. private _deltaTime;
  103673. /** @hidden */
  103674. _drawCalls: PerfCounter;
  103675. /**
  103676. * Turn this value on if you want to pause FPS computation when in background
  103677. */
  103678. disablePerformanceMonitorInBackground: boolean;
  103679. private _performanceMonitor;
  103680. /**
  103681. * Gets the performance monitor attached to this engine
  103682. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103683. */
  103684. get performanceMonitor(): PerformanceMonitor;
  103685. private _onFocus;
  103686. private _onBlur;
  103687. private _onCanvasPointerOut;
  103688. private _onCanvasBlur;
  103689. private _onCanvasFocus;
  103690. private _onFullscreenChange;
  103691. private _onPointerLockChange;
  103692. /**
  103693. * Gets the HTML element used to attach event listeners
  103694. * @returns a HTML element
  103695. */
  103696. getInputElement(): Nullable<HTMLElement>;
  103697. /**
  103698. * Creates a new engine
  103699. * @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
  103700. * @param antialias defines enable antialiasing (default: false)
  103701. * @param options defines further options to be sent to the getContext() function
  103702. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103703. */
  103704. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103705. /**
  103706. * Gets current aspect ratio
  103707. * @param viewportOwner defines the camera to use to get the aspect ratio
  103708. * @param useScreen defines if screen size must be used (or the current render target if any)
  103709. * @returns a number defining the aspect ratio
  103710. */
  103711. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  103712. /**
  103713. * Gets current screen aspect ratio
  103714. * @returns a number defining the aspect ratio
  103715. */
  103716. getScreenAspectRatio(): number;
  103717. /**
  103718. * Gets the client rect of the HTML canvas attached with the current webGL context
  103719. * @returns a client rectanglee
  103720. */
  103721. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  103722. /**
  103723. * Gets the client rect of the HTML element used for events
  103724. * @returns a client rectanglee
  103725. */
  103726. getInputElementClientRect(): Nullable<ClientRect>;
  103727. /**
  103728. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  103729. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103730. * @returns true if engine is in deterministic lock step mode
  103731. */
  103732. isDeterministicLockStep(): boolean;
  103733. /**
  103734. * Gets the max steps when engine is running in deterministic lock step
  103735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103736. * @returns the max steps
  103737. */
  103738. getLockstepMaxSteps(): number;
  103739. /**
  103740. * Returns the time in ms between steps when using deterministic lock step.
  103741. * @returns time step in (ms)
  103742. */
  103743. getTimeStep(): number;
  103744. /**
  103745. * Force the mipmap generation for the given render target texture
  103746. * @param texture defines the render target texture to use
  103747. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  103748. */
  103749. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  103750. /** States */
  103751. /**
  103752. * Set various states to the webGL context
  103753. * @param culling defines backface culling state
  103754. * @param zOffset defines the value to apply to zOffset (0 by default)
  103755. * @param force defines if states must be applied even if cache is up to date
  103756. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  103757. */
  103758. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103759. /**
  103760. * Set the z offset to apply to current rendering
  103761. * @param value defines the offset to apply
  103762. */
  103763. setZOffset(value: number): void;
  103764. /**
  103765. * Gets the current value of the zOffset
  103766. * @returns the current zOffset state
  103767. */
  103768. getZOffset(): number;
  103769. /**
  103770. * Enable or disable depth buffering
  103771. * @param enable defines the state to set
  103772. */
  103773. setDepthBuffer(enable: boolean): void;
  103774. /**
  103775. * Gets a boolean indicating if depth writing is enabled
  103776. * @returns the current depth writing state
  103777. */
  103778. getDepthWrite(): boolean;
  103779. /**
  103780. * Enable or disable depth writing
  103781. * @param enable defines the state to set
  103782. */
  103783. setDepthWrite(enable: boolean): void;
  103784. /**
  103785. * Gets a boolean indicating if stencil buffer is enabled
  103786. * @returns the current stencil buffer state
  103787. */
  103788. getStencilBuffer(): boolean;
  103789. /**
  103790. * Enable or disable the stencil buffer
  103791. * @param enable defines if the stencil buffer must be enabled or disabled
  103792. */
  103793. setStencilBuffer(enable: boolean): void;
  103794. /**
  103795. * Gets the current stencil mask
  103796. * @returns a number defining the new stencil mask to use
  103797. */
  103798. getStencilMask(): number;
  103799. /**
  103800. * Sets the current stencil mask
  103801. * @param mask defines the new stencil mask to use
  103802. */
  103803. setStencilMask(mask: number): void;
  103804. /**
  103805. * Gets the current stencil function
  103806. * @returns a number defining the stencil function to use
  103807. */
  103808. getStencilFunction(): number;
  103809. /**
  103810. * Gets the current stencil reference value
  103811. * @returns a number defining the stencil reference value to use
  103812. */
  103813. getStencilFunctionReference(): number;
  103814. /**
  103815. * Gets the current stencil mask
  103816. * @returns a number defining the stencil mask to use
  103817. */
  103818. getStencilFunctionMask(): number;
  103819. /**
  103820. * Sets the current stencil function
  103821. * @param stencilFunc defines the new stencil function to use
  103822. */
  103823. setStencilFunction(stencilFunc: number): void;
  103824. /**
  103825. * Sets the current stencil reference
  103826. * @param reference defines the new stencil reference to use
  103827. */
  103828. setStencilFunctionReference(reference: number): void;
  103829. /**
  103830. * Sets the current stencil mask
  103831. * @param mask defines the new stencil mask to use
  103832. */
  103833. setStencilFunctionMask(mask: number): void;
  103834. /**
  103835. * Gets the current stencil operation when stencil fails
  103836. * @returns a number defining stencil operation to use when stencil fails
  103837. */
  103838. getStencilOperationFail(): number;
  103839. /**
  103840. * Gets the current stencil operation when depth fails
  103841. * @returns a number defining stencil operation to use when depth fails
  103842. */
  103843. getStencilOperationDepthFail(): number;
  103844. /**
  103845. * Gets the current stencil operation when stencil passes
  103846. * @returns a number defining stencil operation to use when stencil passes
  103847. */
  103848. getStencilOperationPass(): number;
  103849. /**
  103850. * Sets the stencil operation to use when stencil fails
  103851. * @param operation defines the stencil operation to use when stencil fails
  103852. */
  103853. setStencilOperationFail(operation: number): void;
  103854. /**
  103855. * Sets the stencil operation to use when depth fails
  103856. * @param operation defines the stencil operation to use when depth fails
  103857. */
  103858. setStencilOperationDepthFail(operation: number): void;
  103859. /**
  103860. * Sets the stencil operation to use when stencil passes
  103861. * @param operation defines the stencil operation to use when stencil passes
  103862. */
  103863. setStencilOperationPass(operation: number): void;
  103864. /**
  103865. * Sets a boolean indicating if the dithering state is enabled or disabled
  103866. * @param value defines the dithering state
  103867. */
  103868. setDitheringState(value: boolean): void;
  103869. /**
  103870. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  103871. * @param value defines the rasterizer state
  103872. */
  103873. setRasterizerState(value: boolean): void;
  103874. /**
  103875. * Gets the current depth function
  103876. * @returns a number defining the depth function
  103877. */
  103878. getDepthFunction(): Nullable<number>;
  103879. /**
  103880. * Sets the current depth function
  103881. * @param depthFunc defines the function to use
  103882. */
  103883. setDepthFunction(depthFunc: number): void;
  103884. /**
  103885. * Sets the current depth function to GREATER
  103886. */
  103887. setDepthFunctionToGreater(): void;
  103888. /**
  103889. * Sets the current depth function to GEQUAL
  103890. */
  103891. setDepthFunctionToGreaterOrEqual(): void;
  103892. /**
  103893. * Sets the current depth function to LESS
  103894. */
  103895. setDepthFunctionToLess(): void;
  103896. /**
  103897. * Sets the current depth function to LEQUAL
  103898. */
  103899. setDepthFunctionToLessOrEqual(): void;
  103900. private _cachedStencilBuffer;
  103901. private _cachedStencilFunction;
  103902. private _cachedStencilMask;
  103903. private _cachedStencilOperationPass;
  103904. private _cachedStencilOperationFail;
  103905. private _cachedStencilOperationDepthFail;
  103906. private _cachedStencilReference;
  103907. /**
  103908. * Caches the the state of the stencil buffer
  103909. */
  103910. cacheStencilState(): void;
  103911. /**
  103912. * Restores the state of the stencil buffer
  103913. */
  103914. restoreStencilState(): void;
  103915. /**
  103916. * Directly set the WebGL Viewport
  103917. * @param x defines the x coordinate of the viewport (in screen space)
  103918. * @param y defines the y coordinate of the viewport (in screen space)
  103919. * @param width defines the width of the viewport (in screen space)
  103920. * @param height defines the height of the viewport (in screen space)
  103921. * @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
  103922. */
  103923. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  103924. /**
  103925. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  103926. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103927. * @param y defines the y-coordinate of the corner of the clear rectangle
  103928. * @param width defines the width of the clear rectangle
  103929. * @param height defines the height of the clear rectangle
  103930. * @param clearColor defines the clear color
  103931. */
  103932. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  103933. /**
  103934. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  103935. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103936. * @param y defines the y-coordinate of the corner of the clear rectangle
  103937. * @param width defines the width of the clear rectangle
  103938. * @param height defines the height of the clear rectangle
  103939. */
  103940. enableScissor(x: number, y: number, width: number, height: number): void;
  103941. /**
  103942. * Disable previously set scissor test rectangle
  103943. */
  103944. disableScissor(): void;
  103945. protected _reportDrawCall(): void;
  103946. /**
  103947. * Initializes a webVR display and starts listening to display change events
  103948. * The onVRDisplayChangedObservable will be notified upon these changes
  103949. * @returns The onVRDisplayChangedObservable
  103950. */
  103951. initWebVR(): Observable<IDisplayChangedEventArgs>;
  103952. /** @hidden */
  103953. _prepareVRComponent(): void;
  103954. /** @hidden */
  103955. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  103956. /** @hidden */
  103957. _submitVRFrame(): void;
  103958. /**
  103959. * Call this function to leave webVR mode
  103960. * Will do nothing if webVR is not supported or if there is no webVR device
  103961. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103962. */
  103963. disableVR(): void;
  103964. /**
  103965. * Gets a boolean indicating that the system is in VR mode and is presenting
  103966. * @returns true if VR mode is engaged
  103967. */
  103968. isVRPresenting(): boolean;
  103969. /** @hidden */
  103970. _requestVRFrame(): void;
  103971. /** @hidden */
  103972. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103973. /**
  103974. * Gets the source code of the vertex shader associated with a specific webGL program
  103975. * @param program defines the program to use
  103976. * @returns a string containing the source code of the vertex shader associated with the program
  103977. */
  103978. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  103979. /**
  103980. * Gets the source code of the fragment shader associated with a specific webGL program
  103981. * @param program defines the program to use
  103982. * @returns a string containing the source code of the fragment shader associated with the program
  103983. */
  103984. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  103985. /**
  103986. * Sets a depth stencil texture from a render target to the according uniform.
  103987. * @param channel The texture channel
  103988. * @param uniform The uniform to set
  103989. * @param texture The render target texture containing the depth stencil texture to apply
  103990. */
  103991. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  103992. /**
  103993. * Sets a texture to the webGL context from a postprocess
  103994. * @param channel defines the channel to use
  103995. * @param postProcess defines the source postprocess
  103996. */
  103997. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  103998. /**
  103999. * Binds the output of the passed in post process to the texture channel specified
  104000. * @param channel The channel the texture should be bound to
  104001. * @param postProcess The post process which's output should be bound
  104002. */
  104003. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  104004. /** @hidden */
  104005. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  104006. protected _rebuildBuffers(): void;
  104007. /** @hidden */
  104008. _renderFrame(): void;
  104009. _renderLoop(): void;
  104010. /** @hidden */
  104011. _renderViews(): boolean;
  104012. /**
  104013. * Toggle full screen mode
  104014. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104015. */
  104016. switchFullscreen(requestPointerLock: boolean): void;
  104017. /**
  104018. * Enters full screen mode
  104019. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104020. */
  104021. enterFullscreen(requestPointerLock: boolean): void;
  104022. /**
  104023. * Exits full screen mode
  104024. */
  104025. exitFullscreen(): void;
  104026. /**
  104027. * Enters Pointerlock mode
  104028. */
  104029. enterPointerlock(): void;
  104030. /**
  104031. * Exits Pointerlock mode
  104032. */
  104033. exitPointerlock(): void;
  104034. /**
  104035. * Begin a new frame
  104036. */
  104037. beginFrame(): void;
  104038. /**
  104039. * Enf the current frame
  104040. */
  104041. endFrame(): void;
  104042. resize(): void;
  104043. /**
  104044. * Set the compressed texture format to use, based on the formats you have, and the formats
  104045. * supported by the hardware / browser.
  104046. *
  104047. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104048. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104049. * to API arguments needed to compressed textures. This puts the burden on the container
  104050. * generator to house the arcane code for determining these for current & future formats.
  104051. *
  104052. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104053. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104054. *
  104055. * Note: The result of this call is not taken into account when a texture is base64.
  104056. *
  104057. * @param formatsAvailable defines the list of those format families you have created
  104058. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104059. *
  104060. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104061. * @returns The extension selected.
  104062. */
  104063. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104064. /**
  104065. * Set the compressed texture extensions or file names to skip.
  104066. *
  104067. * @param skippedFiles defines the list of those texture files you want to skip
  104068. * Example: [".dds", ".env", "myfile.png"]
  104069. */
  104070. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104071. /**
  104072. * Force a specific size of the canvas
  104073. * @param width defines the new canvas' width
  104074. * @param height defines the new canvas' height
  104075. */
  104076. setSize(width: number, height: number): void;
  104077. /**
  104078. * Updates a dynamic vertex buffer.
  104079. * @param vertexBuffer the vertex buffer to update
  104080. * @param data the data used to update the vertex buffer
  104081. * @param byteOffset the byte offset of the data
  104082. * @param byteLength the byte length of the data
  104083. */
  104084. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104085. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104086. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104087. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104088. _releaseTexture(texture: InternalTexture): void;
  104089. /**
  104090. * @hidden
  104091. * Rescales a texture
  104092. * @param source input texutre
  104093. * @param destination destination texture
  104094. * @param scene scene to use to render the resize
  104095. * @param internalFormat format to use when resizing
  104096. * @param onComplete callback to be called when resize has completed
  104097. */
  104098. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104099. /**
  104100. * Gets the current framerate
  104101. * @returns a number representing the framerate
  104102. */
  104103. getFps(): number;
  104104. /**
  104105. * Gets the time spent between current and previous frame
  104106. * @returns a number representing the delta time in ms
  104107. */
  104108. getDeltaTime(): number;
  104109. private _measureFps;
  104110. /** @hidden */
  104111. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104112. /**
  104113. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104114. * @param renderTarget The render target to set the frame buffer for
  104115. */
  104116. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104117. /**
  104118. * Update a dynamic index buffer
  104119. * @param indexBuffer defines the target index buffer
  104120. * @param indices defines the data to update
  104121. * @param offset defines the offset in the target index buffer where update should start
  104122. */
  104123. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104124. /**
  104125. * Updates the sample count of a render target texture
  104126. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104127. * @param texture defines the texture to update
  104128. * @param samples defines the sample count to set
  104129. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104130. */
  104131. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104132. /**
  104133. * Updates a depth texture Comparison Mode and Function.
  104134. * If the comparison Function is equal to 0, the mode will be set to none.
  104135. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104136. * @param texture The texture to set the comparison function for
  104137. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104138. */
  104139. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104140. /**
  104141. * Creates a webGL buffer to use with instanciation
  104142. * @param capacity defines the size of the buffer
  104143. * @returns the webGL buffer
  104144. */
  104145. createInstancesBuffer(capacity: number): DataBuffer;
  104146. /**
  104147. * Delete a webGL buffer used with instanciation
  104148. * @param buffer defines the webGL buffer to delete
  104149. */
  104150. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  104151. /** @hidden */
  104152. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  104153. dispose(): void;
  104154. private _disableTouchAction;
  104155. /**
  104156. * Display the loading screen
  104157. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104158. */
  104159. displayLoadingUI(): void;
  104160. /**
  104161. * Hide the loading screen
  104162. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104163. */
  104164. hideLoadingUI(): void;
  104165. /**
  104166. * Gets the current loading screen object
  104167. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104168. */
  104169. get loadingScreen(): ILoadingScreen;
  104170. /**
  104171. * Sets the current loading screen object
  104172. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104173. */
  104174. set loadingScreen(loadingScreen: ILoadingScreen);
  104175. /**
  104176. * Sets the current loading screen text
  104177. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104178. */
  104179. set loadingUIText(text: string);
  104180. /**
  104181. * Sets the current loading screen background color
  104182. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104183. */
  104184. set loadingUIBackgroundColor(color: string);
  104185. /** Pointerlock and fullscreen */
  104186. /**
  104187. * Ask the browser to promote the current element to pointerlock mode
  104188. * @param element defines the DOM element to promote
  104189. */
  104190. static _RequestPointerlock(element: HTMLElement): void;
  104191. /**
  104192. * Asks the browser to exit pointerlock mode
  104193. */
  104194. static _ExitPointerlock(): void;
  104195. /**
  104196. * Ask the browser to promote the current element to fullscreen rendering mode
  104197. * @param element defines the DOM element to promote
  104198. */
  104199. static _RequestFullscreen(element: HTMLElement): void;
  104200. /**
  104201. * Asks the browser to exit fullscreen mode
  104202. */
  104203. static _ExitFullscreen(): void;
  104204. }
  104205. }
  104206. declare module BABYLON {
  104207. /**
  104208. * The engine store class is responsible to hold all the instances of Engine and Scene created
  104209. * during the life time of the application.
  104210. */
  104211. export class EngineStore {
  104212. /** Gets the list of created engines */
  104213. static Instances: Engine[];
  104214. /** @hidden */
  104215. static _LastCreatedScene: Nullable<Scene>;
  104216. /**
  104217. * Gets the latest created engine
  104218. */
  104219. static get LastCreatedEngine(): Nullable<Engine>;
  104220. /**
  104221. * Gets the latest created scene
  104222. */
  104223. static get LastCreatedScene(): Nullable<Scene>;
  104224. /**
  104225. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104226. * @ignorenaming
  104227. */
  104228. static UseFallbackTexture: boolean;
  104229. /**
  104230. * Texture content used if a texture cannot loaded
  104231. * @ignorenaming
  104232. */
  104233. static FallbackTexture: string;
  104234. }
  104235. }
  104236. declare module BABYLON {
  104237. /**
  104238. * Helper class that provides a small promise polyfill
  104239. */
  104240. export class PromisePolyfill {
  104241. /**
  104242. * Static function used to check if the polyfill is required
  104243. * If this is the case then the function will inject the polyfill to window.Promise
  104244. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  104245. */
  104246. static Apply(force?: boolean): void;
  104247. }
  104248. }
  104249. declare module BABYLON {
  104250. /**
  104251. * Interface for screenshot methods with describe argument called `size` as object with options
  104252. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  104253. */
  104254. export interface IScreenshotSize {
  104255. /**
  104256. * number in pixels for canvas height
  104257. */
  104258. height?: number;
  104259. /**
  104260. * multiplier allowing render at a higher or lower resolution
  104261. * If value is defined then height and width will be ignored and taken from camera
  104262. */
  104263. precision?: number;
  104264. /**
  104265. * number in pixels for canvas width
  104266. */
  104267. width?: number;
  104268. }
  104269. }
  104270. declare module BABYLON {
  104271. interface IColor4Like {
  104272. r: float;
  104273. g: float;
  104274. b: float;
  104275. a: float;
  104276. }
  104277. /**
  104278. * Class containing a set of static utilities functions
  104279. */
  104280. export class Tools {
  104281. /**
  104282. * Gets or sets the base URL to use to load assets
  104283. */
  104284. static get BaseUrl(): string;
  104285. static set BaseUrl(value: string);
  104286. /**
  104287. * Enable/Disable Custom HTTP Request Headers globally.
  104288. * default = false
  104289. * @see CustomRequestHeaders
  104290. */
  104291. static UseCustomRequestHeaders: boolean;
  104292. /**
  104293. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104294. * i.e. when loading files, where the server/service expects an Authorization header
  104295. */
  104296. static CustomRequestHeaders: {
  104297. [key: string]: string;
  104298. };
  104299. /**
  104300. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104301. */
  104302. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  104303. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  104304. /**
  104305. * Default behaviour for cors in the application.
  104306. * It can be a string if the expected behavior is identical in the entire app.
  104307. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104308. */
  104309. static CorsBehavior: string | ((url: string | string[]) => string);
  104310. /**
  104311. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104312. * @ignorenaming
  104313. */
  104314. static get UseFallbackTexture(): boolean;
  104315. static set UseFallbackTexture(value: boolean);
  104316. /**
  104317. * Use this object to register external classes like custom textures or material
  104318. * to allow the laoders to instantiate them
  104319. */
  104320. static get RegisteredExternalClasses(): {
  104321. [key: string]: Object;
  104322. };
  104323. static set RegisteredExternalClasses(classes: {
  104324. [key: string]: Object;
  104325. });
  104326. /**
  104327. * Texture content used if a texture cannot loaded
  104328. * @ignorenaming
  104329. */
  104330. static get fallbackTexture(): string;
  104331. static set fallbackTexture(value: string);
  104332. /**
  104333. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  104334. * @param u defines the coordinate on X axis
  104335. * @param v defines the coordinate on Y axis
  104336. * @param width defines the width of the source data
  104337. * @param height defines the height of the source data
  104338. * @param pixels defines the source byte array
  104339. * @param color defines the output color
  104340. */
  104341. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  104342. /**
  104343. * Interpolates between a and b via alpha
  104344. * @param a The lower value (returned when alpha = 0)
  104345. * @param b The upper value (returned when alpha = 1)
  104346. * @param alpha The interpolation-factor
  104347. * @return The mixed value
  104348. */
  104349. static Mix(a: number, b: number, alpha: number): number;
  104350. /**
  104351. * Tries to instantiate a new object from a given class name
  104352. * @param className defines the class name to instantiate
  104353. * @returns the new object or null if the system was not able to do the instantiation
  104354. */
  104355. static Instantiate(className: string): any;
  104356. /**
  104357. * Provides a slice function that will work even on IE
  104358. * @param data defines the array to slice
  104359. * @param start defines the start of the data (optional)
  104360. * @param end defines the end of the data (optional)
  104361. * @returns the new sliced array
  104362. */
  104363. static Slice<T>(data: T, start?: number, end?: number): T;
  104364. /**
  104365. * Polyfill for setImmediate
  104366. * @param action defines the action to execute after the current execution block
  104367. */
  104368. static SetImmediate(action: () => void): void;
  104369. /**
  104370. * Function indicating if a number is an exponent of 2
  104371. * @param value defines the value to test
  104372. * @returns true if the value is an exponent of 2
  104373. */
  104374. static IsExponentOfTwo(value: number): boolean;
  104375. private static _tmpFloatArray;
  104376. /**
  104377. * Returns the nearest 32-bit single precision float representation of a Number
  104378. * @param value A Number. If the parameter is of a different type, it will get converted
  104379. * to a number or to NaN if it cannot be converted
  104380. * @returns number
  104381. */
  104382. static FloatRound(value: number): number;
  104383. /**
  104384. * Extracts the filename from a path
  104385. * @param path defines the path to use
  104386. * @returns the filename
  104387. */
  104388. static GetFilename(path: string): string;
  104389. /**
  104390. * Extracts the "folder" part of a path (everything before the filename).
  104391. * @param uri The URI to extract the info from
  104392. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  104393. * @returns The "folder" part of the path
  104394. */
  104395. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  104396. /**
  104397. * Extracts text content from a DOM element hierarchy
  104398. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104399. */
  104400. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  104401. /**
  104402. * Convert an angle in radians to degrees
  104403. * @param angle defines the angle to convert
  104404. * @returns the angle in degrees
  104405. */
  104406. static ToDegrees(angle: number): number;
  104407. /**
  104408. * Convert an angle in degrees to radians
  104409. * @param angle defines the angle to convert
  104410. * @returns the angle in radians
  104411. */
  104412. static ToRadians(angle: number): number;
  104413. /**
  104414. * Returns an array if obj is not an array
  104415. * @param obj defines the object to evaluate as an array
  104416. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  104417. * @returns either obj directly if obj is an array or a new array containing obj
  104418. */
  104419. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  104420. /**
  104421. * Gets the pointer prefix to use
  104422. * @returns "pointer" if touch is enabled. Else returns "mouse"
  104423. */
  104424. static GetPointerPrefix(): string;
  104425. /**
  104426. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  104427. * @param url define the url we are trying
  104428. * @param element define the dom element where to configure the cors policy
  104429. */
  104430. static SetCorsBehavior(url: string | string[], element: {
  104431. crossOrigin: string | null;
  104432. }): void;
  104433. /**
  104434. * Removes unwanted characters from an url
  104435. * @param url defines the url to clean
  104436. * @returns the cleaned url
  104437. */
  104438. static CleanUrl(url: string): string;
  104439. /**
  104440. * Gets or sets a function used to pre-process url before using them to load assets
  104441. */
  104442. static get PreprocessUrl(): (url: string) => string;
  104443. static set PreprocessUrl(processor: (url: string) => string);
  104444. /**
  104445. * Loads an image as an HTMLImageElement.
  104446. * @param input url string, ArrayBuffer, or Blob to load
  104447. * @param onLoad callback called when the image successfully loads
  104448. * @param onError callback called when the image fails to load
  104449. * @param offlineProvider offline provider for caching
  104450. * @param mimeType optional mime type
  104451. * @returns the HTMLImageElement of the loaded image
  104452. */
  104453. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  104454. /**
  104455. * Loads a file from a url
  104456. * @param url url string, ArrayBuffer, or Blob to load
  104457. * @param onSuccess callback called when the file successfully loads
  104458. * @param onProgress callback called while file is loading (if the server supports this mode)
  104459. * @param offlineProvider defines the offline provider for caching
  104460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104461. * @param onError callback called when the file fails to load
  104462. * @returns a file request object
  104463. */
  104464. 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;
  104465. /**
  104466. * Loads a file from a url
  104467. * @param url the file url to load
  104468. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  104469. */
  104470. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  104471. /**
  104472. * Load a script (identified by an url). When the url returns, the
  104473. * content of this file is added into a new script element, attached to the DOM (body element)
  104474. * @param scriptUrl defines the url of the script to laod
  104475. * @param onSuccess defines the callback called when the script is loaded
  104476. * @param onError defines the callback to call if an error occurs
  104477. * @param scriptId defines the id of the script element
  104478. */
  104479. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  104480. /**
  104481. * Load an asynchronous script (identified by an url). When the url returns, the
  104482. * content of this file is added into a new script element, attached to the DOM (body element)
  104483. * @param scriptUrl defines the url of the script to laod
  104484. * @param scriptId defines the id of the script element
  104485. * @returns a promise request object
  104486. */
  104487. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  104488. /**
  104489. * Loads a file from a blob
  104490. * @param fileToLoad defines the blob to use
  104491. * @param callback defines the callback to call when data is loaded
  104492. * @param progressCallback defines the callback to call during loading process
  104493. * @returns a file request object
  104494. */
  104495. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  104496. /**
  104497. * Reads a file from a File object
  104498. * @param file defines the file to load
  104499. * @param onSuccess defines the callback to call when data is loaded
  104500. * @param onProgress defines the callback to call during loading process
  104501. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  104502. * @param onError defines the callback to call when an error occurs
  104503. * @returns a file request object
  104504. */
  104505. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  104506. /**
  104507. * Creates a data url from a given string content
  104508. * @param content defines the content to convert
  104509. * @returns the new data url link
  104510. */
  104511. static FileAsURL(content: string): string;
  104512. /**
  104513. * Format the given number to a specific decimal format
  104514. * @param value defines the number to format
  104515. * @param decimals defines the number of decimals to use
  104516. * @returns the formatted string
  104517. */
  104518. static Format(value: number, decimals?: number): string;
  104519. /**
  104520. * Tries to copy an object by duplicating every property
  104521. * @param source defines the source object
  104522. * @param destination defines the target object
  104523. * @param doNotCopyList defines a list of properties to avoid
  104524. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  104525. */
  104526. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  104527. /**
  104528. * Gets a boolean indicating if the given object has no own property
  104529. * @param obj defines the object to test
  104530. * @returns true if object has no own property
  104531. */
  104532. static IsEmpty(obj: any): boolean;
  104533. /**
  104534. * Function used to register events at window level
  104535. * @param windowElement defines the Window object to use
  104536. * @param events defines the events to register
  104537. */
  104538. static RegisterTopRootEvents(windowElement: Window, events: {
  104539. name: string;
  104540. handler: Nullable<(e: FocusEvent) => any>;
  104541. }[]): void;
  104542. /**
  104543. * Function used to unregister events from window level
  104544. * @param windowElement defines the Window object to use
  104545. * @param events defines the events to unregister
  104546. */
  104547. static UnregisterTopRootEvents(windowElement: Window, events: {
  104548. name: string;
  104549. handler: Nullable<(e: FocusEvent) => any>;
  104550. }[]): void;
  104551. /**
  104552. * @ignore
  104553. */
  104554. static _ScreenshotCanvas: HTMLCanvasElement;
  104555. /**
  104556. * Dumps the current bound framebuffer
  104557. * @param width defines the rendering width
  104558. * @param height defines the rendering height
  104559. * @param engine defines the hosting engine
  104560. * @param successCallback defines the callback triggered once the data are available
  104561. * @param mimeType defines the mime type of the result
  104562. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  104563. */
  104564. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104565. /**
  104566. * Converts the canvas data to blob.
  104567. * This acts as a polyfill for browsers not supporting the to blob function.
  104568. * @param canvas Defines the canvas to extract the data from
  104569. * @param successCallback Defines the callback triggered once the data are available
  104570. * @param mimeType Defines the mime type of the result
  104571. */
  104572. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  104573. /**
  104574. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  104575. * @param successCallback defines the callback triggered once the data are available
  104576. * @param mimeType defines the mime type of the result
  104577. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  104578. */
  104579. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104580. /**
  104581. * Downloads a blob in the browser
  104582. * @param blob defines the blob to download
  104583. * @param fileName defines the name of the downloaded file
  104584. */
  104585. static Download(blob: Blob, fileName: string): void;
  104586. /**
  104587. * Captures a screenshot of the current rendering
  104588. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104589. * @param engine defines the rendering engine
  104590. * @param camera defines the source camera
  104591. * @param size This parameter can be set to a single number or to an object with the
  104592. * following (optional) properties: precision, width, height. If a single number is passed,
  104593. * it will be used for both width and height. If an object is passed, the screenshot size
  104594. * will be derived from the parameters. The precision property is a multiplier allowing
  104595. * rendering at a higher or lower resolution
  104596. * @param successCallback defines the callback receives a single parameter which contains the
  104597. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104598. * src parameter of an <img> to display it
  104599. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104600. * Check your browser for supported MIME types
  104601. */
  104602. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  104603. /**
  104604. * Captures a screenshot of the current rendering
  104605. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104606. * @param engine defines the rendering engine
  104607. * @param camera defines the source camera
  104608. * @param size This parameter can be set to a single number or to an object with the
  104609. * following (optional) properties: precision, width, height. If a single number is passed,
  104610. * it will be used for both width and height. If an object is passed, the screenshot size
  104611. * will be derived from the parameters. The precision property is a multiplier allowing
  104612. * rendering at a higher or lower resolution
  104613. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104614. * Check your browser for supported MIME types
  104615. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104616. * to the src parameter of an <img> to display it
  104617. */
  104618. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  104619. /**
  104620. * Generates an image screenshot from the specified camera.
  104621. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104622. * @param engine The engine to use for rendering
  104623. * @param camera The camera to use for rendering
  104624. * @param size This parameter can be set to a single number or to an object with the
  104625. * following (optional) properties: precision, width, height. If a single number is passed,
  104626. * it will be used for both width and height. If an object is passed, the screenshot size
  104627. * will be derived from the parameters. The precision property is a multiplier allowing
  104628. * rendering at a higher or lower resolution
  104629. * @param successCallback The callback receives a single parameter which contains the
  104630. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104631. * src parameter of an <img> to display it
  104632. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104633. * Check your browser for supported MIME types
  104634. * @param samples Texture samples (default: 1)
  104635. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104636. * @param fileName A name for for the downloaded file.
  104637. */
  104638. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  104639. /**
  104640. * Generates an image screenshot from the specified camera.
  104641. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104642. * @param engine The engine to use for rendering
  104643. * @param camera The camera to use for rendering
  104644. * @param size This parameter can be set to a single number or to an object with the
  104645. * following (optional) properties: precision, width, height. If a single number is passed,
  104646. * it will be used for both width and height. If an object is passed, the screenshot size
  104647. * will be derived from the parameters. The precision property is a multiplier allowing
  104648. * rendering at a higher or lower resolution
  104649. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104650. * Check your browser for supported MIME types
  104651. * @param samples Texture samples (default: 1)
  104652. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104653. * @param fileName A name for for the downloaded file.
  104654. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104655. * to the src parameter of an <img> to display it
  104656. */
  104657. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  104658. /**
  104659. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104660. * Be aware Math.random() could cause collisions, but:
  104661. * "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"
  104662. * @returns a pseudo random id
  104663. */
  104664. static RandomId(): string;
  104665. /**
  104666. * Test if the given uri is a base64 string
  104667. * @param uri The uri to test
  104668. * @return True if the uri is a base64 string or false otherwise
  104669. */
  104670. static IsBase64(uri: string): boolean;
  104671. /**
  104672. * Decode the given base64 uri.
  104673. * @param uri The uri to decode
  104674. * @return The decoded base64 data.
  104675. */
  104676. static DecodeBase64(uri: string): ArrayBuffer;
  104677. /**
  104678. * Gets the absolute url.
  104679. * @param url the input url
  104680. * @return the absolute url
  104681. */
  104682. static GetAbsoluteUrl(url: string): string;
  104683. /**
  104684. * No log
  104685. */
  104686. static readonly NoneLogLevel: number;
  104687. /**
  104688. * Only message logs
  104689. */
  104690. static readonly MessageLogLevel: number;
  104691. /**
  104692. * Only warning logs
  104693. */
  104694. static readonly WarningLogLevel: number;
  104695. /**
  104696. * Only error logs
  104697. */
  104698. static readonly ErrorLogLevel: number;
  104699. /**
  104700. * All logs
  104701. */
  104702. static readonly AllLogLevel: number;
  104703. /**
  104704. * Gets a value indicating the number of loading errors
  104705. * @ignorenaming
  104706. */
  104707. static get errorsCount(): number;
  104708. /**
  104709. * Callback called when a new log is added
  104710. */
  104711. static OnNewCacheEntry: (entry: string) => void;
  104712. /**
  104713. * Log a message to the console
  104714. * @param message defines the message to log
  104715. */
  104716. static Log(message: string): void;
  104717. /**
  104718. * Write a warning message to the console
  104719. * @param message defines the message to log
  104720. */
  104721. static Warn(message: string): void;
  104722. /**
  104723. * Write an error message to the console
  104724. * @param message defines the message to log
  104725. */
  104726. static Error(message: string): void;
  104727. /**
  104728. * Gets current log cache (list of logs)
  104729. */
  104730. static get LogCache(): string;
  104731. /**
  104732. * Clears the log cache
  104733. */
  104734. static ClearLogCache(): void;
  104735. /**
  104736. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104737. */
  104738. static set LogLevels(level: number);
  104739. /**
  104740. * Checks if the window object exists
  104741. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104742. */
  104743. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  104744. /**
  104745. * No performance log
  104746. */
  104747. static readonly PerformanceNoneLogLevel: number;
  104748. /**
  104749. * Use user marks to log performance
  104750. */
  104751. static readonly PerformanceUserMarkLogLevel: number;
  104752. /**
  104753. * Log performance to the console
  104754. */
  104755. static readonly PerformanceConsoleLogLevel: number;
  104756. private static _performance;
  104757. /**
  104758. * Sets the current performance log level
  104759. */
  104760. static set PerformanceLogLevel(level: number);
  104761. private static _StartPerformanceCounterDisabled;
  104762. private static _EndPerformanceCounterDisabled;
  104763. private static _StartUserMark;
  104764. private static _EndUserMark;
  104765. private static _StartPerformanceConsole;
  104766. private static _EndPerformanceConsole;
  104767. /**
  104768. * Starts a performance counter
  104769. */
  104770. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104771. /**
  104772. * Ends a specific performance coutner
  104773. */
  104774. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104775. /**
  104776. * Gets either window.performance.now() if supported or Date.now() else
  104777. */
  104778. static get Now(): number;
  104779. /**
  104780. * This method will return the name of the class used to create the instance of the given object.
  104781. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104782. * @param object the object to get the class name from
  104783. * @param isType defines if the object is actually a type
  104784. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104785. */
  104786. static GetClassName(object: any, isType?: boolean): string;
  104787. /**
  104788. * Gets the first element of an array satisfying a given predicate
  104789. * @param array defines the array to browse
  104790. * @param predicate defines the predicate to use
  104791. * @returns null if not found or the element
  104792. */
  104793. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  104794. /**
  104795. * This method will return the name of the full name of the class, including its owning module (if any).
  104796. * 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).
  104797. * @param object the object to get the class name from
  104798. * @param isType defines if the object is actually a type
  104799. * @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.
  104800. * @ignorenaming
  104801. */
  104802. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  104803. /**
  104804. * Returns a promise that resolves after the given amount of time.
  104805. * @param delay Number of milliseconds to delay
  104806. * @returns Promise that resolves after the given amount of time
  104807. */
  104808. static DelayAsync(delay: number): Promise<void>;
  104809. }
  104810. /**
  104811. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104812. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104813. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104814. * @param name The name of the class, case should be preserved
  104815. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104816. */
  104817. export function className(name: string, module?: string): (target: Object) => void;
  104818. /**
  104819. * An implementation of a loop for asynchronous functions.
  104820. */
  104821. export class AsyncLoop {
  104822. /**
  104823. * Defines the number of iterations for the loop
  104824. */
  104825. iterations: number;
  104826. /**
  104827. * Defines the current index of the loop.
  104828. */
  104829. index: number;
  104830. private _done;
  104831. private _fn;
  104832. private _successCallback;
  104833. /**
  104834. * Constructor.
  104835. * @param iterations the number of iterations.
  104836. * @param func the function to run each iteration
  104837. * @param successCallback the callback that will be called upon succesful execution
  104838. * @param offset starting offset.
  104839. */
  104840. constructor(
  104841. /**
  104842. * Defines the number of iterations for the loop
  104843. */
  104844. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  104845. /**
  104846. * Execute the next iteration. Must be called after the last iteration was finished.
  104847. */
  104848. executeNext(): void;
  104849. /**
  104850. * Break the loop and run the success callback.
  104851. */
  104852. breakLoop(): void;
  104853. /**
  104854. * Create and run an async loop.
  104855. * @param iterations the number of iterations.
  104856. * @param fn the function to run each iteration
  104857. * @param successCallback the callback that will be called upon succesful execution
  104858. * @param offset starting offset.
  104859. * @returns the created async loop object
  104860. */
  104861. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  104862. /**
  104863. * A for-loop that will run a given number of iterations synchronous and the rest async.
  104864. * @param iterations total number of iterations
  104865. * @param syncedIterations number of synchronous iterations in each async iteration.
  104866. * @param fn the function to call each iteration.
  104867. * @param callback a success call back that will be called when iterating stops.
  104868. * @param breakFunction a break condition (optional)
  104869. * @param timeout timeout settings for the setTimeout function. default - 0.
  104870. * @returns the created async loop object
  104871. */
  104872. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  104873. }
  104874. }
  104875. declare module BABYLON {
  104876. /**
  104877. * This class implement a typical dictionary using a string as key and the generic type T as value.
  104878. * The underlying implementation relies on an associative array to ensure the best performances.
  104879. * The value can be anything including 'null' but except 'undefined'
  104880. */
  104881. export class StringDictionary<T> {
  104882. /**
  104883. * This will clear this dictionary and copy the content from the 'source' one.
  104884. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  104885. * @param source the dictionary to take the content from and copy to this dictionary
  104886. */
  104887. copyFrom(source: StringDictionary<T>): void;
  104888. /**
  104889. * Get a value based from its key
  104890. * @param key the given key to get the matching value from
  104891. * @return the value if found, otherwise undefined is returned
  104892. */
  104893. get(key: string): T | undefined;
  104894. /**
  104895. * Get a value from its key or add it if it doesn't exist.
  104896. * This method will ensure you that a given key/data will be present in the dictionary.
  104897. * @param key the given key to get the matching value from
  104898. * @param factory the factory that will create the value if the key is not present in the dictionary.
  104899. * The factory will only be invoked if there's no data for the given key.
  104900. * @return the value corresponding to the key.
  104901. */
  104902. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  104903. /**
  104904. * Get a value from its key if present in the dictionary otherwise add it
  104905. * @param key the key to get the value from
  104906. * @param val if there's no such key/value pair in the dictionary add it with this value
  104907. * @return the value corresponding to the key
  104908. */
  104909. getOrAdd(key: string, val: T): T;
  104910. /**
  104911. * Check if there's a given key in the dictionary
  104912. * @param key the key to check for
  104913. * @return true if the key is present, false otherwise
  104914. */
  104915. contains(key: string): boolean;
  104916. /**
  104917. * Add a new key and its corresponding value
  104918. * @param key the key to add
  104919. * @param value the value corresponding to the key
  104920. * @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
  104921. */
  104922. add(key: string, value: T): boolean;
  104923. /**
  104924. * Update a specific value associated to a key
  104925. * @param key defines the key to use
  104926. * @param value defines the value to store
  104927. * @returns true if the value was updated (or false if the key was not found)
  104928. */
  104929. set(key: string, value: T): boolean;
  104930. /**
  104931. * Get the element of the given key and remove it from the dictionary
  104932. * @param key defines the key to search
  104933. * @returns the value associated with the key or null if not found
  104934. */
  104935. getAndRemove(key: string): Nullable<T>;
  104936. /**
  104937. * Remove a key/value from the dictionary.
  104938. * @param key the key to remove
  104939. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  104940. */
  104941. remove(key: string): boolean;
  104942. /**
  104943. * Clear the whole content of the dictionary
  104944. */
  104945. clear(): void;
  104946. /**
  104947. * Gets the current count
  104948. */
  104949. get count(): number;
  104950. /**
  104951. * Execute a callback on each key/val of the dictionary.
  104952. * Note that you can remove any element in this dictionary in the callback implementation
  104953. * @param callback the callback to execute on a given key/value pair
  104954. */
  104955. forEach(callback: (key: string, val: T) => void): void;
  104956. /**
  104957. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  104958. * If the callback returns null or undefined the method will iterate to the next key/value pair
  104959. * Note that you can remove any element in this dictionary in the callback implementation
  104960. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  104961. * @returns the first item
  104962. */
  104963. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  104964. private _count;
  104965. private _data;
  104966. }
  104967. }
  104968. declare module BABYLON {
  104969. /** @hidden */
  104970. export interface ICollisionCoordinator {
  104971. createCollider(): Collider;
  104972. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104973. init(scene: Scene): void;
  104974. }
  104975. /** @hidden */
  104976. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  104977. private _scene;
  104978. private _scaledPosition;
  104979. private _scaledVelocity;
  104980. private _finalPosition;
  104981. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104982. createCollider(): Collider;
  104983. init(scene: Scene): void;
  104984. private _collideWithWorld;
  104985. }
  104986. }
  104987. declare module BABYLON {
  104988. /**
  104989. * Class used to manage all inputs for the scene.
  104990. */
  104991. export class InputManager {
  104992. /** The distance in pixel that you have to move to prevent some events */
  104993. static DragMovementThreshold: number;
  104994. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  104995. static LongPressDelay: number;
  104996. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  104997. static DoubleClickDelay: number;
  104998. /** If you need to check double click without raising a single click at first click, enable this flag */
  104999. static ExclusiveDoubleClickMode: boolean;
  105000. private _wheelEventName;
  105001. private _onPointerMove;
  105002. private _onPointerDown;
  105003. private _onPointerUp;
  105004. private _initClickEvent;
  105005. private _initActionManager;
  105006. private _delayedSimpleClick;
  105007. private _delayedSimpleClickTimeout;
  105008. private _previousDelayedSimpleClickTimeout;
  105009. private _meshPickProceed;
  105010. private _previousButtonPressed;
  105011. private _currentPickResult;
  105012. private _previousPickResult;
  105013. private _totalPointersPressed;
  105014. private _doubleClickOccured;
  105015. private _pointerOverMesh;
  105016. private _pickedDownMesh;
  105017. private _pickedUpMesh;
  105018. private _pointerX;
  105019. private _pointerY;
  105020. private _unTranslatedPointerX;
  105021. private _unTranslatedPointerY;
  105022. private _startingPointerPosition;
  105023. private _previousStartingPointerPosition;
  105024. private _startingPointerTime;
  105025. private _previousStartingPointerTime;
  105026. private _pointerCaptures;
  105027. private _onKeyDown;
  105028. private _onKeyUp;
  105029. private _onCanvasFocusObserver;
  105030. private _onCanvasBlurObserver;
  105031. private _scene;
  105032. /**
  105033. * Creates a new InputManager
  105034. * @param scene defines the hosting scene
  105035. */
  105036. constructor(scene: Scene);
  105037. /**
  105038. * Gets the mesh that is currently under the pointer
  105039. */
  105040. get meshUnderPointer(): Nullable<AbstractMesh>;
  105041. /**
  105042. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105043. */
  105044. get unTranslatedPointer(): Vector2;
  105045. /**
  105046. * Gets or sets the current on-screen X position of the pointer
  105047. */
  105048. get pointerX(): number;
  105049. set pointerX(value: number);
  105050. /**
  105051. * Gets or sets the current on-screen Y position of the pointer
  105052. */
  105053. get pointerY(): number;
  105054. set pointerY(value: number);
  105055. private _updatePointerPosition;
  105056. private _processPointerMove;
  105057. private _setRayOnPointerInfo;
  105058. private _checkPrePointerObservable;
  105059. /**
  105060. * Use this method to simulate a pointer move on a mesh
  105061. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105062. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105063. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105064. */
  105065. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105066. /**
  105067. * Use this method to simulate a pointer down 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. */
  105072. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105073. private _processPointerDown;
  105074. /** @hidden */
  105075. _isPointerSwiping(): boolean;
  105076. /**
  105077. * Use this method to simulate a pointer up on a mesh
  105078. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105079. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105080. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105081. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105082. */
  105083. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105084. private _processPointerUp;
  105085. /**
  105086. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105087. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105088. * @returns true if the pointer was captured
  105089. */
  105090. isPointerCaptured(pointerId?: number): boolean;
  105091. /**
  105092. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105093. * @param attachUp defines if you want to attach events to pointerup
  105094. * @param attachDown defines if you want to attach events to pointerdown
  105095. * @param attachMove defines if you want to attach events to pointermove
  105096. */
  105097. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105098. /**
  105099. * Detaches all event handlers
  105100. */
  105101. detachControl(): void;
  105102. /**
  105103. * Force the value of meshUnderPointer
  105104. * @param mesh defines the mesh to use
  105105. */
  105106. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105107. /**
  105108. * Gets the mesh under the pointer
  105109. * @returns a Mesh or null if no mesh is under the pointer
  105110. */
  105111. getPointerOverMesh(): Nullable<AbstractMesh>;
  105112. }
  105113. }
  105114. declare module BABYLON {
  105115. /**
  105116. * Helper class used to generate session unique ID
  105117. */
  105118. export class UniqueIdGenerator {
  105119. private static _UniqueIdCounter;
  105120. /**
  105121. * Gets an unique (relatively to the current scene) Id
  105122. */
  105123. static get UniqueId(): number;
  105124. }
  105125. }
  105126. declare module BABYLON {
  105127. /**
  105128. * This class defines the direct association between an animation and a target
  105129. */
  105130. export class TargetedAnimation {
  105131. /**
  105132. * Animation to perform
  105133. */
  105134. animation: Animation;
  105135. /**
  105136. * Target to animate
  105137. */
  105138. target: any;
  105139. /**
  105140. * Serialize the object
  105141. * @returns the JSON object representing the current entity
  105142. */
  105143. serialize(): any;
  105144. }
  105145. /**
  105146. * Use this class to create coordinated animations on multiple targets
  105147. */
  105148. export class AnimationGroup implements IDisposable {
  105149. /** The name of the animation group */
  105150. name: string;
  105151. private _scene;
  105152. private _targetedAnimations;
  105153. private _animatables;
  105154. private _from;
  105155. private _to;
  105156. private _isStarted;
  105157. private _isPaused;
  105158. private _speedRatio;
  105159. private _loopAnimation;
  105160. /**
  105161. * Gets or sets the unique id of the node
  105162. */
  105163. uniqueId: number;
  105164. /**
  105165. * This observable will notify when one animation have ended
  105166. */
  105167. onAnimationEndObservable: Observable<TargetedAnimation>;
  105168. /**
  105169. * Observer raised when one animation loops
  105170. */
  105171. onAnimationLoopObservable: Observable<TargetedAnimation>;
  105172. /**
  105173. * Observer raised when all animations have looped
  105174. */
  105175. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  105176. /**
  105177. * This observable will notify when all animations have ended.
  105178. */
  105179. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  105180. /**
  105181. * This observable will notify when all animations have paused.
  105182. */
  105183. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  105184. /**
  105185. * This observable will notify when all animations are playing.
  105186. */
  105187. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  105188. /**
  105189. * Gets the first frame
  105190. */
  105191. get from(): number;
  105192. /**
  105193. * Gets the last frame
  105194. */
  105195. get to(): number;
  105196. /**
  105197. * Define if the animations are started
  105198. */
  105199. get isStarted(): boolean;
  105200. /**
  105201. * Gets a value indicating that the current group is playing
  105202. */
  105203. get isPlaying(): boolean;
  105204. /**
  105205. * Gets or sets the speed ratio to use for all animations
  105206. */
  105207. get speedRatio(): number;
  105208. /**
  105209. * Gets or sets the speed ratio to use for all animations
  105210. */
  105211. set speedRatio(value: number);
  105212. /**
  105213. * Gets or sets if all animations should loop or not
  105214. */
  105215. get loopAnimation(): boolean;
  105216. set loopAnimation(value: boolean);
  105217. /**
  105218. * Gets the targeted animations for this animation group
  105219. */
  105220. get targetedAnimations(): Array<TargetedAnimation>;
  105221. /**
  105222. * returning the list of animatables controlled by this animation group.
  105223. */
  105224. get animatables(): Array<Animatable>;
  105225. /**
  105226. * Instantiates a new Animation Group.
  105227. * This helps managing several animations at once.
  105228. * @see http://doc.babylonjs.com/how_to/group
  105229. * @param name Defines the name of the group
  105230. * @param scene Defines the scene the group belongs to
  105231. */
  105232. constructor(
  105233. /** The name of the animation group */
  105234. name: string, scene?: Nullable<Scene>);
  105235. /**
  105236. * Add an animation (with its target) in the group
  105237. * @param animation defines the animation we want to add
  105238. * @param target defines the target of the animation
  105239. * @returns the TargetedAnimation object
  105240. */
  105241. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  105242. /**
  105243. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  105244. * It can add constant keys at begin or end
  105245. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  105246. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  105247. * @returns the animation group
  105248. */
  105249. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  105250. private _animationLoopCount;
  105251. private _animationLoopFlags;
  105252. private _processLoop;
  105253. /**
  105254. * Start all animations on given targets
  105255. * @param loop defines if animations must loop
  105256. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  105257. * @param from defines the from key (optional)
  105258. * @param to defines the to key (optional)
  105259. * @returns the current animation group
  105260. */
  105261. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  105262. /**
  105263. * Pause all animations
  105264. * @returns the animation group
  105265. */
  105266. pause(): AnimationGroup;
  105267. /**
  105268. * Play all animations to initial state
  105269. * This function will start() the animations if they were not started or will restart() them if they were paused
  105270. * @param loop defines if animations must loop
  105271. * @returns the animation group
  105272. */
  105273. play(loop?: boolean): AnimationGroup;
  105274. /**
  105275. * Reset all animations to initial state
  105276. * @returns the animation group
  105277. */
  105278. reset(): AnimationGroup;
  105279. /**
  105280. * Restart animations from key 0
  105281. * @returns the animation group
  105282. */
  105283. restart(): AnimationGroup;
  105284. /**
  105285. * Stop all animations
  105286. * @returns the animation group
  105287. */
  105288. stop(): AnimationGroup;
  105289. /**
  105290. * Set animation weight for all animatables
  105291. * @param weight defines the weight to use
  105292. * @return the animationGroup
  105293. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105294. */
  105295. setWeightForAllAnimatables(weight: number): AnimationGroup;
  105296. /**
  105297. * Synchronize and normalize all animatables with a source animatable
  105298. * @param root defines the root animatable to synchronize with
  105299. * @return the animationGroup
  105300. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105301. */
  105302. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  105303. /**
  105304. * Goes to a specific frame in this animation group
  105305. * @param frame the frame number to go to
  105306. * @return the animationGroup
  105307. */
  105308. goToFrame(frame: number): AnimationGroup;
  105309. /**
  105310. * Dispose all associated resources
  105311. */
  105312. dispose(): void;
  105313. private _checkAnimationGroupEnded;
  105314. /**
  105315. * Clone the current animation group and returns a copy
  105316. * @param newName defines the name of the new group
  105317. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  105318. * @returns the new aniamtion group
  105319. */
  105320. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  105321. /**
  105322. * Serializes the animationGroup to an object
  105323. * @returns Serialized object
  105324. */
  105325. serialize(): any;
  105326. /**
  105327. * Returns a new AnimationGroup object parsed from the source provided.
  105328. * @param parsedAnimationGroup defines the source
  105329. * @param scene defines the scene that will receive the animationGroup
  105330. * @returns a new AnimationGroup
  105331. */
  105332. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  105333. /**
  105334. * Returns the string "AnimationGroup"
  105335. * @returns "AnimationGroup"
  105336. */
  105337. getClassName(): string;
  105338. /**
  105339. * Creates a detailled string about the object
  105340. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  105341. * @returns a string representing the object
  105342. */
  105343. toString(fullDetails?: boolean): string;
  105344. }
  105345. }
  105346. declare module BABYLON {
  105347. /**
  105348. * Define an interface for all classes that will hold resources
  105349. */
  105350. export interface IDisposable {
  105351. /**
  105352. * Releases all held resources
  105353. */
  105354. dispose(): void;
  105355. }
  105356. /** Interface defining initialization parameters for Scene class */
  105357. export interface SceneOptions {
  105358. /**
  105359. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  105360. * It will improve performance when the number of geometries becomes important.
  105361. */
  105362. useGeometryUniqueIdsMap?: boolean;
  105363. /**
  105364. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  105365. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105366. */
  105367. useMaterialMeshMap?: boolean;
  105368. /**
  105369. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  105370. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105371. */
  105372. useClonedMeshhMap?: boolean;
  105373. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  105374. virtual?: boolean;
  105375. }
  105376. /**
  105377. * Represents a scene to be rendered by the engine.
  105378. * @see http://doc.babylonjs.com/features/scene
  105379. */
  105380. export class Scene extends AbstractScene implements IAnimatable {
  105381. /** The fog is deactivated */
  105382. static readonly FOGMODE_NONE: number;
  105383. /** The fog density is following an exponential function */
  105384. static readonly FOGMODE_EXP: number;
  105385. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  105386. static readonly FOGMODE_EXP2: number;
  105387. /** The fog density is following a linear function. */
  105388. static readonly FOGMODE_LINEAR: number;
  105389. /**
  105390. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  105391. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105392. */
  105393. static MinDeltaTime: number;
  105394. /**
  105395. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  105396. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105397. */
  105398. static MaxDeltaTime: number;
  105399. /**
  105400. * Factory used to create the default material.
  105401. * @param name The name of the material to create
  105402. * @param scene The scene to create the material for
  105403. * @returns The default material
  105404. */
  105405. static DefaultMaterialFactory(scene: Scene): Material;
  105406. /**
  105407. * Factory used to create the a collision coordinator.
  105408. * @returns The collision coordinator
  105409. */
  105410. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  105411. /** @hidden */
  105412. _inputManager: InputManager;
  105413. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  105414. cameraToUseForPointers: Nullable<Camera>;
  105415. /** @hidden */
  105416. readonly _isScene: boolean;
  105417. /**
  105418. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  105419. */
  105420. autoClear: boolean;
  105421. /**
  105422. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  105423. */
  105424. autoClearDepthAndStencil: boolean;
  105425. /**
  105426. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  105427. */
  105428. clearColor: Color4;
  105429. /**
  105430. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  105431. */
  105432. ambientColor: Color3;
  105433. /**
  105434. * This is use to store the default BRDF lookup for PBR materials in your scene.
  105435. * It should only be one of the following (if not the default embedded one):
  105436. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105437. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  105438. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105439. * The material properties need to be setup according to the type of texture in use.
  105440. */
  105441. environmentBRDFTexture: BaseTexture;
  105442. /** @hidden */
  105443. protected _environmentTexture: Nullable<BaseTexture>;
  105444. /**
  105445. * Texture used in all pbr material as the reflection texture.
  105446. * As in the majority of the scene they are the same (exception for multi room and so on),
  105447. * this is easier to reference from here than from all the materials.
  105448. */
  105449. get environmentTexture(): Nullable<BaseTexture>;
  105450. /**
  105451. * Texture used in all pbr material as the reflection texture.
  105452. * As in the majority of the scene they are the same (exception for multi room and so on),
  105453. * this is easier to set here than in all the materials.
  105454. */
  105455. set environmentTexture(value: Nullable<BaseTexture>);
  105456. /** @hidden */
  105457. protected _environmentIntensity: number;
  105458. /**
  105459. * Intensity of the environment in all pbr material.
  105460. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105461. * As in the majority of the scene they are the same (exception for multi room and so on),
  105462. * this is easier to reference from here than from all the materials.
  105463. */
  105464. get environmentIntensity(): number;
  105465. /**
  105466. * Intensity of the environment in all pbr material.
  105467. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105468. * As in the majority of the scene they are the same (exception for multi room and so on),
  105469. * this is easier to set here than in all the materials.
  105470. */
  105471. set environmentIntensity(value: number);
  105472. /** @hidden */
  105473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105474. /**
  105475. * Default image processing configuration used either in the rendering
  105476. * Forward main pass or through the imageProcessingPostProcess if present.
  105477. * As in the majority of the scene they are the same (exception for multi camera),
  105478. * this is easier to reference from here than from all the materials and post process.
  105479. *
  105480. * No setter as we it is a shared configuration, you can set the values instead.
  105481. */
  105482. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105483. private _forceWireframe;
  105484. /**
  105485. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  105486. */
  105487. set forceWireframe(value: boolean);
  105488. get forceWireframe(): boolean;
  105489. private _skipFrustumClipping;
  105490. /**
  105491. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  105492. */
  105493. set skipFrustumClipping(value: boolean);
  105494. get skipFrustumClipping(): boolean;
  105495. private _forcePointsCloud;
  105496. /**
  105497. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  105498. */
  105499. set forcePointsCloud(value: boolean);
  105500. get forcePointsCloud(): boolean;
  105501. /**
  105502. * Gets or sets the active clipplane 1
  105503. */
  105504. clipPlane: Nullable<Plane>;
  105505. /**
  105506. * Gets or sets the active clipplane 2
  105507. */
  105508. clipPlane2: Nullable<Plane>;
  105509. /**
  105510. * Gets or sets the active clipplane 3
  105511. */
  105512. clipPlane3: Nullable<Plane>;
  105513. /**
  105514. * Gets or sets the active clipplane 4
  105515. */
  105516. clipPlane4: Nullable<Plane>;
  105517. /**
  105518. * Gets or sets the active clipplane 5
  105519. */
  105520. clipPlane5: Nullable<Plane>;
  105521. /**
  105522. * Gets or sets the active clipplane 6
  105523. */
  105524. clipPlane6: Nullable<Plane>;
  105525. /**
  105526. * Gets or sets a boolean indicating if animations are enabled
  105527. */
  105528. animationsEnabled: boolean;
  105529. private _animationPropertiesOverride;
  105530. /**
  105531. * Gets or sets the animation properties override
  105532. */
  105533. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105534. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105535. /**
  105536. * Gets or sets a boolean indicating if a constant deltatime has to be used
  105537. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  105538. */
  105539. useConstantAnimationDeltaTime: boolean;
  105540. /**
  105541. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  105542. * Please note that it requires to run a ray cast through the scene on every frame
  105543. */
  105544. constantlyUpdateMeshUnderPointer: boolean;
  105545. /**
  105546. * Defines the HTML cursor to use when hovering over interactive elements
  105547. */
  105548. hoverCursor: string;
  105549. /**
  105550. * Defines the HTML default cursor to use (empty by default)
  105551. */
  105552. defaultCursor: string;
  105553. /**
  105554. * Defines wether cursors are handled by the scene.
  105555. */
  105556. doNotHandleCursors: boolean;
  105557. /**
  105558. * This is used to call preventDefault() on pointer down
  105559. * in order to block unwanted artifacts like system double clicks
  105560. */
  105561. preventDefaultOnPointerDown: boolean;
  105562. /**
  105563. * This is used to call preventDefault() on pointer up
  105564. * in order to block unwanted artifacts like system double clicks
  105565. */
  105566. preventDefaultOnPointerUp: boolean;
  105567. /**
  105568. * Gets or sets user defined metadata
  105569. */
  105570. metadata: any;
  105571. /**
  105572. * For internal use only. Please do not use.
  105573. */
  105574. reservedDataStore: any;
  105575. /**
  105576. * Gets the name of the plugin used to load this scene (null by default)
  105577. */
  105578. loadingPluginName: string;
  105579. /**
  105580. * Use this array to add regular expressions used to disable offline support for specific urls
  105581. */
  105582. disableOfflineSupportExceptionRules: RegExp[];
  105583. /**
  105584. * An event triggered when the scene is disposed.
  105585. */
  105586. onDisposeObservable: Observable<Scene>;
  105587. private _onDisposeObserver;
  105588. /** Sets a function to be executed when this scene is disposed. */
  105589. set onDispose(callback: () => void);
  105590. /**
  105591. * An event triggered before rendering the scene (right after animations and physics)
  105592. */
  105593. onBeforeRenderObservable: Observable<Scene>;
  105594. private _onBeforeRenderObserver;
  105595. /** Sets a function to be executed before rendering this scene */
  105596. set beforeRender(callback: Nullable<() => void>);
  105597. /**
  105598. * An event triggered after rendering the scene
  105599. */
  105600. onAfterRenderObservable: Observable<Scene>;
  105601. /**
  105602. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  105603. */
  105604. onAfterRenderCameraObservable: Observable<Camera>;
  105605. private _onAfterRenderObserver;
  105606. /** Sets a function to be executed after rendering this scene */
  105607. set afterRender(callback: Nullable<() => void>);
  105608. /**
  105609. * An event triggered before animating the scene
  105610. */
  105611. onBeforeAnimationsObservable: Observable<Scene>;
  105612. /**
  105613. * An event triggered after animations processing
  105614. */
  105615. onAfterAnimationsObservable: Observable<Scene>;
  105616. /**
  105617. * An event triggered before draw calls are ready to be sent
  105618. */
  105619. onBeforeDrawPhaseObservable: Observable<Scene>;
  105620. /**
  105621. * An event triggered after draw calls have been sent
  105622. */
  105623. onAfterDrawPhaseObservable: Observable<Scene>;
  105624. /**
  105625. * An event triggered when the scene is ready
  105626. */
  105627. onReadyObservable: Observable<Scene>;
  105628. /**
  105629. * An event triggered before rendering a camera
  105630. */
  105631. onBeforeCameraRenderObservable: Observable<Camera>;
  105632. private _onBeforeCameraRenderObserver;
  105633. /** Sets a function to be executed before rendering a camera*/
  105634. set beforeCameraRender(callback: () => void);
  105635. /**
  105636. * An event triggered after rendering a camera
  105637. */
  105638. onAfterCameraRenderObservable: Observable<Camera>;
  105639. private _onAfterCameraRenderObserver;
  105640. /** Sets a function to be executed after rendering a camera*/
  105641. set afterCameraRender(callback: () => void);
  105642. /**
  105643. * An event triggered when active meshes evaluation is about to start
  105644. */
  105645. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  105646. /**
  105647. * An event triggered when active meshes evaluation is done
  105648. */
  105649. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  105650. /**
  105651. * An event triggered when particles rendering is about to start
  105652. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105653. */
  105654. onBeforeParticlesRenderingObservable: Observable<Scene>;
  105655. /**
  105656. * An event triggered when particles rendering is done
  105657. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105658. */
  105659. onAfterParticlesRenderingObservable: Observable<Scene>;
  105660. /**
  105661. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  105662. */
  105663. onDataLoadedObservable: Observable<Scene>;
  105664. /**
  105665. * An event triggered when a camera is created
  105666. */
  105667. onNewCameraAddedObservable: Observable<Camera>;
  105668. /**
  105669. * An event triggered when a camera is removed
  105670. */
  105671. onCameraRemovedObservable: Observable<Camera>;
  105672. /**
  105673. * An event triggered when a light is created
  105674. */
  105675. onNewLightAddedObservable: Observable<Light>;
  105676. /**
  105677. * An event triggered when a light is removed
  105678. */
  105679. onLightRemovedObservable: Observable<Light>;
  105680. /**
  105681. * An event triggered when a geometry is created
  105682. */
  105683. onNewGeometryAddedObservable: Observable<Geometry>;
  105684. /**
  105685. * An event triggered when a geometry is removed
  105686. */
  105687. onGeometryRemovedObservable: Observable<Geometry>;
  105688. /**
  105689. * An event triggered when a transform node is created
  105690. */
  105691. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  105692. /**
  105693. * An event triggered when a transform node is removed
  105694. */
  105695. onTransformNodeRemovedObservable: Observable<TransformNode>;
  105696. /**
  105697. * An event triggered when a mesh is created
  105698. */
  105699. onNewMeshAddedObservable: Observable<AbstractMesh>;
  105700. /**
  105701. * An event triggered when a mesh is removed
  105702. */
  105703. onMeshRemovedObservable: Observable<AbstractMesh>;
  105704. /**
  105705. * An event triggered when a skeleton is created
  105706. */
  105707. onNewSkeletonAddedObservable: Observable<Skeleton>;
  105708. /**
  105709. * An event triggered when a skeleton is removed
  105710. */
  105711. onSkeletonRemovedObservable: Observable<Skeleton>;
  105712. /**
  105713. * An event triggered when a material is created
  105714. */
  105715. onNewMaterialAddedObservable: Observable<Material>;
  105716. /**
  105717. * An event triggered when a material is removed
  105718. */
  105719. onMaterialRemovedObservable: Observable<Material>;
  105720. /**
  105721. * An event triggered when a texture is created
  105722. */
  105723. onNewTextureAddedObservable: Observable<BaseTexture>;
  105724. /**
  105725. * An event triggered when a texture is removed
  105726. */
  105727. onTextureRemovedObservable: Observable<BaseTexture>;
  105728. /**
  105729. * An event triggered when render targets are about to be rendered
  105730. * Can happen multiple times per frame.
  105731. */
  105732. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  105733. /**
  105734. * An event triggered when render targets were rendered.
  105735. * Can happen multiple times per frame.
  105736. */
  105737. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  105738. /**
  105739. * An event triggered before calculating deterministic simulation step
  105740. */
  105741. onBeforeStepObservable: Observable<Scene>;
  105742. /**
  105743. * An event triggered after calculating deterministic simulation step
  105744. */
  105745. onAfterStepObservable: Observable<Scene>;
  105746. /**
  105747. * An event triggered when the activeCamera property is updated
  105748. */
  105749. onActiveCameraChanged: Observable<Scene>;
  105750. /**
  105751. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  105752. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105753. * 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)
  105754. */
  105755. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105756. /**
  105757. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  105758. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105759. * 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)
  105760. */
  105761. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105762. /**
  105763. * This Observable will when a mesh has been imported into the scene.
  105764. */
  105765. onMeshImportedObservable: Observable<AbstractMesh>;
  105766. /**
  105767. * This Observable will when an animation file has been imported into the scene.
  105768. */
  105769. onAnimationFileImportedObservable: Observable<Scene>;
  105770. /**
  105771. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  105772. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  105773. */
  105774. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  105775. /** @hidden */
  105776. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  105777. /**
  105778. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  105779. */
  105780. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  105781. /**
  105782. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  105783. */
  105784. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  105785. /**
  105786. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  105787. */
  105788. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  105789. /** Callback called when a pointer move is detected */
  105790. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105791. /** Callback called when a pointer down is detected */
  105792. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105793. /** Callback called when a pointer up is detected */
  105794. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  105795. /** Callback called when a pointer pick is detected */
  105796. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  105797. /**
  105798. * 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).
  105799. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  105800. */
  105801. onPrePointerObservable: Observable<PointerInfoPre>;
  105802. /**
  105803. * Observable event triggered each time an input event is received from the rendering canvas
  105804. */
  105805. onPointerObservable: Observable<PointerInfo>;
  105806. /**
  105807. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  105808. */
  105809. get unTranslatedPointer(): Vector2;
  105810. /**
  105811. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  105812. */
  105813. static get DragMovementThreshold(): number;
  105814. static set DragMovementThreshold(value: number);
  105815. /**
  105816. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  105817. */
  105818. static get LongPressDelay(): number;
  105819. static set LongPressDelay(value: number);
  105820. /**
  105821. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  105822. */
  105823. static get DoubleClickDelay(): number;
  105824. static set DoubleClickDelay(value: number);
  105825. /** If you need to check double click without raising a single click at first click, enable this flag */
  105826. static get ExclusiveDoubleClickMode(): boolean;
  105827. static set ExclusiveDoubleClickMode(value: boolean);
  105828. /** @hidden */
  105829. _mirroredCameraPosition: Nullable<Vector3>;
  105830. /**
  105831. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  105832. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  105833. */
  105834. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  105835. /**
  105836. * Observable event triggered each time an keyboard event is received from the hosting window
  105837. */
  105838. onKeyboardObservable: Observable<KeyboardInfo>;
  105839. private _useRightHandedSystem;
  105840. /**
  105841. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  105842. */
  105843. set useRightHandedSystem(value: boolean);
  105844. get useRightHandedSystem(): boolean;
  105845. private _timeAccumulator;
  105846. private _currentStepId;
  105847. private _currentInternalStep;
  105848. /**
  105849. * Sets the step Id used by deterministic lock step
  105850. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105851. * @param newStepId defines the step Id
  105852. */
  105853. setStepId(newStepId: number): void;
  105854. /**
  105855. * Gets the step Id used by deterministic lock step
  105856. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105857. * @returns the step Id
  105858. */
  105859. getStepId(): number;
  105860. /**
  105861. * Gets the internal step used by deterministic lock step
  105862. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105863. * @returns the internal step
  105864. */
  105865. getInternalStep(): number;
  105866. private _fogEnabled;
  105867. /**
  105868. * Gets or sets a boolean indicating if fog is enabled on this scene
  105869. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105870. * (Default is true)
  105871. */
  105872. set fogEnabled(value: boolean);
  105873. get fogEnabled(): boolean;
  105874. private _fogMode;
  105875. /**
  105876. * Gets or sets the fog mode to use
  105877. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105878. * | mode | value |
  105879. * | --- | --- |
  105880. * | FOGMODE_NONE | 0 |
  105881. * | FOGMODE_EXP | 1 |
  105882. * | FOGMODE_EXP2 | 2 |
  105883. * | FOGMODE_LINEAR | 3 |
  105884. */
  105885. set fogMode(value: number);
  105886. get fogMode(): number;
  105887. /**
  105888. * Gets or sets the fog color to use
  105889. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105890. * (Default is Color3(0.2, 0.2, 0.3))
  105891. */
  105892. fogColor: Color3;
  105893. /**
  105894. * Gets or sets the fog density to use
  105895. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105896. * (Default is 0.1)
  105897. */
  105898. fogDensity: number;
  105899. /**
  105900. * Gets or sets the fog start distance to use
  105901. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105902. * (Default is 0)
  105903. */
  105904. fogStart: number;
  105905. /**
  105906. * Gets or sets the fog end distance to use
  105907. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105908. * (Default is 1000)
  105909. */
  105910. fogEnd: number;
  105911. private _shadowsEnabled;
  105912. /**
  105913. * Gets or sets a boolean indicating if shadows are enabled on this scene
  105914. */
  105915. set shadowsEnabled(value: boolean);
  105916. get shadowsEnabled(): boolean;
  105917. private _lightsEnabled;
  105918. /**
  105919. * Gets or sets a boolean indicating if lights are enabled on this scene
  105920. */
  105921. set lightsEnabled(value: boolean);
  105922. get lightsEnabled(): boolean;
  105923. /** All of the active cameras added to this scene. */
  105924. activeCameras: Camera[];
  105925. /** @hidden */
  105926. _activeCamera: Nullable<Camera>;
  105927. /** Gets or sets the current active camera */
  105928. get activeCamera(): Nullable<Camera>;
  105929. set activeCamera(value: Nullable<Camera>);
  105930. private _defaultMaterial;
  105931. /** The default material used on meshes when no material is affected */
  105932. get defaultMaterial(): Material;
  105933. /** The default material used on meshes when no material is affected */
  105934. set defaultMaterial(value: Material);
  105935. private _texturesEnabled;
  105936. /**
  105937. * Gets or sets a boolean indicating if textures are enabled on this scene
  105938. */
  105939. set texturesEnabled(value: boolean);
  105940. get texturesEnabled(): boolean;
  105941. /**
  105942. * Gets or sets a boolean indicating if particles are enabled on this scene
  105943. */
  105944. particlesEnabled: boolean;
  105945. /**
  105946. * Gets or sets a boolean indicating if sprites are enabled on this scene
  105947. */
  105948. spritesEnabled: boolean;
  105949. private _skeletonsEnabled;
  105950. /**
  105951. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  105952. */
  105953. set skeletonsEnabled(value: boolean);
  105954. get skeletonsEnabled(): boolean;
  105955. /**
  105956. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  105957. */
  105958. lensFlaresEnabled: boolean;
  105959. /**
  105960. * Gets or sets a boolean indicating if collisions are enabled on this scene
  105961. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105962. */
  105963. collisionsEnabled: boolean;
  105964. private _collisionCoordinator;
  105965. /** @hidden */
  105966. get collisionCoordinator(): ICollisionCoordinator;
  105967. /**
  105968. * Defines the gravity applied to this scene (used only for collisions)
  105969. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105970. */
  105971. gravity: Vector3;
  105972. /**
  105973. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  105974. */
  105975. postProcessesEnabled: boolean;
  105976. /**
  105977. * The list of postprocesses added to the scene
  105978. */
  105979. postProcesses: PostProcess[];
  105980. /**
  105981. * Gets the current postprocess manager
  105982. */
  105983. postProcessManager: PostProcessManager;
  105984. /**
  105985. * Gets or sets a boolean indicating if render targets are enabled on this scene
  105986. */
  105987. renderTargetsEnabled: boolean;
  105988. /**
  105989. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  105990. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  105991. */
  105992. dumpNextRenderTargets: boolean;
  105993. /**
  105994. * The list of user defined render targets added to the scene
  105995. */
  105996. customRenderTargets: RenderTargetTexture[];
  105997. /**
  105998. * Defines if texture loading must be delayed
  105999. * If true, textures will only be loaded when they need to be rendered
  106000. */
  106001. useDelayedTextureLoading: boolean;
  106002. /**
  106003. * Gets the list of meshes imported to the scene through SceneLoader
  106004. */
  106005. importedMeshesFiles: String[];
  106006. /**
  106007. * Gets or sets a boolean indicating if probes are enabled on this scene
  106008. */
  106009. probesEnabled: boolean;
  106010. /**
  106011. * Gets or sets the current offline provider to use to store scene data
  106012. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106013. */
  106014. offlineProvider: IOfflineProvider;
  106015. /**
  106016. * Gets or sets the action manager associated with the scene
  106017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106018. */
  106019. actionManager: AbstractActionManager;
  106020. private _meshesForIntersections;
  106021. /**
  106022. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  106023. */
  106024. proceduralTexturesEnabled: boolean;
  106025. private _engine;
  106026. private _totalVertices;
  106027. /** @hidden */
  106028. _activeIndices: PerfCounter;
  106029. /** @hidden */
  106030. _activeParticles: PerfCounter;
  106031. /** @hidden */
  106032. _activeBones: PerfCounter;
  106033. private _animationRatio;
  106034. /** @hidden */
  106035. _animationTimeLast: number;
  106036. /** @hidden */
  106037. _animationTime: number;
  106038. /**
  106039. * Gets or sets a general scale for animation speed
  106040. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106041. */
  106042. animationTimeScale: number;
  106043. /** @hidden */
  106044. _cachedMaterial: Nullable<Material>;
  106045. /** @hidden */
  106046. _cachedEffect: Nullable<Effect>;
  106047. /** @hidden */
  106048. _cachedVisibility: Nullable<number>;
  106049. private _renderId;
  106050. private _frameId;
  106051. private _executeWhenReadyTimeoutId;
  106052. private _intermediateRendering;
  106053. private _viewUpdateFlag;
  106054. private _projectionUpdateFlag;
  106055. /** @hidden */
  106056. _toBeDisposed: Nullable<IDisposable>[];
  106057. private _activeRequests;
  106058. /** @hidden */
  106059. _pendingData: any[];
  106060. private _isDisposed;
  106061. /**
  106062. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106063. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106064. */
  106065. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106066. private _activeMeshes;
  106067. private _processedMaterials;
  106068. private _renderTargets;
  106069. /** @hidden */
  106070. _activeParticleSystems: SmartArray<IParticleSystem>;
  106071. private _activeSkeletons;
  106072. private _softwareSkinnedMeshes;
  106073. private _renderingManager;
  106074. /** @hidden */
  106075. _activeAnimatables: Animatable[];
  106076. private _transformMatrix;
  106077. private _sceneUbo;
  106078. /** @hidden */
  106079. _viewMatrix: Matrix;
  106080. private _projectionMatrix;
  106081. /** @hidden */
  106082. _forcedViewPosition: Nullable<Vector3>;
  106083. /** @hidden */
  106084. _frustumPlanes: Plane[];
  106085. /**
  106086. * Gets the list of frustum planes (built from the active camera)
  106087. */
  106088. get frustumPlanes(): Plane[];
  106089. /**
  106090. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106091. * This is useful if there are more lights that the maximum simulteanous authorized
  106092. */
  106093. requireLightSorting: boolean;
  106094. /** @hidden */
  106095. readonly useMaterialMeshMap: boolean;
  106096. /** @hidden */
  106097. readonly useClonedMeshhMap: boolean;
  106098. private _externalData;
  106099. private _uid;
  106100. /**
  106101. * @hidden
  106102. * Backing store of defined scene components.
  106103. */
  106104. _components: ISceneComponent[];
  106105. /**
  106106. * @hidden
  106107. * Backing store of defined scene components.
  106108. */
  106109. _serializableComponents: ISceneSerializableComponent[];
  106110. /**
  106111. * List of components to register on the next registration step.
  106112. */
  106113. private _transientComponents;
  106114. /**
  106115. * Registers the transient components if needed.
  106116. */
  106117. private _registerTransientComponents;
  106118. /**
  106119. * @hidden
  106120. * Add a component to the scene.
  106121. * Note that the ccomponent could be registered on th next frame if this is called after
  106122. * the register component stage.
  106123. * @param component Defines the component to add to the scene
  106124. */
  106125. _addComponent(component: ISceneComponent): void;
  106126. /**
  106127. * @hidden
  106128. * Gets a component from the scene.
  106129. * @param name defines the name of the component to retrieve
  106130. * @returns the component or null if not present
  106131. */
  106132. _getComponent(name: string): Nullable<ISceneComponent>;
  106133. /**
  106134. * @hidden
  106135. * Defines the actions happening before camera updates.
  106136. */
  106137. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106138. /**
  106139. * @hidden
  106140. * Defines the actions happening before clear the canvas.
  106141. */
  106142. _beforeClearStage: Stage<SimpleStageAction>;
  106143. /**
  106144. * @hidden
  106145. * Defines the actions when collecting render targets for the frame.
  106146. */
  106147. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106148. /**
  106149. * @hidden
  106150. * Defines the actions happening for one camera in the frame.
  106151. */
  106152. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106153. /**
  106154. * @hidden
  106155. * Defines the actions happening during the per mesh ready checks.
  106156. */
  106157. _isReadyForMeshStage: Stage<MeshStageAction>;
  106158. /**
  106159. * @hidden
  106160. * Defines the actions happening before evaluate active mesh checks.
  106161. */
  106162. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  106163. /**
  106164. * @hidden
  106165. * Defines the actions happening during the evaluate sub mesh checks.
  106166. */
  106167. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  106168. /**
  106169. * @hidden
  106170. * Defines the actions happening during the active mesh stage.
  106171. */
  106172. _activeMeshStage: Stage<ActiveMeshStageAction>;
  106173. /**
  106174. * @hidden
  106175. * Defines the actions happening during the per camera render target step.
  106176. */
  106177. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  106178. /**
  106179. * @hidden
  106180. * Defines the actions happening just before the active camera is drawing.
  106181. */
  106182. _beforeCameraDrawStage: Stage<CameraStageAction>;
  106183. /**
  106184. * @hidden
  106185. * Defines the actions happening just before a render target is drawing.
  106186. */
  106187. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106188. /**
  106189. * @hidden
  106190. * Defines the actions happening just before a rendering group is drawing.
  106191. */
  106192. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106193. /**
  106194. * @hidden
  106195. * Defines the actions happening just before a mesh is drawing.
  106196. */
  106197. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106198. /**
  106199. * @hidden
  106200. * Defines the actions happening just after a mesh has been drawn.
  106201. */
  106202. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106203. /**
  106204. * @hidden
  106205. * Defines the actions happening just after a rendering group has been drawn.
  106206. */
  106207. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106208. /**
  106209. * @hidden
  106210. * Defines the actions happening just after the active camera has been drawn.
  106211. */
  106212. _afterCameraDrawStage: Stage<CameraStageAction>;
  106213. /**
  106214. * @hidden
  106215. * Defines the actions happening just after a render target has been drawn.
  106216. */
  106217. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106218. /**
  106219. * @hidden
  106220. * Defines the actions happening just after rendering all cameras and computing intersections.
  106221. */
  106222. _afterRenderStage: Stage<SimpleStageAction>;
  106223. /**
  106224. * @hidden
  106225. * Defines the actions happening when a pointer move event happens.
  106226. */
  106227. _pointerMoveStage: Stage<PointerMoveStageAction>;
  106228. /**
  106229. * @hidden
  106230. * Defines the actions happening when a pointer down event happens.
  106231. */
  106232. _pointerDownStage: Stage<PointerUpDownStageAction>;
  106233. /**
  106234. * @hidden
  106235. * Defines the actions happening when a pointer up event happens.
  106236. */
  106237. _pointerUpStage: Stage<PointerUpDownStageAction>;
  106238. /**
  106239. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  106240. */
  106241. private geometriesByUniqueId;
  106242. /**
  106243. * Creates a new Scene
  106244. * @param engine defines the engine to use to render this scene
  106245. * @param options defines the scene options
  106246. */
  106247. constructor(engine: Engine, options?: SceneOptions);
  106248. /**
  106249. * Gets a string idenfifying the name of the class
  106250. * @returns "Scene" string
  106251. */
  106252. getClassName(): string;
  106253. private _defaultMeshCandidates;
  106254. /**
  106255. * @hidden
  106256. */
  106257. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106258. private _defaultSubMeshCandidates;
  106259. /**
  106260. * @hidden
  106261. */
  106262. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106263. /**
  106264. * Sets the default candidate providers for the scene.
  106265. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  106266. * and getCollidingSubMeshCandidates to their default function
  106267. */
  106268. setDefaultCandidateProviders(): void;
  106269. /**
  106270. * Gets the mesh that is currently under the pointer
  106271. */
  106272. get meshUnderPointer(): Nullable<AbstractMesh>;
  106273. /**
  106274. * Gets or sets the current on-screen X position of the pointer
  106275. */
  106276. get pointerX(): number;
  106277. set pointerX(value: number);
  106278. /**
  106279. * Gets or sets the current on-screen Y position of the pointer
  106280. */
  106281. get pointerY(): number;
  106282. set pointerY(value: number);
  106283. /**
  106284. * Gets the cached material (ie. the latest rendered one)
  106285. * @returns the cached material
  106286. */
  106287. getCachedMaterial(): Nullable<Material>;
  106288. /**
  106289. * Gets the cached effect (ie. the latest rendered one)
  106290. * @returns the cached effect
  106291. */
  106292. getCachedEffect(): Nullable<Effect>;
  106293. /**
  106294. * Gets the cached visibility state (ie. the latest rendered one)
  106295. * @returns the cached visibility state
  106296. */
  106297. getCachedVisibility(): Nullable<number>;
  106298. /**
  106299. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  106300. * @param material defines the current material
  106301. * @param effect defines the current effect
  106302. * @param visibility defines the current visibility state
  106303. * @returns true if one parameter is not cached
  106304. */
  106305. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  106306. /**
  106307. * Gets the engine associated with the scene
  106308. * @returns an Engine
  106309. */
  106310. getEngine(): Engine;
  106311. /**
  106312. * Gets the total number of vertices rendered per frame
  106313. * @returns the total number of vertices rendered per frame
  106314. */
  106315. getTotalVertices(): number;
  106316. /**
  106317. * Gets the performance counter for total vertices
  106318. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106319. */
  106320. get totalVerticesPerfCounter(): PerfCounter;
  106321. /**
  106322. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  106323. * @returns the total number of active indices rendered per frame
  106324. */
  106325. getActiveIndices(): number;
  106326. /**
  106327. * Gets the performance counter for active indices
  106328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106329. */
  106330. get totalActiveIndicesPerfCounter(): PerfCounter;
  106331. /**
  106332. * Gets the total number of active particles rendered per frame
  106333. * @returns the total number of active particles rendered per frame
  106334. */
  106335. getActiveParticles(): number;
  106336. /**
  106337. * Gets the performance counter for active particles
  106338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106339. */
  106340. get activeParticlesPerfCounter(): PerfCounter;
  106341. /**
  106342. * Gets the total number of active bones rendered per frame
  106343. * @returns the total number of active bones rendered per frame
  106344. */
  106345. getActiveBones(): number;
  106346. /**
  106347. * Gets the performance counter for active bones
  106348. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106349. */
  106350. get activeBonesPerfCounter(): PerfCounter;
  106351. /**
  106352. * Gets the array of active meshes
  106353. * @returns an array of AbstractMesh
  106354. */
  106355. getActiveMeshes(): SmartArray<AbstractMesh>;
  106356. /**
  106357. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  106358. * @returns a number
  106359. */
  106360. getAnimationRatio(): number;
  106361. /**
  106362. * Gets an unique Id for the current render phase
  106363. * @returns a number
  106364. */
  106365. getRenderId(): number;
  106366. /**
  106367. * Gets an unique Id for the current frame
  106368. * @returns a number
  106369. */
  106370. getFrameId(): number;
  106371. /** Call this function if you want to manually increment the render Id*/
  106372. incrementRenderId(): void;
  106373. private _createUbo;
  106374. /**
  106375. * Use this method to simulate a pointer move 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. * @returns the current scene
  106380. */
  106381. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106382. /**
  106383. * Use this method to simulate a pointer down on a mesh
  106384. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106385. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106386. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106387. * @returns the current scene
  106388. */
  106389. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106390. /**
  106391. * Use this method to simulate a pointer up on a mesh
  106392. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106393. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106394. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106395. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  106396. * @returns the current scene
  106397. */
  106398. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  106399. /**
  106400. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  106401. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  106402. * @returns true if the pointer was captured
  106403. */
  106404. isPointerCaptured(pointerId?: number): boolean;
  106405. /**
  106406. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  106407. * @param attachUp defines if you want to attach events to pointerup
  106408. * @param attachDown defines if you want to attach events to pointerdown
  106409. * @param attachMove defines if you want to attach events to pointermove
  106410. */
  106411. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  106412. /** Detaches all event handlers*/
  106413. detachControl(): void;
  106414. /**
  106415. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  106416. * Delay loaded resources are not taking in account
  106417. * @return true if all required resources are ready
  106418. */
  106419. isReady(): boolean;
  106420. /** Resets all cached information relative to material (including effect and visibility) */
  106421. resetCachedMaterial(): void;
  106422. /**
  106423. * Registers a function to be called before every frame render
  106424. * @param func defines the function to register
  106425. */
  106426. registerBeforeRender(func: () => void): void;
  106427. /**
  106428. * Unregisters a function called before every frame render
  106429. * @param func defines the function to unregister
  106430. */
  106431. unregisterBeforeRender(func: () => void): void;
  106432. /**
  106433. * Registers a function to be called after every frame render
  106434. * @param func defines the function to register
  106435. */
  106436. registerAfterRender(func: () => void): void;
  106437. /**
  106438. * Unregisters a function called after every frame render
  106439. * @param func defines the function to unregister
  106440. */
  106441. unregisterAfterRender(func: () => void): void;
  106442. private _executeOnceBeforeRender;
  106443. /**
  106444. * The provided function will run before render once and will be disposed afterwards.
  106445. * A timeout delay can be provided so that the function will be executed in N ms.
  106446. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  106447. * @param func The function to be executed.
  106448. * @param timeout optional delay in ms
  106449. */
  106450. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  106451. /** @hidden */
  106452. _addPendingData(data: any): void;
  106453. /** @hidden */
  106454. _removePendingData(data: any): void;
  106455. /**
  106456. * Returns the number of items waiting to be loaded
  106457. * @returns the number of items waiting to be loaded
  106458. */
  106459. getWaitingItemsCount(): number;
  106460. /**
  106461. * Returns a boolean indicating if the scene is still loading data
  106462. */
  106463. get isLoading(): boolean;
  106464. /**
  106465. * Registers a function to be executed when the scene is ready
  106466. * @param {Function} func - the function to be executed
  106467. */
  106468. executeWhenReady(func: () => void): void;
  106469. /**
  106470. * Returns a promise that resolves when the scene is ready
  106471. * @returns A promise that resolves when the scene is ready
  106472. */
  106473. whenReadyAsync(): Promise<void>;
  106474. /** @hidden */
  106475. _checkIsReady(): void;
  106476. /**
  106477. * Gets all animatable attached to the scene
  106478. */
  106479. get animatables(): Animatable[];
  106480. /**
  106481. * Resets the last animation time frame.
  106482. * Useful to override when animations start running when loading a scene for the first time.
  106483. */
  106484. resetLastAnimationTimeFrame(): void;
  106485. /**
  106486. * Gets the current view matrix
  106487. * @returns a Matrix
  106488. */
  106489. getViewMatrix(): Matrix;
  106490. /**
  106491. * Gets the current projection matrix
  106492. * @returns a Matrix
  106493. */
  106494. getProjectionMatrix(): Matrix;
  106495. /**
  106496. * Gets the current transform matrix
  106497. * @returns a Matrix made of View * Projection
  106498. */
  106499. getTransformMatrix(): Matrix;
  106500. /**
  106501. * Sets the current transform matrix
  106502. * @param viewL defines the View matrix to use
  106503. * @param projectionL defines the Projection matrix to use
  106504. * @param viewR defines the right View matrix to use (if provided)
  106505. * @param projectionR defines the right Projection matrix to use (if provided)
  106506. */
  106507. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  106508. /**
  106509. * Gets the uniform buffer used to store scene data
  106510. * @returns a UniformBuffer
  106511. */
  106512. getSceneUniformBuffer(): UniformBuffer;
  106513. /**
  106514. * Gets an unique (relatively to the current scene) Id
  106515. * @returns an unique number for the scene
  106516. */
  106517. getUniqueId(): number;
  106518. /**
  106519. * Add a mesh to the list of scene's meshes
  106520. * @param newMesh defines the mesh to add
  106521. * @param recursive if all child meshes should also be added to the scene
  106522. */
  106523. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  106524. /**
  106525. * Remove a mesh for the list of scene's meshes
  106526. * @param toRemove defines the mesh to remove
  106527. * @param recursive if all child meshes should also be removed from the scene
  106528. * @returns the index where the mesh was in the mesh list
  106529. */
  106530. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  106531. /**
  106532. * Add a transform node to the list of scene's transform nodes
  106533. * @param newTransformNode defines the transform node to add
  106534. */
  106535. addTransformNode(newTransformNode: TransformNode): void;
  106536. /**
  106537. * Remove a transform node for the list of scene's transform nodes
  106538. * @param toRemove defines the transform node to remove
  106539. * @returns the index where the transform node was in the transform node list
  106540. */
  106541. removeTransformNode(toRemove: TransformNode): number;
  106542. /**
  106543. * Remove a skeleton for the list of scene's skeletons
  106544. * @param toRemove defines the skeleton to remove
  106545. * @returns the index where the skeleton was in the skeleton list
  106546. */
  106547. removeSkeleton(toRemove: Skeleton): number;
  106548. /**
  106549. * Remove a morph target for the list of scene's morph targets
  106550. * @param toRemove defines the morph target to remove
  106551. * @returns the index where the morph target was in the morph target list
  106552. */
  106553. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  106554. /**
  106555. * Remove a light for the list of scene's lights
  106556. * @param toRemove defines the light to remove
  106557. * @returns the index where the light was in the light list
  106558. */
  106559. removeLight(toRemove: Light): number;
  106560. /**
  106561. * Remove a camera for the list of scene's cameras
  106562. * @param toRemove defines the camera to remove
  106563. * @returns the index where the camera was in the camera list
  106564. */
  106565. removeCamera(toRemove: Camera): number;
  106566. /**
  106567. * Remove a particle system for the list of scene's particle systems
  106568. * @param toRemove defines the particle system to remove
  106569. * @returns the index where the particle system was in the particle system list
  106570. */
  106571. removeParticleSystem(toRemove: IParticleSystem): number;
  106572. /**
  106573. * Remove a animation for the list of scene's animations
  106574. * @param toRemove defines the animation to remove
  106575. * @returns the index where the animation was in the animation list
  106576. */
  106577. removeAnimation(toRemove: Animation): number;
  106578. /**
  106579. * Will stop the animation of the given target
  106580. * @param target - the target
  106581. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  106582. * @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)
  106583. */
  106584. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  106585. /**
  106586. * Removes the given animation group from this scene.
  106587. * @param toRemove The animation group to remove
  106588. * @returns The index of the removed animation group
  106589. */
  106590. removeAnimationGroup(toRemove: AnimationGroup): number;
  106591. /**
  106592. * Removes the given multi-material from this scene.
  106593. * @param toRemove The multi-material to remove
  106594. * @returns The index of the removed multi-material
  106595. */
  106596. removeMultiMaterial(toRemove: MultiMaterial): number;
  106597. /**
  106598. * Removes the given material from this scene.
  106599. * @param toRemove The material to remove
  106600. * @returns The index of the removed material
  106601. */
  106602. removeMaterial(toRemove: Material): number;
  106603. /**
  106604. * Removes the given action manager from this scene.
  106605. * @param toRemove The action manager to remove
  106606. * @returns The index of the removed action manager
  106607. */
  106608. removeActionManager(toRemove: AbstractActionManager): number;
  106609. /**
  106610. * Removes the given texture from this scene.
  106611. * @param toRemove The texture to remove
  106612. * @returns The index of the removed texture
  106613. */
  106614. removeTexture(toRemove: BaseTexture): number;
  106615. /**
  106616. * Adds the given light to this scene
  106617. * @param newLight The light to add
  106618. */
  106619. addLight(newLight: Light): void;
  106620. /**
  106621. * Sorts the list list based on light priorities
  106622. */
  106623. sortLightsByPriority(): void;
  106624. /**
  106625. * Adds the given camera to this scene
  106626. * @param newCamera The camera to add
  106627. */
  106628. addCamera(newCamera: Camera): void;
  106629. /**
  106630. * Adds the given skeleton to this scene
  106631. * @param newSkeleton The skeleton to add
  106632. */
  106633. addSkeleton(newSkeleton: Skeleton): void;
  106634. /**
  106635. * Adds the given particle system to this scene
  106636. * @param newParticleSystem The particle system to add
  106637. */
  106638. addParticleSystem(newParticleSystem: IParticleSystem): void;
  106639. /**
  106640. * Adds the given animation to this scene
  106641. * @param newAnimation The animation to add
  106642. */
  106643. addAnimation(newAnimation: Animation): void;
  106644. /**
  106645. * Adds the given animation group to this scene.
  106646. * @param newAnimationGroup The animation group to add
  106647. */
  106648. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  106649. /**
  106650. * Adds the given multi-material to this scene
  106651. * @param newMultiMaterial The multi-material to add
  106652. */
  106653. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  106654. /**
  106655. * Adds the given material to this scene
  106656. * @param newMaterial The material to add
  106657. */
  106658. addMaterial(newMaterial: Material): void;
  106659. /**
  106660. * Adds the given morph target to this scene
  106661. * @param newMorphTargetManager The morph target to add
  106662. */
  106663. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  106664. /**
  106665. * Adds the given geometry to this scene
  106666. * @param newGeometry The geometry to add
  106667. */
  106668. addGeometry(newGeometry: Geometry): void;
  106669. /**
  106670. * Adds the given action manager to this scene
  106671. * @param newActionManager The action manager to add
  106672. */
  106673. addActionManager(newActionManager: AbstractActionManager): void;
  106674. /**
  106675. * Adds the given texture to this scene.
  106676. * @param newTexture The texture to add
  106677. */
  106678. addTexture(newTexture: BaseTexture): void;
  106679. /**
  106680. * Switch active camera
  106681. * @param newCamera defines the new active camera
  106682. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  106683. */
  106684. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  106685. /**
  106686. * sets the active camera of the scene using its ID
  106687. * @param id defines the camera's ID
  106688. * @return the new active camera or null if none found.
  106689. */
  106690. setActiveCameraByID(id: string): Nullable<Camera>;
  106691. /**
  106692. * sets the active camera of the scene using its name
  106693. * @param name defines the camera's name
  106694. * @returns the new active camera or null if none found.
  106695. */
  106696. setActiveCameraByName(name: string): Nullable<Camera>;
  106697. /**
  106698. * get an animation group using its name
  106699. * @param name defines the material's name
  106700. * @return the animation group or null if none found.
  106701. */
  106702. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  106703. /**
  106704. * Get a material using its unique id
  106705. * @param uniqueId defines the material's unique id
  106706. * @return the material or null if none found.
  106707. */
  106708. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  106709. /**
  106710. * get a material using its id
  106711. * @param id defines the material's ID
  106712. * @return the material or null if none found.
  106713. */
  106714. getMaterialByID(id: string): Nullable<Material>;
  106715. /**
  106716. * Gets a the last added material using a given id
  106717. * @param id defines the material's ID
  106718. * @return the last material with the given id or null if none found.
  106719. */
  106720. getLastMaterialByID(id: string): Nullable<Material>;
  106721. /**
  106722. * Gets a material using its name
  106723. * @param name defines the material's name
  106724. * @return the material or null if none found.
  106725. */
  106726. getMaterialByName(name: string): Nullable<Material>;
  106727. /**
  106728. * Get a texture using its unique id
  106729. * @param uniqueId defines the texture's unique id
  106730. * @return the texture or null if none found.
  106731. */
  106732. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  106733. /**
  106734. * Gets a camera using its id
  106735. * @param id defines the id to look for
  106736. * @returns the camera or null if not found
  106737. */
  106738. getCameraByID(id: string): Nullable<Camera>;
  106739. /**
  106740. * Gets a camera using its unique id
  106741. * @param uniqueId defines the unique id to look for
  106742. * @returns the camera or null if not found
  106743. */
  106744. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  106745. /**
  106746. * Gets a camera using its name
  106747. * @param name defines the camera's name
  106748. * @return the camera or null if none found.
  106749. */
  106750. getCameraByName(name: string): Nullable<Camera>;
  106751. /**
  106752. * Gets a bone using its id
  106753. * @param id defines the bone's id
  106754. * @return the bone or null if not found
  106755. */
  106756. getBoneByID(id: string): Nullable<Bone>;
  106757. /**
  106758. * Gets a bone using its id
  106759. * @param name defines the bone's name
  106760. * @return the bone or null if not found
  106761. */
  106762. getBoneByName(name: string): Nullable<Bone>;
  106763. /**
  106764. * Gets a light node using its name
  106765. * @param name defines the the light's name
  106766. * @return the light or null if none found.
  106767. */
  106768. getLightByName(name: string): Nullable<Light>;
  106769. /**
  106770. * Gets a light node using its id
  106771. * @param id defines the light's id
  106772. * @return the light or null if none found.
  106773. */
  106774. getLightByID(id: string): Nullable<Light>;
  106775. /**
  106776. * Gets a light node using its scene-generated unique ID
  106777. * @param uniqueId defines the light's unique id
  106778. * @return the light or null if none found.
  106779. */
  106780. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  106781. /**
  106782. * Gets a particle system by id
  106783. * @param id defines the particle system id
  106784. * @return the corresponding system or null if none found
  106785. */
  106786. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  106787. /**
  106788. * Gets a geometry using its ID
  106789. * @param id defines the geometry's id
  106790. * @return the geometry or null if none found.
  106791. */
  106792. getGeometryByID(id: string): Nullable<Geometry>;
  106793. private _getGeometryByUniqueID;
  106794. /**
  106795. * Add a new geometry to this scene
  106796. * @param geometry defines the geometry to be added to the scene.
  106797. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  106798. * @return a boolean defining if the geometry was added or not
  106799. */
  106800. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  106801. /**
  106802. * Removes an existing geometry
  106803. * @param geometry defines the geometry to be removed from the scene
  106804. * @return a boolean defining if the geometry was removed or not
  106805. */
  106806. removeGeometry(geometry: Geometry): boolean;
  106807. /**
  106808. * Gets the list of geometries attached to the scene
  106809. * @returns an array of Geometry
  106810. */
  106811. getGeometries(): Geometry[];
  106812. /**
  106813. * Gets the first added mesh found of a given ID
  106814. * @param id defines the id to search for
  106815. * @return the mesh found or null if not found at all
  106816. */
  106817. getMeshByID(id: string): Nullable<AbstractMesh>;
  106818. /**
  106819. * Gets a list of meshes using their id
  106820. * @param id defines the id to search for
  106821. * @returns a list of meshes
  106822. */
  106823. getMeshesByID(id: string): Array<AbstractMesh>;
  106824. /**
  106825. * Gets the first added transform node found of a given ID
  106826. * @param id defines the id to search for
  106827. * @return the found transform node or null if not found at all.
  106828. */
  106829. getTransformNodeByID(id: string): Nullable<TransformNode>;
  106830. /**
  106831. * Gets a transform node with its auto-generated unique id
  106832. * @param uniqueId efines the unique id to search for
  106833. * @return the found transform node or null if not found at all.
  106834. */
  106835. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  106836. /**
  106837. * Gets a list of transform nodes using their id
  106838. * @param id defines the id to search for
  106839. * @returns a list of transform nodes
  106840. */
  106841. getTransformNodesByID(id: string): Array<TransformNode>;
  106842. /**
  106843. * Gets a mesh with its auto-generated unique id
  106844. * @param uniqueId defines the unique id to search for
  106845. * @return the found mesh or null if not found at all.
  106846. */
  106847. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  106848. /**
  106849. * Gets a the last added mesh using a given id
  106850. * @param id defines the id to search for
  106851. * @return the found mesh or null if not found at all.
  106852. */
  106853. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  106854. /**
  106855. * Gets a the last added node (Mesh, Camera, Light) using a given id
  106856. * @param id defines the id to search for
  106857. * @return the found node or null if not found at all
  106858. */
  106859. getLastEntryByID(id: string): Nullable<Node>;
  106860. /**
  106861. * Gets a node (Mesh, Camera, Light) using a given id
  106862. * @param id defines the id to search for
  106863. * @return the found node or null if not found at all
  106864. */
  106865. getNodeByID(id: string): Nullable<Node>;
  106866. /**
  106867. * Gets a node (Mesh, Camera, Light) using a given name
  106868. * @param name defines the name to search for
  106869. * @return the found node or null if not found at all.
  106870. */
  106871. getNodeByName(name: string): Nullable<Node>;
  106872. /**
  106873. * Gets a mesh using a given name
  106874. * @param name defines the name to search for
  106875. * @return the found mesh or null if not found at all.
  106876. */
  106877. getMeshByName(name: string): Nullable<AbstractMesh>;
  106878. /**
  106879. * Gets a transform node using a given name
  106880. * @param name defines the name to search for
  106881. * @return the found transform node or null if not found at all.
  106882. */
  106883. getTransformNodeByName(name: string): Nullable<TransformNode>;
  106884. /**
  106885. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  106886. * @param id defines the id to search for
  106887. * @return the found skeleton or null if not found at all.
  106888. */
  106889. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  106890. /**
  106891. * Gets a skeleton using a given auto generated unique id
  106892. * @param uniqueId defines the unique id to search for
  106893. * @return the found skeleton or null if not found at all.
  106894. */
  106895. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  106896. /**
  106897. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  106898. * @param id defines the id to search for
  106899. * @return the found skeleton or null if not found at all.
  106900. */
  106901. getSkeletonById(id: string): Nullable<Skeleton>;
  106902. /**
  106903. * Gets a skeleton using a given name
  106904. * @param name defines the name to search for
  106905. * @return the found skeleton or null if not found at all.
  106906. */
  106907. getSkeletonByName(name: string): Nullable<Skeleton>;
  106908. /**
  106909. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  106910. * @param id defines the id to search for
  106911. * @return the found morph target manager or null if not found at all.
  106912. */
  106913. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  106914. /**
  106915. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  106916. * @param id defines the id to search for
  106917. * @return the found morph target or null if not found at all.
  106918. */
  106919. getMorphTargetById(id: string): Nullable<MorphTarget>;
  106920. /**
  106921. * Gets a boolean indicating if the given mesh is active
  106922. * @param mesh defines the mesh to look for
  106923. * @returns true if the mesh is in the active list
  106924. */
  106925. isActiveMesh(mesh: AbstractMesh): boolean;
  106926. /**
  106927. * Return a unique id as a string which can serve as an identifier for the scene
  106928. */
  106929. get uid(): string;
  106930. /**
  106931. * Add an externaly attached data from its key.
  106932. * This method call will fail and return false, if such key already exists.
  106933. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  106934. * @param key the unique key that identifies the data
  106935. * @param data the data object to associate to the key for this Engine instance
  106936. * @return true if no such key were already present and the data was added successfully, false otherwise
  106937. */
  106938. addExternalData<T>(key: string, data: T): boolean;
  106939. /**
  106940. * Get an externaly attached data from its key
  106941. * @param key the unique key that identifies the data
  106942. * @return the associated data, if present (can be null), or undefined if not present
  106943. */
  106944. getExternalData<T>(key: string): Nullable<T>;
  106945. /**
  106946. * Get an externaly attached data from its key, create it using a factory if it's not already present
  106947. * @param key the unique key that identifies the data
  106948. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  106949. * @return the associated data, can be null if the factory returned null.
  106950. */
  106951. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  106952. /**
  106953. * Remove an externaly attached data from the Engine instance
  106954. * @param key the unique key that identifies the data
  106955. * @return true if the data was successfully removed, false if it doesn't exist
  106956. */
  106957. removeExternalData(key: string): boolean;
  106958. private _evaluateSubMesh;
  106959. /**
  106960. * Clear the processed materials smart array preventing retention point in material dispose.
  106961. */
  106962. freeProcessedMaterials(): void;
  106963. private _preventFreeActiveMeshesAndRenderingGroups;
  106964. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  106965. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  106966. * when disposing several meshes in a row or a hierarchy of meshes.
  106967. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  106968. */
  106969. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  106970. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  106971. /**
  106972. * Clear the active meshes smart array preventing retention point in mesh dispose.
  106973. */
  106974. freeActiveMeshes(): void;
  106975. /**
  106976. * Clear the info related to rendering groups preventing retention points during dispose.
  106977. */
  106978. freeRenderingGroups(): void;
  106979. /** @hidden */
  106980. _isInIntermediateRendering(): boolean;
  106981. /**
  106982. * Lambda returning the list of potentially active meshes.
  106983. */
  106984. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  106985. /**
  106986. * Lambda returning the list of potentially active sub meshes.
  106987. */
  106988. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  106989. /**
  106990. * Lambda returning the list of potentially intersecting sub meshes.
  106991. */
  106992. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  106993. /**
  106994. * Lambda returning the list of potentially colliding sub meshes.
  106995. */
  106996. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  106997. private _activeMeshesFrozen;
  106998. private _skipEvaluateActiveMeshesCompletely;
  106999. /**
  107000. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  107001. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  107002. * @returns the current scene
  107003. */
  107004. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  107005. /**
  107006. * Use this function to restart evaluating active meshes on every frame
  107007. * @returns the current scene
  107008. */
  107009. unfreezeActiveMeshes(): Scene;
  107010. private _evaluateActiveMeshes;
  107011. private _activeMesh;
  107012. /**
  107013. * Update the transform matrix to update from the current active camera
  107014. * @param force defines a boolean used to force the update even if cache is up to date
  107015. */
  107016. updateTransformMatrix(force?: boolean): void;
  107017. private _bindFrameBuffer;
  107018. /** @hidden */
  107019. _allowPostProcessClearColor: boolean;
  107020. /** @hidden */
  107021. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  107022. private _processSubCameras;
  107023. private _checkIntersections;
  107024. /** @hidden */
  107025. _advancePhysicsEngineStep(step: number): void;
  107026. /**
  107027. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  107028. */
  107029. getDeterministicFrameTime: () => number;
  107030. /** @hidden */
  107031. _animate(): void;
  107032. /** Execute all animations (for a frame) */
  107033. animate(): void;
  107034. /**
  107035. * Render the scene
  107036. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  107037. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107038. */
  107039. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107040. /**
  107041. * Freeze all materials
  107042. * A frozen material will not be updatable but should be faster to render
  107043. */
  107044. freezeMaterials(): void;
  107045. /**
  107046. * Unfreeze all materials
  107047. * A frozen material will not be updatable but should be faster to render
  107048. */
  107049. unfreezeMaterials(): void;
  107050. /**
  107051. * Releases all held ressources
  107052. */
  107053. dispose(): void;
  107054. /**
  107055. * Gets if the scene is already disposed
  107056. */
  107057. get isDisposed(): boolean;
  107058. /**
  107059. * Call this function to reduce memory footprint of the scene.
  107060. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107061. */
  107062. clearCachedVertexData(): void;
  107063. /**
  107064. * This function will remove the local cached buffer data from texture.
  107065. * It will save memory but will prevent the texture from being rebuilt
  107066. */
  107067. cleanCachedTextureBuffer(): void;
  107068. /**
  107069. * Get the world extend vectors with an optional filter
  107070. *
  107071. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107072. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107073. */
  107074. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107075. min: Vector3;
  107076. max: Vector3;
  107077. };
  107078. /**
  107079. * Creates a ray that can be used to pick in the scene
  107080. * @param x defines the x coordinate of the origin (on-screen)
  107081. * @param y defines the y coordinate of the origin (on-screen)
  107082. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107083. * @param camera defines the camera to use for the picking
  107084. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107085. * @returns a Ray
  107086. */
  107087. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107088. /**
  107089. * Creates a ray that can be used to pick in the scene
  107090. * @param x defines the x coordinate of the origin (on-screen)
  107091. * @param y defines the y coordinate of the origin (on-screen)
  107092. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107093. * @param result defines the ray where to store the picking ray
  107094. * @param camera defines the camera to use for the picking
  107095. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107096. * @returns the current scene
  107097. */
  107098. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107099. /**
  107100. * Creates a ray that can be used to pick in the scene
  107101. * @param x defines the x coordinate of the origin (on-screen)
  107102. * @param y defines the y coordinate of the origin (on-screen)
  107103. * @param camera defines the camera to use for the picking
  107104. * @returns a Ray
  107105. */
  107106. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107107. /**
  107108. * Creates a ray that can be used to pick in the scene
  107109. * @param x defines the x coordinate of the origin (on-screen)
  107110. * @param y defines the y coordinate of the origin (on-screen)
  107111. * @param result defines the ray where to store the picking ray
  107112. * @param camera defines the camera to use for the picking
  107113. * @returns the current scene
  107114. */
  107115. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107116. /** Launch a ray to try to pick a mesh in the scene
  107117. * @param x position on screen
  107118. * @param y position on screen
  107119. * @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
  107120. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107121. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107122. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107123. * @returns a PickingInfo
  107124. */
  107125. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107126. /** Use the given ray to pick a mesh in the scene
  107127. * @param ray The ray to use to pick meshes
  107128. * @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
  107129. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107130. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107131. * @returns a PickingInfo
  107132. */
  107133. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107134. /**
  107135. * Launch a ray to try to pick a mesh in the scene
  107136. * @param x X position on screen
  107137. * @param y Y position on screen
  107138. * @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
  107139. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107140. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107141. * @returns an array of PickingInfo
  107142. */
  107143. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107144. /**
  107145. * Launch a ray to try to pick a mesh in the scene
  107146. * @param ray Ray to use
  107147. * @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
  107148. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107149. * @returns an array of PickingInfo
  107150. */
  107151. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107152. /**
  107153. * Force the value of meshUnderPointer
  107154. * @param mesh defines the mesh to use
  107155. */
  107156. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107157. /**
  107158. * Gets the mesh under the pointer
  107159. * @returns a Mesh or null if no mesh is under the pointer
  107160. */
  107161. getPointerOverMesh(): Nullable<AbstractMesh>;
  107162. /** @hidden */
  107163. _rebuildGeometries(): void;
  107164. /** @hidden */
  107165. _rebuildTextures(): void;
  107166. private _getByTags;
  107167. /**
  107168. * Get a list of meshes by tags
  107169. * @param tagsQuery defines the tags query to use
  107170. * @param forEach defines a predicate used to filter results
  107171. * @returns an array of Mesh
  107172. */
  107173. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  107174. /**
  107175. * Get a list of cameras by tags
  107176. * @param tagsQuery defines the tags query to use
  107177. * @param forEach defines a predicate used to filter results
  107178. * @returns an array of Camera
  107179. */
  107180. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  107181. /**
  107182. * Get a list of lights by tags
  107183. * @param tagsQuery defines the tags query to use
  107184. * @param forEach defines a predicate used to filter results
  107185. * @returns an array of Light
  107186. */
  107187. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  107188. /**
  107189. * Get a list of materials by tags
  107190. * @param tagsQuery defines the tags query to use
  107191. * @param forEach defines a predicate used to filter results
  107192. * @returns an array of Material
  107193. */
  107194. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  107195. /**
  107196. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  107197. * This allowed control for front to back rendering or reversly depending of the special needs.
  107198. *
  107199. * @param renderingGroupId The rendering group id corresponding to its index
  107200. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  107201. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  107202. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  107203. */
  107204. 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;
  107205. /**
  107206. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  107207. *
  107208. * @param renderingGroupId The rendering group id corresponding to its index
  107209. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107210. * @param depth Automatically clears depth between groups if true and autoClear is true.
  107211. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  107212. */
  107213. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  107214. /**
  107215. * Gets the current auto clear configuration for one rendering group of the rendering
  107216. * manager.
  107217. * @param index the rendering group index to get the information for
  107218. * @returns The auto clear setup for the requested rendering group
  107219. */
  107220. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  107221. private _blockMaterialDirtyMechanism;
  107222. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  107223. get blockMaterialDirtyMechanism(): boolean;
  107224. set blockMaterialDirtyMechanism(value: boolean);
  107225. /**
  107226. * Will flag all materials as dirty to trigger new shader compilation
  107227. * @param flag defines the flag used to specify which material part must be marked as dirty
  107228. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  107229. */
  107230. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107231. /** @hidden */
  107232. _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;
  107233. /** @hidden */
  107234. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107235. /** @hidden */
  107236. _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;
  107237. /** @hidden */
  107238. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  107239. /** @hidden */
  107240. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107241. /** @hidden */
  107242. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107243. }
  107244. }
  107245. declare module BABYLON {
  107246. /**
  107247. * Set of assets to keep when moving a scene into an asset container.
  107248. */
  107249. export class KeepAssets extends AbstractScene {
  107250. }
  107251. /**
  107252. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  107253. */
  107254. export class InstantiatedEntries {
  107255. /**
  107256. * List of new root nodes (eg. nodes with no parent)
  107257. */
  107258. rootNodes: TransformNode[];
  107259. /**
  107260. * List of new skeletons
  107261. */
  107262. skeletons: Skeleton[];
  107263. /**
  107264. * List of new animation groups
  107265. */
  107266. animationGroups: AnimationGroup[];
  107267. }
  107268. /**
  107269. * Container with a set of assets that can be added or removed from a scene.
  107270. */
  107271. export class AssetContainer extends AbstractScene {
  107272. /**
  107273. * The scene the AssetContainer belongs to.
  107274. */
  107275. scene: Scene;
  107276. /**
  107277. * Instantiates an AssetContainer.
  107278. * @param scene The scene the AssetContainer belongs to.
  107279. */
  107280. constructor(scene: Scene);
  107281. /**
  107282. * Instantiate or clone all meshes and add the new ones to the scene.
  107283. * Skeletons and animation groups will all be cloned
  107284. * @param nameFunction defines an optional function used to get new names for clones
  107285. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  107286. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  107287. */
  107288. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  107289. /**
  107290. * Adds all the assets from the container to the scene.
  107291. */
  107292. addAllToScene(): void;
  107293. /**
  107294. * Removes all the assets in the container from the scene
  107295. */
  107296. removeAllFromScene(): void;
  107297. /**
  107298. * Disposes all the assets in the container
  107299. */
  107300. dispose(): void;
  107301. private _moveAssets;
  107302. /**
  107303. * Removes all the assets contained in the scene and adds them to the container.
  107304. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  107305. */
  107306. moveAllFromScene(keepAssets?: KeepAssets): void;
  107307. /**
  107308. * 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.
  107309. * @returns the root mesh
  107310. */
  107311. createRootMesh(): Mesh;
  107312. /**
  107313. * Merge animations from this asset container into a scene
  107314. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107315. * @param animatables set of animatables to retarget to a node from the scene
  107316. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  107317. */
  107318. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  107319. }
  107320. }
  107321. declare module BABYLON {
  107322. /**
  107323. * Defines how the parser contract is defined.
  107324. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  107325. */
  107326. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  107327. /**
  107328. * Defines how the individual parser contract is defined.
  107329. * These parser can parse an individual asset
  107330. */
  107331. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  107332. /**
  107333. * Base class of the scene acting as a container for the different elements composing a scene.
  107334. * This class is dynamically extended by the different components of the scene increasing
  107335. * flexibility and reducing coupling
  107336. */
  107337. export abstract class AbstractScene {
  107338. /**
  107339. * Stores the list of available parsers in the application.
  107340. */
  107341. private static _BabylonFileParsers;
  107342. /**
  107343. * Stores the list of available individual parsers in the application.
  107344. */
  107345. private static _IndividualBabylonFileParsers;
  107346. /**
  107347. * Adds a parser in the list of available ones
  107348. * @param name Defines the name of the parser
  107349. * @param parser Defines the parser to add
  107350. */
  107351. static AddParser(name: string, parser: BabylonFileParser): void;
  107352. /**
  107353. * Gets a general parser from the list of avaialble ones
  107354. * @param name Defines the name of the parser
  107355. * @returns the requested parser or null
  107356. */
  107357. static GetParser(name: string): Nullable<BabylonFileParser>;
  107358. /**
  107359. * Adds n individual parser in the list of available ones
  107360. * @param name Defines the name of the parser
  107361. * @param parser Defines the parser to add
  107362. */
  107363. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  107364. /**
  107365. * Gets an individual parser from the list of avaialble ones
  107366. * @param name Defines the name of the parser
  107367. * @returns the requested parser or null
  107368. */
  107369. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  107370. /**
  107371. * Parser json data and populate both a scene and its associated container object
  107372. * @param jsonData Defines the data to parse
  107373. * @param scene Defines the scene to parse the data for
  107374. * @param container Defines the container attached to the parsing sequence
  107375. * @param rootUrl Defines the root url of the data
  107376. */
  107377. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  107378. /**
  107379. * Gets the list of root nodes (ie. nodes with no parent)
  107380. */
  107381. rootNodes: Node[];
  107382. /** All of the cameras added to this scene
  107383. * @see http://doc.babylonjs.com/babylon101/cameras
  107384. */
  107385. cameras: Camera[];
  107386. /**
  107387. * All of the lights added to this scene
  107388. * @see http://doc.babylonjs.com/babylon101/lights
  107389. */
  107390. lights: Light[];
  107391. /**
  107392. * All of the (abstract) meshes added to this scene
  107393. */
  107394. meshes: AbstractMesh[];
  107395. /**
  107396. * The list of skeletons added to the scene
  107397. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107398. */
  107399. skeletons: Skeleton[];
  107400. /**
  107401. * All of the particle systems added to this scene
  107402. * @see http://doc.babylonjs.com/babylon101/particles
  107403. */
  107404. particleSystems: IParticleSystem[];
  107405. /**
  107406. * Gets a list of Animations associated with the scene
  107407. */
  107408. animations: Animation[];
  107409. /**
  107410. * All of the animation groups added to this scene
  107411. * @see http://doc.babylonjs.com/how_to/group
  107412. */
  107413. animationGroups: AnimationGroup[];
  107414. /**
  107415. * All of the multi-materials added to this scene
  107416. * @see http://doc.babylonjs.com/how_to/multi_materials
  107417. */
  107418. multiMaterials: MultiMaterial[];
  107419. /**
  107420. * All of the materials added to this scene
  107421. * In the context of a Scene, it is not supposed to be modified manually.
  107422. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  107423. * Note also that the order of the Material within the array is not significant and might change.
  107424. * @see http://doc.babylonjs.com/babylon101/materials
  107425. */
  107426. materials: Material[];
  107427. /**
  107428. * The list of morph target managers added to the scene
  107429. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  107430. */
  107431. morphTargetManagers: MorphTargetManager[];
  107432. /**
  107433. * The list of geometries used in the scene.
  107434. */
  107435. geometries: Geometry[];
  107436. /**
  107437. * All of the tranform nodes added to this scene
  107438. * In the context of a Scene, it is not supposed to be modified manually.
  107439. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  107440. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  107441. * @see http://doc.babylonjs.com/how_to/transformnode
  107442. */
  107443. transformNodes: TransformNode[];
  107444. /**
  107445. * ActionManagers available on the scene.
  107446. */
  107447. actionManagers: AbstractActionManager[];
  107448. /**
  107449. * Textures to keep.
  107450. */
  107451. textures: BaseTexture[];
  107452. /**
  107453. * Environment texture for the scene
  107454. */
  107455. environmentTexture: Nullable<BaseTexture>;
  107456. /**
  107457. * @returns all meshes, lights, cameras, transformNodes and bones
  107458. */
  107459. getNodes(): Array<Node>;
  107460. }
  107461. }
  107462. declare module BABYLON {
  107463. /**
  107464. * Interface used to define options for Sound class
  107465. */
  107466. export interface ISoundOptions {
  107467. /**
  107468. * Does the sound autoplay once loaded.
  107469. */
  107470. autoplay?: boolean;
  107471. /**
  107472. * Does the sound loop after it finishes playing once.
  107473. */
  107474. loop?: boolean;
  107475. /**
  107476. * Sound's volume
  107477. */
  107478. volume?: number;
  107479. /**
  107480. * Is it a spatial sound?
  107481. */
  107482. spatialSound?: boolean;
  107483. /**
  107484. * Maximum distance to hear that sound
  107485. */
  107486. maxDistance?: number;
  107487. /**
  107488. * Uses user defined attenuation function
  107489. */
  107490. useCustomAttenuation?: boolean;
  107491. /**
  107492. * Define the roll off factor of spatial sounds.
  107493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107494. */
  107495. rolloffFactor?: number;
  107496. /**
  107497. * Define the reference distance the sound should be heard perfectly.
  107498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107499. */
  107500. refDistance?: number;
  107501. /**
  107502. * Define the distance attenuation model the sound will follow.
  107503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107504. */
  107505. distanceModel?: string;
  107506. /**
  107507. * Defines the playback speed (1 by default)
  107508. */
  107509. playbackRate?: number;
  107510. /**
  107511. * Defines if the sound is from a streaming source
  107512. */
  107513. streaming?: boolean;
  107514. /**
  107515. * Defines an optional length (in seconds) inside the sound file
  107516. */
  107517. length?: number;
  107518. /**
  107519. * Defines an optional offset (in seconds) inside the sound file
  107520. */
  107521. offset?: number;
  107522. /**
  107523. * If true, URLs will not be required to state the audio file codec to use.
  107524. */
  107525. skipCodecCheck?: boolean;
  107526. }
  107527. /**
  107528. * Defines a sound that can be played in the application.
  107529. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  107530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107531. */
  107532. export class Sound {
  107533. /**
  107534. * The name of the sound in the scene.
  107535. */
  107536. name: string;
  107537. /**
  107538. * Does the sound autoplay once loaded.
  107539. */
  107540. autoplay: boolean;
  107541. /**
  107542. * Does the sound loop after it finishes playing once.
  107543. */
  107544. loop: boolean;
  107545. /**
  107546. * Does the sound use a custom attenuation curve to simulate the falloff
  107547. * happening when the source gets further away from the camera.
  107548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107549. */
  107550. useCustomAttenuation: boolean;
  107551. /**
  107552. * The sound track id this sound belongs to.
  107553. */
  107554. soundTrackId: number;
  107555. /**
  107556. * Is this sound currently played.
  107557. */
  107558. isPlaying: boolean;
  107559. /**
  107560. * Is this sound currently paused.
  107561. */
  107562. isPaused: boolean;
  107563. /**
  107564. * Does this sound enables spatial sound.
  107565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107566. */
  107567. spatialSound: boolean;
  107568. /**
  107569. * Define the reference distance the sound should be heard perfectly.
  107570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107571. */
  107572. refDistance: number;
  107573. /**
  107574. * Define the roll off factor of spatial sounds.
  107575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107576. */
  107577. rolloffFactor: number;
  107578. /**
  107579. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  107580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107581. */
  107582. maxDistance: number;
  107583. /**
  107584. * Define the distance attenuation model the sound will follow.
  107585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107586. */
  107587. distanceModel: string;
  107588. /**
  107589. * @hidden
  107590. * Back Compat
  107591. **/
  107592. onended: () => any;
  107593. /**
  107594. * Observable event when the current playing sound finishes.
  107595. */
  107596. onEndedObservable: Observable<Sound>;
  107597. private _panningModel;
  107598. private _playbackRate;
  107599. private _streaming;
  107600. private _startTime;
  107601. private _startOffset;
  107602. private _position;
  107603. /** @hidden */
  107604. _positionInEmitterSpace: boolean;
  107605. private _localDirection;
  107606. private _volume;
  107607. private _isReadyToPlay;
  107608. private _isDirectional;
  107609. private _readyToPlayCallback;
  107610. private _audioBuffer;
  107611. private _soundSource;
  107612. private _streamingSource;
  107613. private _soundPanner;
  107614. private _soundGain;
  107615. private _inputAudioNode;
  107616. private _outputAudioNode;
  107617. private _coneInnerAngle;
  107618. private _coneOuterAngle;
  107619. private _coneOuterGain;
  107620. private _scene;
  107621. private _connectedTransformNode;
  107622. private _customAttenuationFunction;
  107623. private _registerFunc;
  107624. private _isOutputConnected;
  107625. private _htmlAudioElement;
  107626. private _urlType;
  107627. private _length?;
  107628. private _offset?;
  107629. /** @hidden */
  107630. static _SceneComponentInitialization: (scene: Scene) => void;
  107631. /**
  107632. * Create a sound and attach it to a scene
  107633. * @param name Name of your sound
  107634. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  107635. * @param scene defines the scene the sound belongs to
  107636. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  107637. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  107638. */
  107639. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  107640. /**
  107641. * Release the sound and its associated resources
  107642. */
  107643. dispose(): void;
  107644. /**
  107645. * Gets if the sounds is ready to be played or not.
  107646. * @returns true if ready, otherwise false
  107647. */
  107648. isReady(): boolean;
  107649. private _soundLoaded;
  107650. /**
  107651. * Sets the data of the sound from an audiobuffer
  107652. * @param audioBuffer The audioBuffer containing the data
  107653. */
  107654. setAudioBuffer(audioBuffer: AudioBuffer): void;
  107655. /**
  107656. * Updates the current sounds options such as maxdistance, loop...
  107657. * @param options A JSON object containing values named as the object properties
  107658. */
  107659. updateOptions(options: ISoundOptions): void;
  107660. private _createSpatialParameters;
  107661. private _updateSpatialParameters;
  107662. /**
  107663. * Switch the panning model to HRTF:
  107664. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107666. */
  107667. switchPanningModelToHRTF(): void;
  107668. /**
  107669. * Switch the panning model to Equal Power:
  107670. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107672. */
  107673. switchPanningModelToEqualPower(): void;
  107674. private _switchPanningModel;
  107675. /**
  107676. * Connect this sound to a sound track audio node like gain...
  107677. * @param soundTrackAudioNode the sound track audio node to connect to
  107678. */
  107679. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  107680. /**
  107681. * Transform this sound into a directional source
  107682. * @param coneInnerAngle Size of the inner cone in degree
  107683. * @param coneOuterAngle Size of the outer cone in degree
  107684. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  107685. */
  107686. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  107687. /**
  107688. * Gets or sets the inner angle for the directional cone.
  107689. */
  107690. get directionalConeInnerAngle(): number;
  107691. /**
  107692. * Gets or sets the inner angle for the directional cone.
  107693. */
  107694. set directionalConeInnerAngle(value: number);
  107695. /**
  107696. * Gets or sets the outer angle for the directional cone.
  107697. */
  107698. get directionalConeOuterAngle(): number;
  107699. /**
  107700. * Gets or sets the outer angle for the directional cone.
  107701. */
  107702. set directionalConeOuterAngle(value: number);
  107703. /**
  107704. * Sets the position of the emitter if spatial sound is enabled
  107705. * @param newPosition Defines the new posisiton
  107706. */
  107707. setPosition(newPosition: Vector3): void;
  107708. /**
  107709. * Sets the local direction of the emitter if spatial sound is enabled
  107710. * @param newLocalDirection Defines the new local direction
  107711. */
  107712. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  107713. private _updateDirection;
  107714. /** @hidden */
  107715. updateDistanceFromListener(): void;
  107716. /**
  107717. * Sets a new custom attenuation function for the sound.
  107718. * @param callback Defines the function used for the attenuation
  107719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107720. */
  107721. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  107722. /**
  107723. * Play the sound
  107724. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  107725. * @param offset (optional) Start the sound at a specific time in seconds
  107726. * @param length (optional) Sound duration (in seconds)
  107727. */
  107728. play(time?: number, offset?: number, length?: number): void;
  107729. private _onended;
  107730. /**
  107731. * Stop the sound
  107732. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  107733. */
  107734. stop(time?: number): void;
  107735. /**
  107736. * Put the sound in pause
  107737. */
  107738. pause(): void;
  107739. /**
  107740. * Sets a dedicated volume for this sounds
  107741. * @param newVolume Define the new volume of the sound
  107742. * @param time Define time for gradual change to new volume
  107743. */
  107744. setVolume(newVolume: number, time?: number): void;
  107745. /**
  107746. * Set the sound play back rate
  107747. * @param newPlaybackRate Define the playback rate the sound should be played at
  107748. */
  107749. setPlaybackRate(newPlaybackRate: number): void;
  107750. /**
  107751. * Gets the volume of the sound.
  107752. * @returns the volume of the sound
  107753. */
  107754. getVolume(): number;
  107755. /**
  107756. * Attach the sound to a dedicated mesh
  107757. * @param transformNode The transform node to connect the sound with
  107758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107759. */
  107760. attachToMesh(transformNode: TransformNode): void;
  107761. /**
  107762. * Detach the sound from the previously attached mesh
  107763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107764. */
  107765. detachFromMesh(): void;
  107766. private _onRegisterAfterWorldMatrixUpdate;
  107767. /**
  107768. * Clone the current sound in the scene.
  107769. * @returns the new sound clone
  107770. */
  107771. clone(): Nullable<Sound>;
  107772. /**
  107773. * Gets the current underlying audio buffer containing the data
  107774. * @returns the audio buffer
  107775. */
  107776. getAudioBuffer(): Nullable<AudioBuffer>;
  107777. /**
  107778. * Serializes the Sound in a JSON representation
  107779. * @returns the JSON representation of the sound
  107780. */
  107781. serialize(): any;
  107782. /**
  107783. * Parse a JSON representation of a sound to innstantiate in a given scene
  107784. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  107785. * @param scene Define the scene the new parsed sound should be created in
  107786. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  107787. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  107788. * @returns the newly parsed sound
  107789. */
  107790. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  107791. }
  107792. }
  107793. declare module BABYLON {
  107794. /**
  107795. * This defines an action helpful to play a defined sound on a triggered action.
  107796. */
  107797. export class PlaySoundAction extends Action {
  107798. private _sound;
  107799. /**
  107800. * Instantiate the action
  107801. * @param triggerOptions defines the trigger options
  107802. * @param sound defines the sound to play
  107803. * @param condition defines the trigger related conditions
  107804. */
  107805. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107806. /** @hidden */
  107807. _prepare(): void;
  107808. /**
  107809. * Execute the action and play the sound.
  107810. */
  107811. execute(): void;
  107812. /**
  107813. * Serializes the actions and its related information.
  107814. * @param parent defines the object to serialize in
  107815. * @returns the serialized object
  107816. */
  107817. serialize(parent: any): any;
  107818. }
  107819. /**
  107820. * This defines an action helpful to stop a defined sound on a triggered action.
  107821. */
  107822. export class StopSoundAction extends Action {
  107823. private _sound;
  107824. /**
  107825. * Instantiate the action
  107826. * @param triggerOptions defines the trigger options
  107827. * @param sound defines the sound to stop
  107828. * @param condition defines the trigger related conditions
  107829. */
  107830. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107831. /** @hidden */
  107832. _prepare(): void;
  107833. /**
  107834. * Execute the action and stop the sound.
  107835. */
  107836. execute(): void;
  107837. /**
  107838. * Serializes the actions and its related information.
  107839. * @param parent defines the object to serialize in
  107840. * @returns the serialized object
  107841. */
  107842. serialize(parent: any): any;
  107843. }
  107844. }
  107845. declare module BABYLON {
  107846. /**
  107847. * This defines an action responsible to change the value of a property
  107848. * by interpolating between its current value and the newly set one once triggered.
  107849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  107850. */
  107851. export class InterpolateValueAction extends Action {
  107852. /**
  107853. * Defines the path of the property where the value should be interpolated
  107854. */
  107855. propertyPath: string;
  107856. /**
  107857. * Defines the target value at the end of the interpolation.
  107858. */
  107859. value: any;
  107860. /**
  107861. * Defines the time it will take for the property to interpolate to the value.
  107862. */
  107863. duration: number;
  107864. /**
  107865. * Defines if the other scene animations should be stopped when the action has been triggered
  107866. */
  107867. stopOtherAnimations?: boolean;
  107868. /**
  107869. * Defines a callback raised once the interpolation animation has been done.
  107870. */
  107871. onInterpolationDone?: () => void;
  107872. /**
  107873. * Observable triggered once the interpolation animation has been done.
  107874. */
  107875. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  107876. private _target;
  107877. private _effectiveTarget;
  107878. private _property;
  107879. /**
  107880. * Instantiate the action
  107881. * @param triggerOptions defines the trigger options
  107882. * @param target defines the object containing the value to interpolate
  107883. * @param propertyPath defines the path to the property in the target object
  107884. * @param value defines the target value at the end of the interpolation
  107885. * @param duration deines the time it will take for the property to interpolate to the value.
  107886. * @param condition defines the trigger related conditions
  107887. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  107888. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  107889. */
  107890. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  107891. /** @hidden */
  107892. _prepare(): void;
  107893. /**
  107894. * Execute the action starts the value interpolation.
  107895. */
  107896. execute(): void;
  107897. /**
  107898. * Serializes the actions and its related information.
  107899. * @param parent defines the object to serialize in
  107900. * @returns the serialized object
  107901. */
  107902. serialize(parent: any): any;
  107903. }
  107904. }
  107905. declare module BABYLON {
  107906. /**
  107907. * Options allowed during the creation of a sound track.
  107908. */
  107909. export interface ISoundTrackOptions {
  107910. /**
  107911. * The volume the sound track should take during creation
  107912. */
  107913. volume?: number;
  107914. /**
  107915. * Define if the sound track is the main sound track of the scene
  107916. */
  107917. mainTrack?: boolean;
  107918. }
  107919. /**
  107920. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  107921. * It will be also used in a future release to apply effects on a specific track.
  107922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107923. */
  107924. export class SoundTrack {
  107925. /**
  107926. * The unique identifier of the sound track in the scene.
  107927. */
  107928. id: number;
  107929. /**
  107930. * The list of sounds included in the sound track.
  107931. */
  107932. soundCollection: Array<Sound>;
  107933. private _outputAudioNode;
  107934. private _scene;
  107935. private _connectedAnalyser;
  107936. private _options;
  107937. private _isInitialized;
  107938. /**
  107939. * Creates a new sound track.
  107940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107941. * @param scene Define the scene the sound track belongs to
  107942. * @param options
  107943. */
  107944. constructor(scene: Scene, options?: ISoundTrackOptions);
  107945. private _initializeSoundTrackAudioGraph;
  107946. /**
  107947. * Release the sound track and its associated resources
  107948. */
  107949. dispose(): void;
  107950. /**
  107951. * Adds a sound to this sound track
  107952. * @param sound define the cound to add
  107953. * @ignoreNaming
  107954. */
  107955. AddSound(sound: Sound): void;
  107956. /**
  107957. * Removes a sound to this sound track
  107958. * @param sound define the cound to remove
  107959. * @ignoreNaming
  107960. */
  107961. RemoveSound(sound: Sound): void;
  107962. /**
  107963. * Set a global volume for the full sound track.
  107964. * @param newVolume Define the new volume of the sound track
  107965. */
  107966. setVolume(newVolume: number): void;
  107967. /**
  107968. * Switch the panning model to HRTF:
  107969. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107971. */
  107972. switchPanningModelToHRTF(): void;
  107973. /**
  107974. * Switch the panning model to Equal Power:
  107975. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107977. */
  107978. switchPanningModelToEqualPower(): void;
  107979. /**
  107980. * Connect the sound track to an audio analyser allowing some amazing
  107981. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107983. * @param analyser The analyser to connect to the engine
  107984. */
  107985. connectToAnalyser(analyser: Analyser): void;
  107986. }
  107987. }
  107988. declare module BABYLON {
  107989. interface AbstractScene {
  107990. /**
  107991. * The list of sounds used in the scene.
  107992. */
  107993. sounds: Nullable<Array<Sound>>;
  107994. }
  107995. interface Scene {
  107996. /**
  107997. * @hidden
  107998. * Backing field
  107999. */
  108000. _mainSoundTrack: SoundTrack;
  108001. /**
  108002. * The main sound track played by the scene.
  108003. * It cotains your primary collection of sounds.
  108004. */
  108005. mainSoundTrack: SoundTrack;
  108006. /**
  108007. * The list of sound tracks added to the scene
  108008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108009. */
  108010. soundTracks: Nullable<Array<SoundTrack>>;
  108011. /**
  108012. * Gets a sound using a given name
  108013. * @param name defines the name to search for
  108014. * @return the found sound or null if not found at all.
  108015. */
  108016. getSoundByName(name: string): Nullable<Sound>;
  108017. /**
  108018. * Gets or sets if audio support is enabled
  108019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108020. */
  108021. audioEnabled: boolean;
  108022. /**
  108023. * Gets or sets if audio will be output to headphones
  108024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108025. */
  108026. headphone: boolean;
  108027. /**
  108028. * Gets or sets custom audio listener position provider
  108029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108030. */
  108031. audioListenerPositionProvider: Nullable<() => Vector3>;
  108032. /**
  108033. * Gets or sets a refresh rate when using 3D audio positioning
  108034. */
  108035. audioPositioningRefreshRate: number;
  108036. }
  108037. /**
  108038. * Defines the sound scene component responsible to manage any sounds
  108039. * in a given scene.
  108040. */
  108041. export class AudioSceneComponent implements ISceneSerializableComponent {
  108042. /**
  108043. * The component name helpfull to identify the component in the list of scene components.
  108044. */
  108045. readonly name: string;
  108046. /**
  108047. * The scene the component belongs to.
  108048. */
  108049. scene: Scene;
  108050. private _audioEnabled;
  108051. /**
  108052. * Gets whether audio is enabled or not.
  108053. * Please use related enable/disable method to switch state.
  108054. */
  108055. get audioEnabled(): boolean;
  108056. private _headphone;
  108057. /**
  108058. * Gets whether audio is outputing to headphone or not.
  108059. * Please use the according Switch methods to change output.
  108060. */
  108061. get headphone(): boolean;
  108062. /**
  108063. * Gets or sets a refresh rate when using 3D audio positioning
  108064. */
  108065. audioPositioningRefreshRate: number;
  108066. private _audioListenerPositionProvider;
  108067. /**
  108068. * Gets the current audio listener position provider
  108069. */
  108070. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108071. /**
  108072. * Sets a custom listener position for all sounds in the scene
  108073. * By default, this is the position of the first active camera
  108074. */
  108075. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108076. /**
  108077. * Creates a new instance of the component for the given scene
  108078. * @param scene Defines the scene to register the component in
  108079. */
  108080. constructor(scene: Scene);
  108081. /**
  108082. * Registers the component in a given scene
  108083. */
  108084. register(): void;
  108085. /**
  108086. * Rebuilds the elements related to this component in case of
  108087. * context lost for instance.
  108088. */
  108089. rebuild(): void;
  108090. /**
  108091. * Serializes the component data to the specified json object
  108092. * @param serializationObject The object to serialize to
  108093. */
  108094. serialize(serializationObject: any): void;
  108095. /**
  108096. * Adds all the elements from the container to the scene
  108097. * @param container the container holding the elements
  108098. */
  108099. addFromContainer(container: AbstractScene): void;
  108100. /**
  108101. * Removes all the elements in the container from the scene
  108102. * @param container contains the elements to remove
  108103. * @param dispose if the removed element should be disposed (default: false)
  108104. */
  108105. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108106. /**
  108107. * Disposes the component and the associated ressources.
  108108. */
  108109. dispose(): void;
  108110. /**
  108111. * Disables audio in the associated scene.
  108112. */
  108113. disableAudio(): void;
  108114. /**
  108115. * Enables audio in the associated scene.
  108116. */
  108117. enableAudio(): void;
  108118. /**
  108119. * Switch audio to headphone output.
  108120. */
  108121. switchAudioModeForHeadphones(): void;
  108122. /**
  108123. * Switch audio to normal speakers.
  108124. */
  108125. switchAudioModeForNormalSpeakers(): void;
  108126. private _cachedCameraDirection;
  108127. private _cachedCameraPosition;
  108128. private _lastCheck;
  108129. private _afterRender;
  108130. }
  108131. }
  108132. declare module BABYLON {
  108133. /**
  108134. * Wraps one or more Sound objects and selects one with random weight for playback.
  108135. */
  108136. export class WeightedSound {
  108137. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108138. loop: boolean;
  108139. private _coneInnerAngle;
  108140. private _coneOuterAngle;
  108141. private _volume;
  108142. /** A Sound is currently playing. */
  108143. isPlaying: boolean;
  108144. /** A Sound is currently paused. */
  108145. isPaused: boolean;
  108146. private _sounds;
  108147. private _weights;
  108148. private _currentIndex?;
  108149. /**
  108150. * Creates a new WeightedSound from the list of sounds given.
  108151. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  108152. * @param sounds Array of Sounds that will be selected from.
  108153. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  108154. */
  108155. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  108156. /**
  108157. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  108158. */
  108159. get directionalConeInnerAngle(): number;
  108160. /**
  108161. * The size of cone in degress for a directional sound in which there will be no attenuation.
  108162. */
  108163. set directionalConeInnerAngle(value: number);
  108164. /**
  108165. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108166. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108167. */
  108168. get directionalConeOuterAngle(): number;
  108169. /**
  108170. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108171. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108172. */
  108173. set directionalConeOuterAngle(value: number);
  108174. /**
  108175. * Playback volume.
  108176. */
  108177. get volume(): number;
  108178. /**
  108179. * Playback volume.
  108180. */
  108181. set volume(value: number);
  108182. private _onended;
  108183. /**
  108184. * Suspend playback
  108185. */
  108186. pause(): void;
  108187. /**
  108188. * Stop playback
  108189. */
  108190. stop(): void;
  108191. /**
  108192. * Start playback.
  108193. * @param startOffset Position the clip head at a specific time in seconds.
  108194. */
  108195. play(startOffset?: number): void;
  108196. }
  108197. }
  108198. declare module BABYLON {
  108199. /**
  108200. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  108201. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108202. */
  108203. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  108204. /**
  108205. * Gets the name of the behavior.
  108206. */
  108207. get name(): string;
  108208. /**
  108209. * The easing function used by animations
  108210. */
  108211. static EasingFunction: BackEase;
  108212. /**
  108213. * The easing mode used by animations
  108214. */
  108215. static EasingMode: number;
  108216. /**
  108217. * The duration of the animation, in milliseconds
  108218. */
  108219. transitionDuration: number;
  108220. /**
  108221. * Length of the distance animated by the transition when lower radius is reached
  108222. */
  108223. lowerRadiusTransitionRange: number;
  108224. /**
  108225. * Length of the distance animated by the transition when upper radius is reached
  108226. */
  108227. upperRadiusTransitionRange: number;
  108228. private _autoTransitionRange;
  108229. /**
  108230. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108231. */
  108232. get autoTransitionRange(): boolean;
  108233. /**
  108234. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108235. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  108236. */
  108237. set autoTransitionRange(value: boolean);
  108238. private _attachedCamera;
  108239. private _onAfterCheckInputsObserver;
  108240. private _onMeshTargetChangedObserver;
  108241. /**
  108242. * Initializes the behavior.
  108243. */
  108244. init(): void;
  108245. /**
  108246. * Attaches the behavior to its arc rotate camera.
  108247. * @param camera Defines the camera to attach the behavior to
  108248. */
  108249. attach(camera: ArcRotateCamera): void;
  108250. /**
  108251. * Detaches the behavior from its current arc rotate camera.
  108252. */
  108253. detach(): void;
  108254. private _radiusIsAnimating;
  108255. private _radiusBounceTransition;
  108256. private _animatables;
  108257. private _cachedWheelPrecision;
  108258. /**
  108259. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  108260. * @param radiusLimit The limit to check against.
  108261. * @return Bool to indicate if at limit.
  108262. */
  108263. private _isRadiusAtLimit;
  108264. /**
  108265. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  108266. * @param radiusDelta The delta by which to animate to. Can be negative.
  108267. */
  108268. private _applyBoundRadiusAnimation;
  108269. /**
  108270. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  108271. */
  108272. protected _clearAnimationLocks(): void;
  108273. /**
  108274. * Stops and removes all animations that have been applied to the camera
  108275. */
  108276. stopAllAnimations(): void;
  108277. }
  108278. }
  108279. declare module BABYLON {
  108280. /**
  108281. * 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.
  108282. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108283. */
  108284. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  108285. /**
  108286. * Gets the name of the behavior.
  108287. */
  108288. get name(): string;
  108289. private _mode;
  108290. private _radiusScale;
  108291. private _positionScale;
  108292. private _defaultElevation;
  108293. private _elevationReturnTime;
  108294. private _elevationReturnWaitTime;
  108295. private _zoomStopsAnimation;
  108296. private _framingTime;
  108297. /**
  108298. * The easing function used by animations
  108299. */
  108300. static EasingFunction: ExponentialEase;
  108301. /**
  108302. * The easing mode used by animations
  108303. */
  108304. static EasingMode: number;
  108305. /**
  108306. * Sets the current mode used by the behavior
  108307. */
  108308. set mode(mode: number);
  108309. /**
  108310. * Gets current mode used by the behavior.
  108311. */
  108312. get mode(): number;
  108313. /**
  108314. * Sets the scale applied to the radius (1 by default)
  108315. */
  108316. set radiusScale(radius: number);
  108317. /**
  108318. * Gets the scale applied to the radius
  108319. */
  108320. get radiusScale(): number;
  108321. /**
  108322. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108323. */
  108324. set positionScale(scale: number);
  108325. /**
  108326. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108327. */
  108328. get positionScale(): number;
  108329. /**
  108330. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108331. * behaviour is triggered, in radians.
  108332. */
  108333. set defaultElevation(elevation: number);
  108334. /**
  108335. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108336. * behaviour is triggered, in radians.
  108337. */
  108338. get defaultElevation(): number;
  108339. /**
  108340. * Sets the time (in milliseconds) taken to return to the default beta position.
  108341. * Negative value indicates camera should not return to default.
  108342. */
  108343. set elevationReturnTime(speed: number);
  108344. /**
  108345. * Gets the time (in milliseconds) taken to return to the default beta position.
  108346. * Negative value indicates camera should not return to default.
  108347. */
  108348. get elevationReturnTime(): number;
  108349. /**
  108350. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108351. */
  108352. set elevationReturnWaitTime(time: number);
  108353. /**
  108354. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108355. */
  108356. get elevationReturnWaitTime(): number;
  108357. /**
  108358. * Sets the flag that indicates if user zooming should stop animation.
  108359. */
  108360. set zoomStopsAnimation(flag: boolean);
  108361. /**
  108362. * Gets the flag that indicates if user zooming should stop animation.
  108363. */
  108364. get zoomStopsAnimation(): boolean;
  108365. /**
  108366. * Sets the transition time when framing the mesh, in milliseconds
  108367. */
  108368. set framingTime(time: number);
  108369. /**
  108370. * Gets the transition time when framing the mesh, in milliseconds
  108371. */
  108372. get framingTime(): number;
  108373. /**
  108374. * Define if the behavior should automatically change the configured
  108375. * camera limits and sensibilities.
  108376. */
  108377. autoCorrectCameraLimitsAndSensibility: boolean;
  108378. private _onPrePointerObservableObserver;
  108379. private _onAfterCheckInputsObserver;
  108380. private _onMeshTargetChangedObserver;
  108381. private _attachedCamera;
  108382. private _isPointerDown;
  108383. private _lastInteractionTime;
  108384. /**
  108385. * Initializes the behavior.
  108386. */
  108387. init(): void;
  108388. /**
  108389. * Attaches the behavior to its arc rotate camera.
  108390. * @param camera Defines the camera to attach the behavior to
  108391. */
  108392. attach(camera: ArcRotateCamera): void;
  108393. /**
  108394. * Detaches the behavior from its current arc rotate camera.
  108395. */
  108396. detach(): void;
  108397. private _animatables;
  108398. private _betaIsAnimating;
  108399. private _betaTransition;
  108400. private _radiusTransition;
  108401. private _vectorTransition;
  108402. /**
  108403. * Targets the given mesh and updates zoom level accordingly.
  108404. * @param mesh The mesh to target.
  108405. * @param radius Optional. If a cached radius position already exists, overrides default.
  108406. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108407. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108408. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108409. */
  108410. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108411. /**
  108412. * Targets the given mesh with its children and updates zoom level accordingly.
  108413. * @param mesh The mesh to target.
  108414. * @param radius Optional. If a cached radius position already exists, overrides default.
  108415. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108416. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108417. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108418. */
  108419. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108420. /**
  108421. * Targets the given meshes with their children and updates zoom level accordingly.
  108422. * @param meshes The mesh to target.
  108423. * @param radius Optional. If a cached radius position already exists, overrides default.
  108424. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108425. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108426. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108427. */
  108428. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108429. /**
  108430. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  108431. * @param minimumWorld Determines the smaller position of the bounding box extend
  108432. * @param maximumWorld Determines the bigger position of the bounding box extend
  108433. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108434. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108435. */
  108436. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108437. /**
  108438. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  108439. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  108440. * frustum width.
  108441. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  108442. * to fully enclose the mesh in the viewing frustum.
  108443. */
  108444. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  108445. /**
  108446. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  108447. * is automatically returned to its default position (expected to be above ground plane).
  108448. */
  108449. private _maintainCameraAboveGround;
  108450. /**
  108451. * Returns the frustum slope based on the canvas ratio and camera FOV
  108452. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  108453. */
  108454. private _getFrustumSlope;
  108455. /**
  108456. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  108457. */
  108458. private _clearAnimationLocks;
  108459. /**
  108460. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  108461. */
  108462. private _applyUserInteraction;
  108463. /**
  108464. * Stops and removes all animations that have been applied to the camera
  108465. */
  108466. stopAllAnimations(): void;
  108467. /**
  108468. * Gets a value indicating if the user is moving the camera
  108469. */
  108470. get isUserIsMoving(): boolean;
  108471. /**
  108472. * The camera can move all the way towards the mesh.
  108473. */
  108474. static IgnoreBoundsSizeMode: number;
  108475. /**
  108476. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  108477. */
  108478. static FitFrustumSidesMode: number;
  108479. }
  108480. }
  108481. declare module BABYLON {
  108482. /**
  108483. * Base class for Camera Pointer Inputs.
  108484. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  108485. * for example usage.
  108486. */
  108487. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  108488. /**
  108489. * Defines the camera the input is attached to.
  108490. */
  108491. abstract camera: Camera;
  108492. /**
  108493. * Whether keyboard modifier keys are pressed at time of last mouse event.
  108494. */
  108495. protected _altKey: boolean;
  108496. protected _ctrlKey: boolean;
  108497. protected _metaKey: boolean;
  108498. protected _shiftKey: boolean;
  108499. /**
  108500. * Which mouse buttons were pressed at time of last mouse event.
  108501. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  108502. */
  108503. protected _buttonsPressed: number;
  108504. /**
  108505. * Defines the buttons associated with the input to handle camera move.
  108506. */
  108507. buttons: number[];
  108508. /**
  108509. * Attach the input controls to a specific dom element to get the input from.
  108510. * @param element Defines the element the controls should be listened from
  108511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108512. */
  108513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108514. /**
  108515. * Detach the current controls from the specified dom element.
  108516. * @param element Defines the element to stop listening the inputs from
  108517. */
  108518. detachControl(element: Nullable<HTMLElement>): void;
  108519. /**
  108520. * Gets the class name of the current input.
  108521. * @returns the class name
  108522. */
  108523. getClassName(): string;
  108524. /**
  108525. * Get the friendly name associated with the input class.
  108526. * @returns the input friendly name
  108527. */
  108528. getSimpleName(): string;
  108529. /**
  108530. * Called on pointer POINTERDOUBLETAP event.
  108531. * Override this method to provide functionality on POINTERDOUBLETAP event.
  108532. */
  108533. protected onDoubleTap(type: string): void;
  108534. /**
  108535. * Called on pointer POINTERMOVE event if only a single touch is active.
  108536. * Override this method to provide functionality.
  108537. */
  108538. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108539. /**
  108540. * Called on pointer POINTERMOVE event if multiple touches are active.
  108541. * Override this method to provide functionality.
  108542. */
  108543. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108544. /**
  108545. * Called on JS contextmenu event.
  108546. * Override this method to provide functionality.
  108547. */
  108548. protected onContextMenu(evt: PointerEvent): void;
  108549. /**
  108550. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108551. * press.
  108552. * Override this method to provide functionality.
  108553. */
  108554. protected onButtonDown(evt: PointerEvent): void;
  108555. /**
  108556. * Called each time a new POINTERUP event occurs. Ie, for each button
  108557. * release.
  108558. * Override this method to provide functionality.
  108559. */
  108560. protected onButtonUp(evt: PointerEvent): void;
  108561. /**
  108562. * Called when window becomes inactive.
  108563. * Override this method to provide functionality.
  108564. */
  108565. protected onLostFocus(): void;
  108566. private _pointerInput;
  108567. private _observer;
  108568. private _onLostFocus;
  108569. private pointA;
  108570. private pointB;
  108571. }
  108572. }
  108573. declare module BABYLON {
  108574. /**
  108575. * Manage the pointers inputs to control an arc rotate camera.
  108576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108577. */
  108578. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  108579. /**
  108580. * Defines the camera the input is attached to.
  108581. */
  108582. camera: ArcRotateCamera;
  108583. /**
  108584. * Gets the class name of the current input.
  108585. * @returns the class name
  108586. */
  108587. getClassName(): string;
  108588. /**
  108589. * Defines the buttons associated with the input to handle camera move.
  108590. */
  108591. buttons: number[];
  108592. /**
  108593. * Defines the pointer angular sensibility along the X axis or how fast is
  108594. * the camera rotating.
  108595. */
  108596. angularSensibilityX: number;
  108597. /**
  108598. * Defines the pointer angular sensibility along the Y axis or how fast is
  108599. * the camera rotating.
  108600. */
  108601. angularSensibilityY: number;
  108602. /**
  108603. * Defines the pointer pinch precision or how fast is the camera zooming.
  108604. */
  108605. pinchPrecision: number;
  108606. /**
  108607. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108608. * from 0.
  108609. * It defines the percentage of current camera.radius to use as delta when
  108610. * pinch zoom is used.
  108611. */
  108612. pinchDeltaPercentage: number;
  108613. /**
  108614. * Defines the pointer panning sensibility or how fast is the camera moving.
  108615. */
  108616. panningSensibility: number;
  108617. /**
  108618. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  108619. */
  108620. multiTouchPanning: boolean;
  108621. /**
  108622. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  108623. * zoom (pinch) through multitouch.
  108624. */
  108625. multiTouchPanAndZoom: boolean;
  108626. /**
  108627. * Revers pinch action direction.
  108628. */
  108629. pinchInwards: boolean;
  108630. private _isPanClick;
  108631. private _twoFingerActivityCount;
  108632. private _isPinching;
  108633. /**
  108634. * Called on pointer POINTERMOVE event if only a single touch is active.
  108635. */
  108636. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108637. /**
  108638. * Called on pointer POINTERDOUBLETAP event.
  108639. */
  108640. protected onDoubleTap(type: string): void;
  108641. /**
  108642. * Called on pointer POINTERMOVE event if multiple touches are active.
  108643. */
  108644. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108645. /**
  108646. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108647. * press.
  108648. */
  108649. protected onButtonDown(evt: PointerEvent): void;
  108650. /**
  108651. * Called each time a new POINTERUP event occurs. Ie, for each button
  108652. * release.
  108653. */
  108654. protected onButtonUp(evt: PointerEvent): void;
  108655. /**
  108656. * Called when window becomes inactive.
  108657. */
  108658. protected onLostFocus(): void;
  108659. }
  108660. }
  108661. declare module BABYLON {
  108662. /**
  108663. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  108664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108665. */
  108666. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  108667. /**
  108668. * Defines the camera the input is attached to.
  108669. */
  108670. camera: ArcRotateCamera;
  108671. /**
  108672. * Defines the list of key codes associated with the up action (increase alpha)
  108673. */
  108674. keysUp: number[];
  108675. /**
  108676. * Defines the list of key codes associated with the down action (decrease alpha)
  108677. */
  108678. keysDown: number[];
  108679. /**
  108680. * Defines the list of key codes associated with the left action (increase beta)
  108681. */
  108682. keysLeft: number[];
  108683. /**
  108684. * Defines the list of key codes associated with the right action (decrease beta)
  108685. */
  108686. keysRight: number[];
  108687. /**
  108688. * Defines the list of key codes associated with the reset action.
  108689. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  108690. */
  108691. keysReset: number[];
  108692. /**
  108693. * Defines the panning sensibility of the inputs.
  108694. * (How fast is the camera paning)
  108695. */
  108696. panningSensibility: number;
  108697. /**
  108698. * Defines the zooming sensibility of the inputs.
  108699. * (How fast is the camera zooming)
  108700. */
  108701. zoomingSensibility: number;
  108702. /**
  108703. * Defines wether maintaining the alt key down switch the movement mode from
  108704. * orientation to zoom.
  108705. */
  108706. useAltToZoom: boolean;
  108707. /**
  108708. * Rotation speed of the camera
  108709. */
  108710. angularSpeed: number;
  108711. private _keys;
  108712. private _ctrlPressed;
  108713. private _altPressed;
  108714. private _onCanvasBlurObserver;
  108715. private _onKeyboardObserver;
  108716. private _engine;
  108717. private _scene;
  108718. /**
  108719. * Attach the input controls to a specific dom element to get the input from.
  108720. * @param element Defines the element the controls should be listened from
  108721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108722. */
  108723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108724. /**
  108725. * Detach the current controls from the specified dom element.
  108726. * @param element Defines the element to stop listening the inputs from
  108727. */
  108728. detachControl(element: Nullable<HTMLElement>): void;
  108729. /**
  108730. * Update the current camera state depending on the inputs that have been used this frame.
  108731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108732. */
  108733. checkInputs(): void;
  108734. /**
  108735. * Gets the class name of the current intput.
  108736. * @returns the class name
  108737. */
  108738. getClassName(): string;
  108739. /**
  108740. * Get the friendly name associated with the input class.
  108741. * @returns the input friendly name
  108742. */
  108743. getSimpleName(): string;
  108744. }
  108745. }
  108746. declare module BABYLON {
  108747. /**
  108748. * Manage the mouse wheel inputs to control an arc rotate camera.
  108749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108750. */
  108751. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  108752. /**
  108753. * Defines the camera the input is attached to.
  108754. */
  108755. camera: ArcRotateCamera;
  108756. /**
  108757. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108758. */
  108759. wheelPrecision: number;
  108760. /**
  108761. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108762. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108763. */
  108764. wheelDeltaPercentage: number;
  108765. private _wheel;
  108766. private _observer;
  108767. private computeDeltaFromMouseWheelLegacyEvent;
  108768. /**
  108769. * Attach the input controls to a specific dom element to get the input from.
  108770. * @param element Defines the element the controls should be listened from
  108771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108772. */
  108773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108774. /**
  108775. * Detach the current controls from the specified dom element.
  108776. * @param element Defines the element to stop listening the inputs from
  108777. */
  108778. detachControl(element: Nullable<HTMLElement>): void;
  108779. /**
  108780. * Gets the class name of the current intput.
  108781. * @returns the class name
  108782. */
  108783. getClassName(): string;
  108784. /**
  108785. * Get the friendly name associated with the input class.
  108786. * @returns the input friendly name
  108787. */
  108788. getSimpleName(): string;
  108789. }
  108790. }
  108791. declare module BABYLON {
  108792. /**
  108793. * Default Inputs manager for the ArcRotateCamera.
  108794. * It groups all the default supported inputs for ease of use.
  108795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108796. */
  108797. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  108798. /**
  108799. * Instantiates a new ArcRotateCameraInputsManager.
  108800. * @param camera Defines the camera the inputs belong to
  108801. */
  108802. constructor(camera: ArcRotateCamera);
  108803. /**
  108804. * Add mouse wheel input support to the input manager.
  108805. * @returns the current input manager
  108806. */
  108807. addMouseWheel(): ArcRotateCameraInputsManager;
  108808. /**
  108809. * Add pointers input support to the input manager.
  108810. * @returns the current input manager
  108811. */
  108812. addPointers(): ArcRotateCameraInputsManager;
  108813. /**
  108814. * Add keyboard input support to the input manager.
  108815. * @returns the current input manager
  108816. */
  108817. addKeyboard(): ArcRotateCameraInputsManager;
  108818. }
  108819. }
  108820. declare module BABYLON {
  108821. /**
  108822. * This represents an orbital type of camera.
  108823. *
  108824. * 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.
  108825. * 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.
  108826. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  108827. */
  108828. export class ArcRotateCamera extends TargetCamera {
  108829. /**
  108830. * Defines the rotation angle of the camera along the longitudinal axis.
  108831. */
  108832. alpha: number;
  108833. /**
  108834. * Defines the rotation angle of the camera along the latitudinal axis.
  108835. */
  108836. beta: number;
  108837. /**
  108838. * Defines the radius of the camera from it s target point.
  108839. */
  108840. radius: number;
  108841. protected _target: Vector3;
  108842. protected _targetHost: Nullable<AbstractMesh>;
  108843. /**
  108844. * Defines the target point of the camera.
  108845. * The camera looks towards it form the radius distance.
  108846. */
  108847. get target(): Vector3;
  108848. set target(value: Vector3);
  108849. /**
  108850. * Define the current local position of the camera in the scene
  108851. */
  108852. get position(): Vector3;
  108853. set position(newPosition: Vector3);
  108854. protected _upVector: Vector3;
  108855. protected _upToYMatrix: Matrix;
  108856. protected _YToUpMatrix: Matrix;
  108857. /**
  108858. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  108859. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  108860. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  108861. */
  108862. set upVector(vec: Vector3);
  108863. get upVector(): Vector3;
  108864. /**
  108865. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  108866. */
  108867. setMatUp(): void;
  108868. /**
  108869. * Current inertia value on the longitudinal axis.
  108870. * The bigger this number the longer it will take for the camera to stop.
  108871. */
  108872. inertialAlphaOffset: number;
  108873. /**
  108874. * Current inertia value on the latitudinal axis.
  108875. * The bigger this number the longer it will take for the camera to stop.
  108876. */
  108877. inertialBetaOffset: number;
  108878. /**
  108879. * Current inertia value on the radius axis.
  108880. * The bigger this number the longer it will take for the camera to stop.
  108881. */
  108882. inertialRadiusOffset: number;
  108883. /**
  108884. * Minimum allowed angle on the longitudinal axis.
  108885. * This can help limiting how the Camera is able to move in the scene.
  108886. */
  108887. lowerAlphaLimit: Nullable<number>;
  108888. /**
  108889. * Maximum allowed angle on the longitudinal axis.
  108890. * This can help limiting how the Camera is able to move in the scene.
  108891. */
  108892. upperAlphaLimit: Nullable<number>;
  108893. /**
  108894. * Minimum allowed angle on the latitudinal axis.
  108895. * This can help limiting how the Camera is able to move in the scene.
  108896. */
  108897. lowerBetaLimit: number;
  108898. /**
  108899. * Maximum allowed angle on the latitudinal axis.
  108900. * This can help limiting how the Camera is able to move in the scene.
  108901. */
  108902. upperBetaLimit: number;
  108903. /**
  108904. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  108905. * This can help limiting how the Camera is able to move in the scene.
  108906. */
  108907. lowerRadiusLimit: Nullable<number>;
  108908. /**
  108909. * Maximum allowed distance of the camera to the target (The camera can not get further).
  108910. * This can help limiting how the Camera is able to move in the scene.
  108911. */
  108912. upperRadiusLimit: Nullable<number>;
  108913. /**
  108914. * Defines the current inertia value used during panning of the camera along the X axis.
  108915. */
  108916. inertialPanningX: number;
  108917. /**
  108918. * Defines the current inertia value used during panning of the camera along the Y axis.
  108919. */
  108920. inertialPanningY: number;
  108921. /**
  108922. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  108923. * Basically if your fingers moves away from more than this distance you will be considered
  108924. * in pinch mode.
  108925. */
  108926. pinchToPanMaxDistance: number;
  108927. /**
  108928. * Defines the maximum distance the camera can pan.
  108929. * This could help keeping the cammera always in your scene.
  108930. */
  108931. panningDistanceLimit: Nullable<number>;
  108932. /**
  108933. * Defines the target of the camera before paning.
  108934. */
  108935. panningOriginTarget: Vector3;
  108936. /**
  108937. * Defines the value of the inertia used during panning.
  108938. * 0 would mean stop inertia and one would mean no decelleration at all.
  108939. */
  108940. panningInertia: number;
  108941. /**
  108942. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  108943. */
  108944. get angularSensibilityX(): number;
  108945. set angularSensibilityX(value: number);
  108946. /**
  108947. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  108948. */
  108949. get angularSensibilityY(): number;
  108950. set angularSensibilityY(value: number);
  108951. /**
  108952. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  108953. */
  108954. get pinchPrecision(): number;
  108955. set pinchPrecision(value: number);
  108956. /**
  108957. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  108958. * It will be used instead of pinchDeltaPrecision if different from 0.
  108959. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108960. */
  108961. get pinchDeltaPercentage(): number;
  108962. set pinchDeltaPercentage(value: number);
  108963. /**
  108964. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  108965. */
  108966. get panningSensibility(): number;
  108967. set panningSensibility(value: number);
  108968. /**
  108969. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  108970. */
  108971. get keysUp(): number[];
  108972. set keysUp(value: number[]);
  108973. /**
  108974. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  108975. */
  108976. get keysDown(): number[];
  108977. set keysDown(value: number[]);
  108978. /**
  108979. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  108980. */
  108981. get keysLeft(): number[];
  108982. set keysLeft(value: number[]);
  108983. /**
  108984. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  108985. */
  108986. get keysRight(): number[];
  108987. set keysRight(value: number[]);
  108988. /**
  108989. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108990. */
  108991. get wheelPrecision(): number;
  108992. set wheelPrecision(value: number);
  108993. /**
  108994. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  108995. * It will be used instead of pinchDeltaPrecision if different from 0.
  108996. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108997. */
  108998. get wheelDeltaPercentage(): number;
  108999. set wheelDeltaPercentage(value: number);
  109000. /**
  109001. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  109002. */
  109003. zoomOnFactor: number;
  109004. /**
  109005. * Defines a screen offset for the camera position.
  109006. */
  109007. targetScreenOffset: Vector2;
  109008. /**
  109009. * Allows the camera to be completely reversed.
  109010. * If false the camera can not arrive upside down.
  109011. */
  109012. allowUpsideDown: boolean;
  109013. /**
  109014. * Define if double tap/click is used to restore the previously saved state of the camera.
  109015. */
  109016. useInputToRestoreState: boolean;
  109017. /** @hidden */
  109018. _viewMatrix: Matrix;
  109019. /** @hidden */
  109020. _useCtrlForPanning: boolean;
  109021. /** @hidden */
  109022. _panningMouseButton: number;
  109023. /**
  109024. * Defines the input associated to the camera.
  109025. */
  109026. inputs: ArcRotateCameraInputsManager;
  109027. /** @hidden */
  109028. _reset: () => void;
  109029. /**
  109030. * Defines the allowed panning axis.
  109031. */
  109032. panningAxis: Vector3;
  109033. protected _localDirection: Vector3;
  109034. protected _transformedDirection: Vector3;
  109035. private _bouncingBehavior;
  109036. /**
  109037. * Gets the bouncing behavior of the camera if it has been enabled.
  109038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109039. */
  109040. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109041. /**
  109042. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109043. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109044. */
  109045. get useBouncingBehavior(): boolean;
  109046. set useBouncingBehavior(value: boolean);
  109047. private _framingBehavior;
  109048. /**
  109049. * Gets the framing behavior of the camera if it has been enabled.
  109050. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109051. */
  109052. get framingBehavior(): Nullable<FramingBehavior>;
  109053. /**
  109054. * Defines if the framing behavior of the camera is enabled on the camera.
  109055. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109056. */
  109057. get useFramingBehavior(): boolean;
  109058. set useFramingBehavior(value: boolean);
  109059. private _autoRotationBehavior;
  109060. /**
  109061. * Gets the auto rotation behavior of the camera if it has been enabled.
  109062. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109063. */
  109064. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109065. /**
  109066. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109067. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109068. */
  109069. get useAutoRotationBehavior(): boolean;
  109070. set useAutoRotationBehavior(value: boolean);
  109071. /**
  109072. * Observable triggered when the mesh target has been changed on the camera.
  109073. */
  109074. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109075. /**
  109076. * Event raised when the camera is colliding with a mesh.
  109077. */
  109078. onCollide: (collidedMesh: AbstractMesh) => void;
  109079. /**
  109080. * Defines whether the camera should check collision with the objects oh the scene.
  109081. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109082. */
  109083. checkCollisions: boolean;
  109084. /**
  109085. * Defines the collision radius of the camera.
  109086. * This simulates a sphere around the camera.
  109087. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109088. */
  109089. collisionRadius: Vector3;
  109090. protected _collider: Collider;
  109091. protected _previousPosition: Vector3;
  109092. protected _collisionVelocity: Vector3;
  109093. protected _newPosition: Vector3;
  109094. protected _previousAlpha: number;
  109095. protected _previousBeta: number;
  109096. protected _previousRadius: number;
  109097. protected _collisionTriggered: boolean;
  109098. protected _targetBoundingCenter: Nullable<Vector3>;
  109099. private _computationVector;
  109100. /**
  109101. * Instantiates a new ArcRotateCamera in a given scene
  109102. * @param name Defines the name of the camera
  109103. * @param alpha Defines the camera rotation along the logitudinal axis
  109104. * @param beta Defines the camera rotation along the latitudinal axis
  109105. * @param radius Defines the camera distance from its target
  109106. * @param target Defines the camera target
  109107. * @param scene Defines the scene the camera belongs to
  109108. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109109. */
  109110. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109111. /** @hidden */
  109112. _initCache(): void;
  109113. /** @hidden */
  109114. _updateCache(ignoreParentClass?: boolean): void;
  109115. protected _getTargetPosition(): Vector3;
  109116. private _storedAlpha;
  109117. private _storedBeta;
  109118. private _storedRadius;
  109119. private _storedTarget;
  109120. private _storedTargetScreenOffset;
  109121. /**
  109122. * Stores the current state of the camera (alpha, beta, radius and target)
  109123. * @returns the camera itself
  109124. */
  109125. storeState(): Camera;
  109126. /**
  109127. * @hidden
  109128. * Restored camera state. You must call storeState() first
  109129. */
  109130. _restoreStateValues(): boolean;
  109131. /** @hidden */
  109132. _isSynchronizedViewMatrix(): boolean;
  109133. /**
  109134. * Attached controls to the current camera.
  109135. * @param element Defines the element the controls should be listened from
  109136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109137. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109138. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109139. */
  109140. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  109141. /**
  109142. * Detach the current controls from the camera.
  109143. * The camera will stop reacting to inputs.
  109144. * @param element Defines the element to stop listening the inputs from
  109145. */
  109146. detachControl(element: HTMLElement): void;
  109147. /** @hidden */
  109148. _checkInputs(): void;
  109149. protected _checkLimits(): void;
  109150. /**
  109151. * Rebuilds angles (alpha, beta) and radius from the give position and target
  109152. */
  109153. rebuildAnglesAndRadius(): void;
  109154. /**
  109155. * Use a position to define the current camera related information like alpha, beta and radius
  109156. * @param position Defines the position to set the camera at
  109157. */
  109158. setPosition(position: Vector3): void;
  109159. /**
  109160. * Defines the target the camera should look at.
  109161. * This will automatically adapt alpha beta and radius to fit within the new target.
  109162. * @param target Defines the new target as a Vector or a mesh
  109163. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  109164. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  109165. */
  109166. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  109167. /** @hidden */
  109168. _getViewMatrix(): Matrix;
  109169. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  109170. /**
  109171. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  109172. * @param meshes Defines the mesh to zoom on
  109173. * @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)
  109174. */
  109175. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  109176. /**
  109177. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  109178. * The target will be changed but the radius
  109179. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  109180. * @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)
  109181. */
  109182. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  109183. min: Vector3;
  109184. max: Vector3;
  109185. distance: number;
  109186. }, doNotUpdateMaxZ?: boolean): void;
  109187. /**
  109188. * @override
  109189. * Override Camera.createRigCamera
  109190. */
  109191. createRigCamera(name: string, cameraIndex: number): Camera;
  109192. /**
  109193. * @hidden
  109194. * @override
  109195. * Override Camera._updateRigCameras
  109196. */
  109197. _updateRigCameras(): void;
  109198. /**
  109199. * Destroy the camera and release the current resources hold by it.
  109200. */
  109201. dispose(): void;
  109202. /**
  109203. * Gets the current object class name.
  109204. * @return the class name
  109205. */
  109206. getClassName(): string;
  109207. }
  109208. }
  109209. declare module BABYLON {
  109210. /**
  109211. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  109212. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109213. */
  109214. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  109215. /**
  109216. * Gets the name of the behavior.
  109217. */
  109218. get name(): string;
  109219. private _zoomStopsAnimation;
  109220. private _idleRotationSpeed;
  109221. private _idleRotationWaitTime;
  109222. private _idleRotationSpinupTime;
  109223. /**
  109224. * Sets the flag that indicates if user zooming should stop animation.
  109225. */
  109226. set zoomStopsAnimation(flag: boolean);
  109227. /**
  109228. * Gets the flag that indicates if user zooming should stop animation.
  109229. */
  109230. get zoomStopsAnimation(): boolean;
  109231. /**
  109232. * Sets the default speed at which the camera rotates around the model.
  109233. */
  109234. set idleRotationSpeed(speed: number);
  109235. /**
  109236. * Gets the default speed at which the camera rotates around the model.
  109237. */
  109238. get idleRotationSpeed(): number;
  109239. /**
  109240. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  109241. */
  109242. set idleRotationWaitTime(time: number);
  109243. /**
  109244. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  109245. */
  109246. get idleRotationWaitTime(): number;
  109247. /**
  109248. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109249. */
  109250. set idleRotationSpinupTime(time: number);
  109251. /**
  109252. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109253. */
  109254. get idleRotationSpinupTime(): number;
  109255. /**
  109256. * Gets a value indicating if the camera is currently rotating because of this behavior
  109257. */
  109258. get rotationInProgress(): boolean;
  109259. private _onPrePointerObservableObserver;
  109260. private _onAfterCheckInputsObserver;
  109261. private _attachedCamera;
  109262. private _isPointerDown;
  109263. private _lastFrameTime;
  109264. private _lastInteractionTime;
  109265. private _cameraRotationSpeed;
  109266. /**
  109267. * Initializes the behavior.
  109268. */
  109269. init(): void;
  109270. /**
  109271. * Attaches the behavior to its arc rotate camera.
  109272. * @param camera Defines the camera to attach the behavior to
  109273. */
  109274. attach(camera: ArcRotateCamera): void;
  109275. /**
  109276. * Detaches the behavior from its current arc rotate camera.
  109277. */
  109278. detach(): void;
  109279. /**
  109280. * Returns true if user is scrolling.
  109281. * @return true if user is scrolling.
  109282. */
  109283. private _userIsZooming;
  109284. private _lastFrameRadius;
  109285. private _shouldAnimationStopForInteraction;
  109286. /**
  109287. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109288. */
  109289. private _applyUserInteraction;
  109290. private _userIsMoving;
  109291. }
  109292. }
  109293. declare module BABYLON {
  109294. /**
  109295. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  109296. */
  109297. export class AttachToBoxBehavior implements Behavior<Mesh> {
  109298. private ui;
  109299. /**
  109300. * The name of the behavior
  109301. */
  109302. name: string;
  109303. /**
  109304. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  109305. */
  109306. distanceAwayFromFace: number;
  109307. /**
  109308. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  109309. */
  109310. distanceAwayFromBottomOfFace: number;
  109311. private _faceVectors;
  109312. private _target;
  109313. private _scene;
  109314. private _onRenderObserver;
  109315. private _tmpMatrix;
  109316. private _tmpVector;
  109317. /**
  109318. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  109319. * @param ui The transform node that should be attched to the mesh
  109320. */
  109321. constructor(ui: TransformNode);
  109322. /**
  109323. * Initializes the behavior
  109324. */
  109325. init(): void;
  109326. private _closestFace;
  109327. private _zeroVector;
  109328. private _lookAtTmpMatrix;
  109329. private _lookAtToRef;
  109330. /**
  109331. * Attaches the AttachToBoxBehavior to the passed in mesh
  109332. * @param target The mesh that the specified node will be attached to
  109333. */
  109334. attach(target: Mesh): void;
  109335. /**
  109336. * Detaches the behavior from the mesh
  109337. */
  109338. detach(): void;
  109339. }
  109340. }
  109341. declare module BABYLON {
  109342. /**
  109343. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  109344. */
  109345. export class FadeInOutBehavior implements Behavior<Mesh> {
  109346. /**
  109347. * Time in milliseconds to delay before fading in (Default: 0)
  109348. */
  109349. delay: number;
  109350. /**
  109351. * Time in milliseconds for the mesh to fade in (Default: 300)
  109352. */
  109353. fadeInTime: number;
  109354. private _millisecondsPerFrame;
  109355. private _hovered;
  109356. private _hoverValue;
  109357. private _ownerNode;
  109358. /**
  109359. * Instatiates the FadeInOutBehavior
  109360. */
  109361. constructor();
  109362. /**
  109363. * The name of the behavior
  109364. */
  109365. get name(): string;
  109366. /**
  109367. * Initializes the behavior
  109368. */
  109369. init(): void;
  109370. /**
  109371. * Attaches the fade behavior on the passed in mesh
  109372. * @param ownerNode The mesh that will be faded in/out once attached
  109373. */
  109374. attach(ownerNode: Mesh): void;
  109375. /**
  109376. * Detaches the behavior from the mesh
  109377. */
  109378. detach(): void;
  109379. /**
  109380. * Triggers the mesh to begin fading in or out
  109381. * @param value if the object should fade in or out (true to fade in)
  109382. */
  109383. fadeIn(value: boolean): void;
  109384. private _update;
  109385. private _setAllVisibility;
  109386. }
  109387. }
  109388. declare module BABYLON {
  109389. /**
  109390. * Class containing a set of static utilities functions for managing Pivots
  109391. * @hidden
  109392. */
  109393. export class PivotTools {
  109394. private static _PivotCached;
  109395. private static _OldPivotPoint;
  109396. private static _PivotTranslation;
  109397. private static _PivotTmpVector;
  109398. /** @hidden */
  109399. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  109400. /** @hidden */
  109401. static _RestorePivotPoint(mesh: AbstractMesh): void;
  109402. }
  109403. }
  109404. declare module BABYLON {
  109405. /**
  109406. * Class containing static functions to help procedurally build meshes
  109407. */
  109408. export class PlaneBuilder {
  109409. /**
  109410. * Creates a plane mesh
  109411. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109412. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109413. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109417. * @param name defines the name of the mesh
  109418. * @param options defines the options used to create the mesh
  109419. * @param scene defines the hosting scene
  109420. * @returns the plane mesh
  109421. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109422. */
  109423. static CreatePlane(name: string, options: {
  109424. size?: number;
  109425. width?: number;
  109426. height?: number;
  109427. sideOrientation?: number;
  109428. frontUVs?: Vector4;
  109429. backUVs?: Vector4;
  109430. updatable?: boolean;
  109431. sourcePlane?: Plane;
  109432. }, scene?: Nullable<Scene>): Mesh;
  109433. }
  109434. }
  109435. declare module BABYLON {
  109436. /**
  109437. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  109438. */
  109439. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  109440. private static _AnyMouseID;
  109441. /**
  109442. * Abstract mesh the behavior is set on
  109443. */
  109444. attachedNode: AbstractMesh;
  109445. private _dragPlane;
  109446. private _scene;
  109447. private _pointerObserver;
  109448. private _beforeRenderObserver;
  109449. private static _planeScene;
  109450. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  109451. /**
  109452. * 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)
  109453. */
  109454. maxDragAngle: number;
  109455. /**
  109456. * @hidden
  109457. */
  109458. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  109459. /**
  109460. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109461. */
  109462. currentDraggingPointerID: number;
  109463. /**
  109464. * The last position where the pointer hit the drag plane in world space
  109465. */
  109466. lastDragPosition: Vector3;
  109467. /**
  109468. * If the behavior is currently in a dragging state
  109469. */
  109470. dragging: boolean;
  109471. /**
  109472. * 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)
  109473. */
  109474. dragDeltaRatio: number;
  109475. /**
  109476. * If the drag plane orientation should be updated during the dragging (Default: true)
  109477. */
  109478. updateDragPlane: boolean;
  109479. private _debugMode;
  109480. private _moving;
  109481. /**
  109482. * Fires each time the attached mesh is dragged with the pointer
  109483. * * delta between last drag position and current drag position in world space
  109484. * * dragDistance along the drag axis
  109485. * * dragPlaneNormal normal of the current drag plane used during the drag
  109486. * * dragPlanePoint in world space where the drag intersects the drag plane
  109487. */
  109488. onDragObservable: Observable<{
  109489. delta: Vector3;
  109490. dragPlanePoint: Vector3;
  109491. dragPlaneNormal: Vector3;
  109492. dragDistance: number;
  109493. pointerId: number;
  109494. }>;
  109495. /**
  109496. * Fires each time a drag begins (eg. mouse down on mesh)
  109497. */
  109498. onDragStartObservable: Observable<{
  109499. dragPlanePoint: Vector3;
  109500. pointerId: number;
  109501. }>;
  109502. /**
  109503. * Fires each time a drag ends (eg. mouse release after drag)
  109504. */
  109505. onDragEndObservable: Observable<{
  109506. dragPlanePoint: Vector3;
  109507. pointerId: number;
  109508. }>;
  109509. /**
  109510. * If the attached mesh should be moved when dragged
  109511. */
  109512. moveAttached: boolean;
  109513. /**
  109514. * If the drag behavior will react to drag events (Default: true)
  109515. */
  109516. enabled: boolean;
  109517. /**
  109518. * If pointer events should start and release the drag (Default: true)
  109519. */
  109520. startAndReleaseDragOnPointerEvents: boolean;
  109521. /**
  109522. * If camera controls should be detached during the drag
  109523. */
  109524. detachCameraControls: boolean;
  109525. /**
  109526. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  109527. */
  109528. useObjectOrienationForDragging: boolean;
  109529. private _options;
  109530. /**
  109531. * Gets the options used by the behavior
  109532. */
  109533. get options(): {
  109534. dragAxis?: Vector3;
  109535. dragPlaneNormal?: Vector3;
  109536. };
  109537. /**
  109538. * Sets the options used by the behavior
  109539. */
  109540. set options(options: {
  109541. dragAxis?: Vector3;
  109542. dragPlaneNormal?: Vector3;
  109543. });
  109544. /**
  109545. * Creates a pointer drag behavior that can be attached to a mesh
  109546. * @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)
  109547. */
  109548. constructor(options?: {
  109549. dragAxis?: Vector3;
  109550. dragPlaneNormal?: Vector3;
  109551. });
  109552. /**
  109553. * Predicate to determine if it is valid to move the object to a new position when it is moved
  109554. */
  109555. validateDrag: (targetPosition: Vector3) => boolean;
  109556. /**
  109557. * The name of the behavior
  109558. */
  109559. get name(): string;
  109560. /**
  109561. * Initializes the behavior
  109562. */
  109563. init(): void;
  109564. private _tmpVector;
  109565. private _alternatePickedPoint;
  109566. private _worldDragAxis;
  109567. private _targetPosition;
  109568. private _attachedElement;
  109569. /**
  109570. * Attaches the drag behavior the passed in mesh
  109571. * @param ownerNode The mesh that will be dragged around once attached
  109572. * @param predicate Predicate to use for pick filtering
  109573. */
  109574. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  109575. /**
  109576. * Force relase the drag action by code.
  109577. */
  109578. releaseDrag(): void;
  109579. private _startDragRay;
  109580. private _lastPointerRay;
  109581. /**
  109582. * Simulates the start of a pointer drag event on the behavior
  109583. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  109584. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  109585. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  109586. */
  109587. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  109588. private _startDrag;
  109589. private _dragDelta;
  109590. private _moveDrag;
  109591. private _pickWithRayOnDragPlane;
  109592. private _pointA;
  109593. private _pointB;
  109594. private _pointC;
  109595. private _lineA;
  109596. private _lineB;
  109597. private _localAxis;
  109598. private _lookAt;
  109599. private _updateDragPlanePosition;
  109600. /**
  109601. * Detaches the behavior from the mesh
  109602. */
  109603. detach(): void;
  109604. }
  109605. }
  109606. declare module BABYLON {
  109607. /**
  109608. * A behavior that when attached to a mesh will allow the mesh to be scaled
  109609. */
  109610. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  109611. private _dragBehaviorA;
  109612. private _dragBehaviorB;
  109613. private _startDistance;
  109614. private _initialScale;
  109615. private _targetScale;
  109616. private _ownerNode;
  109617. private _sceneRenderObserver;
  109618. /**
  109619. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  109620. */
  109621. constructor();
  109622. /**
  109623. * The name of the behavior
  109624. */
  109625. get name(): string;
  109626. /**
  109627. * Initializes the behavior
  109628. */
  109629. init(): void;
  109630. private _getCurrentDistance;
  109631. /**
  109632. * Attaches the scale behavior the passed in mesh
  109633. * @param ownerNode The mesh that will be scaled around once attached
  109634. */
  109635. attach(ownerNode: Mesh): void;
  109636. /**
  109637. * Detaches the behavior from the mesh
  109638. */
  109639. detach(): void;
  109640. }
  109641. }
  109642. declare module BABYLON {
  109643. /**
  109644. * 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
  109645. */
  109646. export class SixDofDragBehavior implements Behavior<Mesh> {
  109647. private static _virtualScene;
  109648. private _ownerNode;
  109649. private _sceneRenderObserver;
  109650. private _scene;
  109651. private _targetPosition;
  109652. private _virtualOriginMesh;
  109653. private _virtualDragMesh;
  109654. private _pointerObserver;
  109655. private _moving;
  109656. private _startingOrientation;
  109657. /**
  109658. * 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)
  109659. */
  109660. private zDragFactor;
  109661. /**
  109662. * If the object should rotate to face the drag origin
  109663. */
  109664. rotateDraggedObject: boolean;
  109665. /**
  109666. * If the behavior is currently in a dragging state
  109667. */
  109668. dragging: boolean;
  109669. /**
  109670. * 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)
  109671. */
  109672. dragDeltaRatio: number;
  109673. /**
  109674. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109675. */
  109676. currentDraggingPointerID: number;
  109677. /**
  109678. * If camera controls should be detached during the drag
  109679. */
  109680. detachCameraControls: boolean;
  109681. /**
  109682. * Fires each time a drag starts
  109683. */
  109684. onDragStartObservable: Observable<{}>;
  109685. /**
  109686. * Fires each time a drag ends (eg. mouse release after drag)
  109687. */
  109688. onDragEndObservable: Observable<{}>;
  109689. /**
  109690. * 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
  109691. */
  109692. constructor();
  109693. /**
  109694. * The name of the behavior
  109695. */
  109696. get name(): string;
  109697. /**
  109698. * Initializes the behavior
  109699. */
  109700. init(): void;
  109701. /**
  109702. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  109703. */
  109704. private get _pointerCamera();
  109705. /**
  109706. * Attaches the scale behavior the passed in mesh
  109707. * @param ownerNode The mesh that will be scaled around once attached
  109708. */
  109709. attach(ownerNode: Mesh): void;
  109710. /**
  109711. * Detaches the behavior from the mesh
  109712. */
  109713. detach(): void;
  109714. }
  109715. }
  109716. declare module BABYLON {
  109717. /**
  109718. * Class used to apply inverse kinematics to bones
  109719. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  109720. */
  109721. export class BoneIKController {
  109722. private static _tmpVecs;
  109723. private static _tmpQuat;
  109724. private static _tmpMats;
  109725. /**
  109726. * Gets or sets the target mesh
  109727. */
  109728. targetMesh: AbstractMesh;
  109729. /** Gets or sets the mesh used as pole */
  109730. poleTargetMesh: AbstractMesh;
  109731. /**
  109732. * Gets or sets the bone used as pole
  109733. */
  109734. poleTargetBone: Nullable<Bone>;
  109735. /**
  109736. * Gets or sets the target position
  109737. */
  109738. targetPosition: Vector3;
  109739. /**
  109740. * Gets or sets the pole target position
  109741. */
  109742. poleTargetPosition: Vector3;
  109743. /**
  109744. * Gets or sets the pole target local offset
  109745. */
  109746. poleTargetLocalOffset: Vector3;
  109747. /**
  109748. * Gets or sets the pole angle
  109749. */
  109750. poleAngle: number;
  109751. /**
  109752. * Gets or sets the mesh associated with the controller
  109753. */
  109754. mesh: AbstractMesh;
  109755. /**
  109756. * 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)
  109757. */
  109758. slerpAmount: number;
  109759. private _bone1Quat;
  109760. private _bone1Mat;
  109761. private _bone2Ang;
  109762. private _bone1;
  109763. private _bone2;
  109764. private _bone1Length;
  109765. private _bone2Length;
  109766. private _maxAngle;
  109767. private _maxReach;
  109768. private _rightHandedSystem;
  109769. private _bendAxis;
  109770. private _slerping;
  109771. private _adjustRoll;
  109772. /**
  109773. * Gets or sets maximum allowed angle
  109774. */
  109775. get maxAngle(): number;
  109776. set maxAngle(value: number);
  109777. /**
  109778. * Creates a new BoneIKController
  109779. * @param mesh defines the mesh to control
  109780. * @param bone defines the bone to control
  109781. * @param options defines options to set up the controller
  109782. */
  109783. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  109784. targetMesh?: AbstractMesh;
  109785. poleTargetMesh?: AbstractMesh;
  109786. poleTargetBone?: Bone;
  109787. poleTargetLocalOffset?: Vector3;
  109788. poleAngle?: number;
  109789. bendAxis?: Vector3;
  109790. maxAngle?: number;
  109791. slerpAmount?: number;
  109792. });
  109793. private _setMaxAngle;
  109794. /**
  109795. * Force the controller to update the bones
  109796. */
  109797. update(): void;
  109798. }
  109799. }
  109800. declare module BABYLON {
  109801. /**
  109802. * Class used to make a bone look toward a point in space
  109803. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  109804. */
  109805. export class BoneLookController {
  109806. private static _tmpVecs;
  109807. private static _tmpQuat;
  109808. private static _tmpMats;
  109809. /**
  109810. * The target Vector3 that the bone will look at
  109811. */
  109812. target: Vector3;
  109813. /**
  109814. * The mesh that the bone is attached to
  109815. */
  109816. mesh: AbstractMesh;
  109817. /**
  109818. * The bone that will be looking to the target
  109819. */
  109820. bone: Bone;
  109821. /**
  109822. * The up axis of the coordinate system that is used when the bone is rotated
  109823. */
  109824. upAxis: Vector3;
  109825. /**
  109826. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  109827. */
  109828. upAxisSpace: Space;
  109829. /**
  109830. * Used to make an adjustment to the yaw of the bone
  109831. */
  109832. adjustYaw: number;
  109833. /**
  109834. * Used to make an adjustment to the pitch of the bone
  109835. */
  109836. adjustPitch: number;
  109837. /**
  109838. * Used to make an adjustment to the roll of the bone
  109839. */
  109840. adjustRoll: number;
  109841. /**
  109842. * 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)
  109843. */
  109844. slerpAmount: number;
  109845. private _minYaw;
  109846. private _maxYaw;
  109847. private _minPitch;
  109848. private _maxPitch;
  109849. private _minYawSin;
  109850. private _minYawCos;
  109851. private _maxYawSin;
  109852. private _maxYawCos;
  109853. private _midYawConstraint;
  109854. private _minPitchTan;
  109855. private _maxPitchTan;
  109856. private _boneQuat;
  109857. private _slerping;
  109858. private _transformYawPitch;
  109859. private _transformYawPitchInv;
  109860. private _firstFrameSkipped;
  109861. private _yawRange;
  109862. private _fowardAxis;
  109863. /**
  109864. * Gets or sets the minimum yaw angle that the bone can look to
  109865. */
  109866. get minYaw(): number;
  109867. set minYaw(value: number);
  109868. /**
  109869. * Gets or sets the maximum yaw angle that the bone can look to
  109870. */
  109871. get maxYaw(): number;
  109872. set maxYaw(value: number);
  109873. /**
  109874. * Gets or sets the minimum pitch angle that the bone can look to
  109875. */
  109876. get minPitch(): number;
  109877. set minPitch(value: number);
  109878. /**
  109879. * Gets or sets the maximum pitch angle that the bone can look to
  109880. */
  109881. get maxPitch(): number;
  109882. set maxPitch(value: number);
  109883. /**
  109884. * Create a BoneLookController
  109885. * @param mesh the mesh that the bone belongs to
  109886. * @param bone the bone that will be looking to the target
  109887. * @param target the target Vector3 to look at
  109888. * @param options optional settings:
  109889. * * maxYaw: the maximum angle the bone will yaw to
  109890. * * minYaw: the minimum angle the bone will yaw to
  109891. * * maxPitch: the maximum angle the bone will pitch to
  109892. * * minPitch: the minimum angle the bone will yaw to
  109893. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  109894. * * upAxis: the up axis of the coordinate system
  109895. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  109896. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  109897. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  109898. * * adjustYaw: used to make an adjustment to the yaw of the bone
  109899. * * adjustPitch: used to make an adjustment to the pitch of the bone
  109900. * * adjustRoll: used to make an adjustment to the roll of the bone
  109901. **/
  109902. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  109903. maxYaw?: number;
  109904. minYaw?: number;
  109905. maxPitch?: number;
  109906. minPitch?: number;
  109907. slerpAmount?: number;
  109908. upAxis?: Vector3;
  109909. upAxisSpace?: Space;
  109910. yawAxis?: Vector3;
  109911. pitchAxis?: Vector3;
  109912. adjustYaw?: number;
  109913. adjustPitch?: number;
  109914. adjustRoll?: number;
  109915. });
  109916. /**
  109917. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  109918. */
  109919. update(): void;
  109920. private _getAngleDiff;
  109921. private _getAngleBetween;
  109922. private _isAngleBetween;
  109923. }
  109924. }
  109925. declare module BABYLON {
  109926. /**
  109927. * Manage the gamepad inputs to control an arc rotate camera.
  109928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109929. */
  109930. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  109931. /**
  109932. * Defines the camera the input is attached to.
  109933. */
  109934. camera: ArcRotateCamera;
  109935. /**
  109936. * Defines the gamepad the input is gathering event from.
  109937. */
  109938. gamepad: Nullable<Gamepad>;
  109939. /**
  109940. * Defines the gamepad rotation sensiblity.
  109941. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109942. */
  109943. gamepadRotationSensibility: number;
  109944. /**
  109945. * Defines the gamepad move sensiblity.
  109946. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109947. */
  109948. gamepadMoveSensibility: number;
  109949. private _yAxisScale;
  109950. /**
  109951. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  109952. */
  109953. get invertYAxis(): boolean;
  109954. set invertYAxis(value: boolean);
  109955. private _onGamepadConnectedObserver;
  109956. private _onGamepadDisconnectedObserver;
  109957. /**
  109958. * Attach the input controls to a specific dom element to get the input from.
  109959. * @param element Defines the element the controls should be listened from
  109960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109961. */
  109962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109963. /**
  109964. * Detach the current controls from the specified dom element.
  109965. * @param element Defines the element to stop listening the inputs from
  109966. */
  109967. detachControl(element: Nullable<HTMLElement>): void;
  109968. /**
  109969. * Update the current camera state depending on the inputs that have been used this frame.
  109970. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109971. */
  109972. checkInputs(): void;
  109973. /**
  109974. * Gets the class name of the current intput.
  109975. * @returns the class name
  109976. */
  109977. getClassName(): string;
  109978. /**
  109979. * Get the friendly name associated with the input class.
  109980. * @returns the input friendly name
  109981. */
  109982. getSimpleName(): string;
  109983. }
  109984. }
  109985. declare module BABYLON {
  109986. interface ArcRotateCameraInputsManager {
  109987. /**
  109988. * Add orientation input support to the input manager.
  109989. * @returns the current input manager
  109990. */
  109991. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  109992. }
  109993. /**
  109994. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  109995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109996. */
  109997. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  109998. /**
  109999. * Defines the camera the input is attached to.
  110000. */
  110001. camera: ArcRotateCamera;
  110002. /**
  110003. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  110004. */
  110005. alphaCorrection: number;
  110006. /**
  110007. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  110008. */
  110009. gammaCorrection: number;
  110010. private _alpha;
  110011. private _gamma;
  110012. private _dirty;
  110013. private _deviceOrientationHandler;
  110014. /**
  110015. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  110016. */
  110017. constructor();
  110018. /**
  110019. * Attach the input controls to a specific dom element to get the input from.
  110020. * @param element Defines the element the controls should be listened from
  110021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110022. */
  110023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110024. /** @hidden */
  110025. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  110026. /**
  110027. * Update the current camera state depending on the inputs that have been used this frame.
  110028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110029. */
  110030. checkInputs(): void;
  110031. /**
  110032. * Detach the current controls from the specified dom element.
  110033. * @param element Defines the element to stop listening the inputs from
  110034. */
  110035. detachControl(element: Nullable<HTMLElement>): void;
  110036. /**
  110037. * Gets the class name of the current intput.
  110038. * @returns the class name
  110039. */
  110040. getClassName(): string;
  110041. /**
  110042. * Get the friendly name associated with the input class.
  110043. * @returns the input friendly name
  110044. */
  110045. getSimpleName(): string;
  110046. }
  110047. }
  110048. declare module BABYLON {
  110049. /**
  110050. * Listen to mouse events to control the camera.
  110051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110052. */
  110053. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110054. /**
  110055. * Defines the camera the input is attached to.
  110056. */
  110057. camera: FlyCamera;
  110058. /**
  110059. * Defines if touch is enabled. (Default is true.)
  110060. */
  110061. touchEnabled: boolean;
  110062. /**
  110063. * Defines the buttons associated with the input to handle camera rotation.
  110064. */
  110065. buttons: number[];
  110066. /**
  110067. * Assign buttons for Yaw control.
  110068. */
  110069. buttonsYaw: number[];
  110070. /**
  110071. * Assign buttons for Pitch control.
  110072. */
  110073. buttonsPitch: number[];
  110074. /**
  110075. * Assign buttons for Roll control.
  110076. */
  110077. buttonsRoll: number[];
  110078. /**
  110079. * Detect if any button is being pressed while mouse is moved.
  110080. * -1 = Mouse locked.
  110081. * 0 = Left button.
  110082. * 1 = Middle Button.
  110083. * 2 = Right Button.
  110084. */
  110085. activeButton: number;
  110086. /**
  110087. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110088. * Higher values reduce its sensitivity.
  110089. */
  110090. angularSensibility: number;
  110091. private _mousemoveCallback;
  110092. private _observer;
  110093. private _rollObserver;
  110094. private previousPosition;
  110095. private noPreventDefault;
  110096. private element;
  110097. /**
  110098. * Listen to mouse events to control the camera.
  110099. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110101. */
  110102. constructor(touchEnabled?: boolean);
  110103. /**
  110104. * Attach the mouse control to the HTML DOM element.
  110105. * @param element Defines the element that listens to the input events.
  110106. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110107. */
  110108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110109. /**
  110110. * Detach the current controls from the specified dom element.
  110111. * @param element Defines the element to stop listening the inputs from
  110112. */
  110113. detachControl(element: Nullable<HTMLElement>): void;
  110114. /**
  110115. * Gets the class name of the current input.
  110116. * @returns the class name.
  110117. */
  110118. getClassName(): string;
  110119. /**
  110120. * Get the friendly name associated with the input class.
  110121. * @returns the input's friendly name.
  110122. */
  110123. getSimpleName(): string;
  110124. private _pointerInput;
  110125. private _onMouseMove;
  110126. /**
  110127. * Rotate camera by mouse offset.
  110128. */
  110129. private rotateCamera;
  110130. }
  110131. }
  110132. declare module BABYLON {
  110133. /**
  110134. * Default Inputs manager for the FlyCamera.
  110135. * It groups all the default supported inputs for ease of use.
  110136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110137. */
  110138. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110139. /**
  110140. * Instantiates a new FlyCameraInputsManager.
  110141. * @param camera Defines the camera the inputs belong to.
  110142. */
  110143. constructor(camera: FlyCamera);
  110144. /**
  110145. * Add keyboard input support to the input manager.
  110146. * @returns the new FlyCameraKeyboardMoveInput().
  110147. */
  110148. addKeyboard(): FlyCameraInputsManager;
  110149. /**
  110150. * Add mouse input support to the input manager.
  110151. * @param touchEnabled Enable touch screen support.
  110152. * @returns the new FlyCameraMouseInput().
  110153. */
  110154. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  110155. }
  110156. }
  110157. declare module BABYLON {
  110158. /**
  110159. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110160. * such as in a 3D Space Shooter or a Flight Simulator.
  110161. */
  110162. export class FlyCamera extends TargetCamera {
  110163. /**
  110164. * Define the collision ellipsoid of the camera.
  110165. * This is helpful for simulating a camera body, like a player's body.
  110166. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110167. */
  110168. ellipsoid: Vector3;
  110169. /**
  110170. * Define an offset for the position of the ellipsoid around the camera.
  110171. * This can be helpful if the camera is attached away from the player's body center,
  110172. * such as at its head.
  110173. */
  110174. ellipsoidOffset: Vector3;
  110175. /**
  110176. * Enable or disable collisions of the camera with the rest of the scene objects.
  110177. */
  110178. checkCollisions: boolean;
  110179. /**
  110180. * Enable or disable gravity on the camera.
  110181. */
  110182. applyGravity: boolean;
  110183. /**
  110184. * Define the current direction the camera is moving to.
  110185. */
  110186. cameraDirection: Vector3;
  110187. /**
  110188. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  110189. * This overrides and empties cameraRotation.
  110190. */
  110191. rotationQuaternion: Quaternion;
  110192. /**
  110193. * Track Roll to maintain the wanted Rolling when looking around.
  110194. */
  110195. _trackRoll: number;
  110196. /**
  110197. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  110198. */
  110199. rollCorrect: number;
  110200. /**
  110201. * Mimic a banked turn, Rolling the camera when Yawing.
  110202. * It's recommended to use rollCorrect = 10 for faster banking correction.
  110203. */
  110204. bankedTurn: boolean;
  110205. /**
  110206. * Limit in radians for how much Roll banking will add. (Default: 90°)
  110207. */
  110208. bankedTurnLimit: number;
  110209. /**
  110210. * Value of 0 disables the banked Roll.
  110211. * Value of 1 is equal to the Yaw angle in radians.
  110212. */
  110213. bankedTurnMultiplier: number;
  110214. /**
  110215. * The inputs manager loads all the input sources, such as keyboard and mouse.
  110216. */
  110217. inputs: FlyCameraInputsManager;
  110218. /**
  110219. * Gets the input sensibility for mouse input.
  110220. * Higher values reduce sensitivity.
  110221. */
  110222. get angularSensibility(): number;
  110223. /**
  110224. * Sets the input sensibility for a mouse input.
  110225. * Higher values reduce sensitivity.
  110226. */
  110227. set angularSensibility(value: number);
  110228. /**
  110229. * Get the keys for camera movement forward.
  110230. */
  110231. get keysForward(): number[];
  110232. /**
  110233. * Set the keys for camera movement forward.
  110234. */
  110235. set keysForward(value: number[]);
  110236. /**
  110237. * Get the keys for camera movement backward.
  110238. */
  110239. get keysBackward(): number[];
  110240. set keysBackward(value: number[]);
  110241. /**
  110242. * Get the keys for camera movement up.
  110243. */
  110244. get keysUp(): number[];
  110245. /**
  110246. * Set the keys for camera movement up.
  110247. */
  110248. set keysUp(value: number[]);
  110249. /**
  110250. * Get the keys for camera movement down.
  110251. */
  110252. get keysDown(): number[];
  110253. /**
  110254. * Set the keys for camera movement down.
  110255. */
  110256. set keysDown(value: number[]);
  110257. /**
  110258. * Get the keys for camera movement left.
  110259. */
  110260. get keysLeft(): number[];
  110261. /**
  110262. * Set the keys for camera movement left.
  110263. */
  110264. set keysLeft(value: number[]);
  110265. /**
  110266. * Set the keys for camera movement right.
  110267. */
  110268. get keysRight(): number[];
  110269. /**
  110270. * Set the keys for camera movement right.
  110271. */
  110272. set keysRight(value: number[]);
  110273. /**
  110274. * Event raised when the camera collides with a mesh in the scene.
  110275. */
  110276. onCollide: (collidedMesh: AbstractMesh) => void;
  110277. private _collider;
  110278. private _needMoveForGravity;
  110279. private _oldPosition;
  110280. private _diffPosition;
  110281. private _newPosition;
  110282. /** @hidden */
  110283. _localDirection: Vector3;
  110284. /** @hidden */
  110285. _transformedDirection: Vector3;
  110286. /**
  110287. * Instantiates a FlyCamera.
  110288. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110289. * such as in a 3D Space Shooter or a Flight Simulator.
  110290. * @param name Define the name of the camera in the scene.
  110291. * @param position Define the starting position of the camera in the scene.
  110292. * @param scene Define the scene the camera belongs to.
  110293. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  110294. */
  110295. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110296. /**
  110297. * Attach a control to the HTML DOM element.
  110298. * @param element Defines the element that listens to the input events.
  110299. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  110300. */
  110301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110302. /**
  110303. * Detach a control from the HTML DOM element.
  110304. * The camera will stop reacting to that input.
  110305. * @param element Defines the element that listens to the input events.
  110306. */
  110307. detachControl(element: HTMLElement): void;
  110308. private _collisionMask;
  110309. /**
  110310. * Get the mask that the camera ignores in collision events.
  110311. */
  110312. get collisionMask(): number;
  110313. /**
  110314. * Set the mask that the camera ignores in collision events.
  110315. */
  110316. set collisionMask(mask: number);
  110317. /** @hidden */
  110318. _collideWithWorld(displacement: Vector3): void;
  110319. /** @hidden */
  110320. private _onCollisionPositionChange;
  110321. /** @hidden */
  110322. _checkInputs(): void;
  110323. /** @hidden */
  110324. _decideIfNeedsToMove(): boolean;
  110325. /** @hidden */
  110326. _updatePosition(): void;
  110327. /**
  110328. * Restore the Roll to its target value at the rate specified.
  110329. * @param rate - Higher means slower restoring.
  110330. * @hidden
  110331. */
  110332. restoreRoll(rate: number): void;
  110333. /**
  110334. * Destroy the camera and release the current resources held by it.
  110335. */
  110336. dispose(): void;
  110337. /**
  110338. * Get the current object class name.
  110339. * @returns the class name.
  110340. */
  110341. getClassName(): string;
  110342. }
  110343. }
  110344. declare module BABYLON {
  110345. /**
  110346. * Listen to keyboard events to control the camera.
  110347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110348. */
  110349. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  110350. /**
  110351. * Defines the camera the input is attached to.
  110352. */
  110353. camera: FlyCamera;
  110354. /**
  110355. * The list of keyboard keys used to control the forward move of the camera.
  110356. */
  110357. keysForward: number[];
  110358. /**
  110359. * The list of keyboard keys used to control the backward move of the camera.
  110360. */
  110361. keysBackward: number[];
  110362. /**
  110363. * The list of keyboard keys used to control the forward move of the camera.
  110364. */
  110365. keysUp: number[];
  110366. /**
  110367. * The list of keyboard keys used to control the backward move of the camera.
  110368. */
  110369. keysDown: number[];
  110370. /**
  110371. * The list of keyboard keys used to control the right strafe move of the camera.
  110372. */
  110373. keysRight: number[];
  110374. /**
  110375. * The list of keyboard keys used to control the left strafe move of the camera.
  110376. */
  110377. keysLeft: number[];
  110378. private _keys;
  110379. private _onCanvasBlurObserver;
  110380. private _onKeyboardObserver;
  110381. private _engine;
  110382. private _scene;
  110383. /**
  110384. * Attach the input controls to a specific dom element to get the input from.
  110385. * @param element Defines the element the controls should be listened from
  110386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110387. */
  110388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110389. /**
  110390. * Detach the current controls from the specified dom element.
  110391. * @param element Defines the element to stop listening the inputs from
  110392. */
  110393. detachControl(element: Nullable<HTMLElement>): void;
  110394. /**
  110395. * Gets the class name of the current intput.
  110396. * @returns the class name
  110397. */
  110398. getClassName(): string;
  110399. /** @hidden */
  110400. _onLostFocus(e: FocusEvent): void;
  110401. /**
  110402. * Get the friendly name associated with the input class.
  110403. * @returns the input friendly name
  110404. */
  110405. getSimpleName(): string;
  110406. /**
  110407. * Update the current camera state depending on the inputs that have been used this frame.
  110408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110409. */
  110410. checkInputs(): void;
  110411. }
  110412. }
  110413. declare module BABYLON {
  110414. /**
  110415. * Manage the mouse wheel inputs to control a follow camera.
  110416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110417. */
  110418. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  110419. /**
  110420. * Defines the camera the input is attached to.
  110421. */
  110422. camera: FollowCamera;
  110423. /**
  110424. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  110425. */
  110426. axisControlRadius: boolean;
  110427. /**
  110428. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  110429. */
  110430. axisControlHeight: boolean;
  110431. /**
  110432. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  110433. */
  110434. axisControlRotation: boolean;
  110435. /**
  110436. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  110437. * relation to mouseWheel events.
  110438. */
  110439. wheelPrecision: number;
  110440. /**
  110441. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110442. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110443. */
  110444. wheelDeltaPercentage: number;
  110445. private _wheel;
  110446. private _observer;
  110447. /**
  110448. * Attach the input controls to a specific dom element to get the input from.
  110449. * @param element Defines the element the controls should be listened from
  110450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110451. */
  110452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110453. /**
  110454. * Detach the current controls from the specified dom element.
  110455. * @param element Defines the element to stop listening the inputs from
  110456. */
  110457. detachControl(element: Nullable<HTMLElement>): void;
  110458. /**
  110459. * Gets the class name of the current intput.
  110460. * @returns the class name
  110461. */
  110462. getClassName(): string;
  110463. /**
  110464. * Get the friendly name associated with the input class.
  110465. * @returns the input friendly name
  110466. */
  110467. getSimpleName(): string;
  110468. }
  110469. }
  110470. declare module BABYLON {
  110471. /**
  110472. * Manage the pointers inputs to control an follow camera.
  110473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110474. */
  110475. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  110476. /**
  110477. * Defines the camera the input is attached to.
  110478. */
  110479. camera: FollowCamera;
  110480. /**
  110481. * Gets the class name of the current input.
  110482. * @returns the class name
  110483. */
  110484. getClassName(): string;
  110485. /**
  110486. * Defines the pointer angular sensibility along the X axis or how fast is
  110487. * the camera rotating.
  110488. * A negative number will reverse the axis direction.
  110489. */
  110490. angularSensibilityX: number;
  110491. /**
  110492. * Defines the pointer angular sensibility along the Y axis or how fast is
  110493. * the camera rotating.
  110494. * A negative number will reverse the axis direction.
  110495. */
  110496. angularSensibilityY: number;
  110497. /**
  110498. * Defines the pointer pinch precision or how fast is the camera zooming.
  110499. * A negative number will reverse the axis direction.
  110500. */
  110501. pinchPrecision: number;
  110502. /**
  110503. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110504. * from 0.
  110505. * It defines the percentage of current camera.radius to use as delta when
  110506. * pinch zoom is used.
  110507. */
  110508. pinchDeltaPercentage: number;
  110509. /**
  110510. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  110511. */
  110512. axisXControlRadius: boolean;
  110513. /**
  110514. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  110515. */
  110516. axisXControlHeight: boolean;
  110517. /**
  110518. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  110519. */
  110520. axisXControlRotation: boolean;
  110521. /**
  110522. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  110523. */
  110524. axisYControlRadius: boolean;
  110525. /**
  110526. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  110527. */
  110528. axisYControlHeight: boolean;
  110529. /**
  110530. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  110531. */
  110532. axisYControlRotation: boolean;
  110533. /**
  110534. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  110535. */
  110536. axisPinchControlRadius: boolean;
  110537. /**
  110538. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  110539. */
  110540. axisPinchControlHeight: boolean;
  110541. /**
  110542. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  110543. */
  110544. axisPinchControlRotation: boolean;
  110545. /**
  110546. * Log error messages if basic misconfiguration has occurred.
  110547. */
  110548. warningEnable: boolean;
  110549. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110550. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110551. private _warningCounter;
  110552. private _warning;
  110553. }
  110554. }
  110555. declare module BABYLON {
  110556. /**
  110557. * Default Inputs manager for the FollowCamera.
  110558. * It groups all the default supported inputs for ease of use.
  110559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110560. */
  110561. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  110562. /**
  110563. * Instantiates a new FollowCameraInputsManager.
  110564. * @param camera Defines the camera the inputs belong to
  110565. */
  110566. constructor(camera: FollowCamera);
  110567. /**
  110568. * Add keyboard input support to the input manager.
  110569. * @returns the current input manager
  110570. */
  110571. addKeyboard(): FollowCameraInputsManager;
  110572. /**
  110573. * Add mouse wheel input support to the input manager.
  110574. * @returns the current input manager
  110575. */
  110576. addMouseWheel(): FollowCameraInputsManager;
  110577. /**
  110578. * Add pointers input support to the input manager.
  110579. * @returns the current input manager
  110580. */
  110581. addPointers(): FollowCameraInputsManager;
  110582. /**
  110583. * Add orientation input support to the input manager.
  110584. * @returns the current input manager
  110585. */
  110586. addVRDeviceOrientation(): FollowCameraInputsManager;
  110587. }
  110588. }
  110589. declare module BABYLON {
  110590. /**
  110591. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  110592. * an arc rotate version arcFollowCamera are available.
  110593. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110594. */
  110595. export class FollowCamera extends TargetCamera {
  110596. /**
  110597. * Distance the follow camera should follow an object at
  110598. */
  110599. radius: number;
  110600. /**
  110601. * Minimum allowed distance of the camera to the axis of rotation
  110602. * (The camera can not get closer).
  110603. * This can help limiting how the Camera is able to move in the scene.
  110604. */
  110605. lowerRadiusLimit: Nullable<number>;
  110606. /**
  110607. * Maximum allowed distance of the camera to the axis of rotation
  110608. * (The camera can not get further).
  110609. * This can help limiting how the Camera is able to move in the scene.
  110610. */
  110611. upperRadiusLimit: Nullable<number>;
  110612. /**
  110613. * Define a rotation offset between the camera and the object it follows
  110614. */
  110615. rotationOffset: number;
  110616. /**
  110617. * Minimum allowed angle to camera position relative to target object.
  110618. * This can help limiting how the Camera is able to move in the scene.
  110619. */
  110620. lowerRotationOffsetLimit: Nullable<number>;
  110621. /**
  110622. * Maximum allowed angle to camera position relative to target object.
  110623. * This can help limiting how the Camera is able to move in the scene.
  110624. */
  110625. upperRotationOffsetLimit: Nullable<number>;
  110626. /**
  110627. * Define a height offset between the camera and the object it follows.
  110628. * It can help following an object from the top (like a car chaing a plane)
  110629. */
  110630. heightOffset: number;
  110631. /**
  110632. * Minimum allowed height of camera position relative to target object.
  110633. * This can help limiting how the Camera is able to move in the scene.
  110634. */
  110635. lowerHeightOffsetLimit: Nullable<number>;
  110636. /**
  110637. * Maximum allowed height of camera position relative to target object.
  110638. * This can help limiting how the Camera is able to move in the scene.
  110639. */
  110640. upperHeightOffsetLimit: Nullable<number>;
  110641. /**
  110642. * Define how fast the camera can accelerate to follow it s target.
  110643. */
  110644. cameraAcceleration: number;
  110645. /**
  110646. * Define the speed limit of the camera following an object.
  110647. */
  110648. maxCameraSpeed: number;
  110649. /**
  110650. * Define the target of the camera.
  110651. */
  110652. lockedTarget: Nullable<AbstractMesh>;
  110653. /**
  110654. * Defines the input associated with the camera.
  110655. */
  110656. inputs: FollowCameraInputsManager;
  110657. /**
  110658. * Instantiates the follow camera.
  110659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110660. * @param name Define the name of the camera in the scene
  110661. * @param position Define the position of the camera
  110662. * @param scene Define the scene the camera belong to
  110663. * @param lockedTarget Define the target of the camera
  110664. */
  110665. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  110666. private _follow;
  110667. /**
  110668. * Attached controls to the current camera.
  110669. * @param element Defines the element the controls should be listened from
  110670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110671. */
  110672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110673. /**
  110674. * Detach the current controls from the camera.
  110675. * The camera will stop reacting to inputs.
  110676. * @param element Defines the element to stop listening the inputs from
  110677. */
  110678. detachControl(element: HTMLElement): void;
  110679. /** @hidden */
  110680. _checkInputs(): void;
  110681. private _checkLimits;
  110682. /**
  110683. * Gets the camera class name.
  110684. * @returns the class name
  110685. */
  110686. getClassName(): string;
  110687. }
  110688. /**
  110689. * Arc Rotate version of the follow camera.
  110690. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  110691. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110692. */
  110693. export class ArcFollowCamera extends TargetCamera {
  110694. /** The longitudinal angle of the camera */
  110695. alpha: number;
  110696. /** The latitudinal angle of the camera */
  110697. beta: number;
  110698. /** The radius of the camera from its target */
  110699. radius: number;
  110700. /** Define the camera target (the messh it should follow) */
  110701. target: Nullable<AbstractMesh>;
  110702. private _cartesianCoordinates;
  110703. /**
  110704. * Instantiates a new ArcFollowCamera
  110705. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110706. * @param name Define the name of the camera
  110707. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  110708. * @param beta Define the rotation angle of the camera around the elevation axis
  110709. * @param radius Define the radius of the camera from its target point
  110710. * @param target Define the target of the camera
  110711. * @param scene Define the scene the camera belongs to
  110712. */
  110713. constructor(name: string,
  110714. /** The longitudinal angle of the camera */
  110715. alpha: number,
  110716. /** The latitudinal angle of the camera */
  110717. beta: number,
  110718. /** The radius of the camera from its target */
  110719. radius: number,
  110720. /** Define the camera target (the messh it should follow) */
  110721. target: Nullable<AbstractMesh>, scene: Scene);
  110722. private _follow;
  110723. /** @hidden */
  110724. _checkInputs(): void;
  110725. /**
  110726. * Returns the class name of the object.
  110727. * It is mostly used internally for serialization purposes.
  110728. */
  110729. getClassName(): string;
  110730. }
  110731. }
  110732. declare module BABYLON {
  110733. /**
  110734. * Manage the keyboard inputs to control the movement of a follow camera.
  110735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110736. */
  110737. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  110738. /**
  110739. * Defines the camera the input is attached to.
  110740. */
  110741. camera: FollowCamera;
  110742. /**
  110743. * Defines the list of key codes associated with the up action (increase heightOffset)
  110744. */
  110745. keysHeightOffsetIncr: number[];
  110746. /**
  110747. * Defines the list of key codes associated with the down action (decrease heightOffset)
  110748. */
  110749. keysHeightOffsetDecr: number[];
  110750. /**
  110751. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  110752. */
  110753. keysHeightOffsetModifierAlt: boolean;
  110754. /**
  110755. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  110756. */
  110757. keysHeightOffsetModifierCtrl: boolean;
  110758. /**
  110759. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  110760. */
  110761. keysHeightOffsetModifierShift: boolean;
  110762. /**
  110763. * Defines the list of key codes associated with the left action (increase rotationOffset)
  110764. */
  110765. keysRotationOffsetIncr: number[];
  110766. /**
  110767. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  110768. */
  110769. keysRotationOffsetDecr: number[];
  110770. /**
  110771. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  110772. */
  110773. keysRotationOffsetModifierAlt: boolean;
  110774. /**
  110775. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  110776. */
  110777. keysRotationOffsetModifierCtrl: boolean;
  110778. /**
  110779. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  110780. */
  110781. keysRotationOffsetModifierShift: boolean;
  110782. /**
  110783. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  110784. */
  110785. keysRadiusIncr: number[];
  110786. /**
  110787. * Defines the list of key codes associated with the zoom-out action (increase radius)
  110788. */
  110789. keysRadiusDecr: number[];
  110790. /**
  110791. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  110792. */
  110793. keysRadiusModifierAlt: boolean;
  110794. /**
  110795. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  110796. */
  110797. keysRadiusModifierCtrl: boolean;
  110798. /**
  110799. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  110800. */
  110801. keysRadiusModifierShift: boolean;
  110802. /**
  110803. * Defines the rate of change of heightOffset.
  110804. */
  110805. heightSensibility: number;
  110806. /**
  110807. * Defines the rate of change of rotationOffset.
  110808. */
  110809. rotationSensibility: number;
  110810. /**
  110811. * Defines the rate of change of radius.
  110812. */
  110813. radiusSensibility: number;
  110814. private _keys;
  110815. private _ctrlPressed;
  110816. private _altPressed;
  110817. private _shiftPressed;
  110818. private _onCanvasBlurObserver;
  110819. private _onKeyboardObserver;
  110820. private _engine;
  110821. private _scene;
  110822. /**
  110823. * Attach the input controls to a specific dom element to get the input from.
  110824. * @param element Defines the element the controls should be listened from
  110825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110826. */
  110827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110828. /**
  110829. * Detach the current controls from the specified dom element.
  110830. * @param element Defines the element to stop listening the inputs from
  110831. */
  110832. detachControl(element: Nullable<HTMLElement>): void;
  110833. /**
  110834. * Update the current camera state depending on the inputs that have been used this frame.
  110835. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110836. */
  110837. checkInputs(): void;
  110838. /**
  110839. * Gets the class name of the current input.
  110840. * @returns the class name
  110841. */
  110842. getClassName(): string;
  110843. /**
  110844. * Get the friendly name associated with the input class.
  110845. * @returns the input friendly name
  110846. */
  110847. getSimpleName(): string;
  110848. /**
  110849. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110850. * allow modification of the heightOffset value.
  110851. */
  110852. private _modifierHeightOffset;
  110853. /**
  110854. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110855. * allow modification of the rotationOffset value.
  110856. */
  110857. private _modifierRotationOffset;
  110858. /**
  110859. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110860. * allow modification of the radius value.
  110861. */
  110862. private _modifierRadius;
  110863. }
  110864. }
  110865. declare module BABYLON {
  110866. interface FreeCameraInputsManager {
  110867. /**
  110868. * @hidden
  110869. */
  110870. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  110871. /**
  110872. * Add orientation input support to the input manager.
  110873. * @returns the current input manager
  110874. */
  110875. addDeviceOrientation(): FreeCameraInputsManager;
  110876. }
  110877. /**
  110878. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  110879. * Screen rotation is taken into account.
  110880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110881. */
  110882. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  110883. private _camera;
  110884. private _screenOrientationAngle;
  110885. private _constantTranform;
  110886. private _screenQuaternion;
  110887. private _alpha;
  110888. private _beta;
  110889. private _gamma;
  110890. /**
  110891. * Can be used to detect if a device orientation sensor is available on a device
  110892. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  110893. * @returns a promise that will resolve on orientation change
  110894. */
  110895. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  110896. /**
  110897. * @hidden
  110898. */
  110899. _onDeviceOrientationChangedObservable: Observable<void>;
  110900. /**
  110901. * Instantiates a new input
  110902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110903. */
  110904. constructor();
  110905. /**
  110906. * Define the camera controlled by the input.
  110907. */
  110908. get camera(): FreeCamera;
  110909. set camera(camera: FreeCamera);
  110910. /**
  110911. * Attach the input controls to a specific dom element to get the input from.
  110912. * @param element Defines the element the controls should be listened from
  110913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110914. */
  110915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110916. private _orientationChanged;
  110917. private _deviceOrientation;
  110918. /**
  110919. * Detach the current controls from the specified dom element.
  110920. * @param element Defines the element to stop listening the inputs from
  110921. */
  110922. detachControl(element: Nullable<HTMLElement>): void;
  110923. /**
  110924. * Update the current camera state depending on the inputs that have been used this frame.
  110925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110926. */
  110927. checkInputs(): void;
  110928. /**
  110929. * Gets the class name of the current intput.
  110930. * @returns the class name
  110931. */
  110932. getClassName(): string;
  110933. /**
  110934. * Get the friendly name associated with the input class.
  110935. * @returns the input friendly name
  110936. */
  110937. getSimpleName(): string;
  110938. }
  110939. }
  110940. declare module BABYLON {
  110941. /**
  110942. * Manage the gamepad inputs to control a free camera.
  110943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110944. */
  110945. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  110946. /**
  110947. * Define the camera the input is attached to.
  110948. */
  110949. camera: FreeCamera;
  110950. /**
  110951. * Define the Gamepad controlling the input
  110952. */
  110953. gamepad: Nullable<Gamepad>;
  110954. /**
  110955. * Defines the gamepad rotation sensiblity.
  110956. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110957. */
  110958. gamepadAngularSensibility: number;
  110959. /**
  110960. * Defines the gamepad move sensiblity.
  110961. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110962. */
  110963. gamepadMoveSensibility: number;
  110964. private _yAxisScale;
  110965. /**
  110966. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110967. */
  110968. get invertYAxis(): boolean;
  110969. set invertYAxis(value: boolean);
  110970. private _onGamepadConnectedObserver;
  110971. private _onGamepadDisconnectedObserver;
  110972. private _cameraTransform;
  110973. private _deltaTransform;
  110974. private _vector3;
  110975. private _vector2;
  110976. /**
  110977. * Attach the input controls to a specific dom element to get the input from.
  110978. * @param element Defines the element the controls should be listened from
  110979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110980. */
  110981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110982. /**
  110983. * Detach the current controls from the specified dom element.
  110984. * @param element Defines the element to stop listening the inputs from
  110985. */
  110986. detachControl(element: Nullable<HTMLElement>): void;
  110987. /**
  110988. * Update the current camera state depending on the inputs that have been used this frame.
  110989. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110990. */
  110991. checkInputs(): void;
  110992. /**
  110993. * Gets the class name of the current intput.
  110994. * @returns the class name
  110995. */
  110996. getClassName(): string;
  110997. /**
  110998. * Get the friendly name associated with the input class.
  110999. * @returns the input friendly name
  111000. */
  111001. getSimpleName(): string;
  111002. }
  111003. }
  111004. declare module BABYLON {
  111005. /**
  111006. * Defines the potential axis of a Joystick
  111007. */
  111008. export enum JoystickAxis {
  111009. /** X axis */
  111010. X = 0,
  111011. /** Y axis */
  111012. Y = 1,
  111013. /** Z axis */
  111014. Z = 2
  111015. }
  111016. /**
  111017. * Class used to define virtual joystick (used in touch mode)
  111018. */
  111019. export class VirtualJoystick {
  111020. /**
  111021. * Gets or sets a boolean indicating that left and right values must be inverted
  111022. */
  111023. reverseLeftRight: boolean;
  111024. /**
  111025. * Gets or sets a boolean indicating that up and down values must be inverted
  111026. */
  111027. reverseUpDown: boolean;
  111028. /**
  111029. * Gets the offset value for the position (ie. the change of the position value)
  111030. */
  111031. deltaPosition: Vector3;
  111032. /**
  111033. * Gets a boolean indicating if the virtual joystick was pressed
  111034. */
  111035. pressed: boolean;
  111036. /**
  111037. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111038. */
  111039. static Canvas: Nullable<HTMLCanvasElement>;
  111040. private static _globalJoystickIndex;
  111041. private static vjCanvasContext;
  111042. private static vjCanvasWidth;
  111043. private static vjCanvasHeight;
  111044. private static halfWidth;
  111045. private _action;
  111046. private _axisTargetedByLeftAndRight;
  111047. private _axisTargetedByUpAndDown;
  111048. private _joystickSensibility;
  111049. private _inversedSensibility;
  111050. private _joystickPointerID;
  111051. private _joystickColor;
  111052. private _joystickPointerPos;
  111053. private _joystickPreviousPointerPos;
  111054. private _joystickPointerStartPos;
  111055. private _deltaJoystickVector;
  111056. private _leftJoystick;
  111057. private _touches;
  111058. private _onPointerDownHandlerRef;
  111059. private _onPointerMoveHandlerRef;
  111060. private _onPointerUpHandlerRef;
  111061. private _onResize;
  111062. /**
  111063. * Creates a new virtual joystick
  111064. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111065. */
  111066. constructor(leftJoystick?: boolean);
  111067. /**
  111068. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111069. * @param newJoystickSensibility defines the new sensibility
  111070. */
  111071. setJoystickSensibility(newJoystickSensibility: number): void;
  111072. private _onPointerDown;
  111073. private _onPointerMove;
  111074. private _onPointerUp;
  111075. /**
  111076. * Change the color of the virtual joystick
  111077. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111078. */
  111079. setJoystickColor(newColor: string): void;
  111080. /**
  111081. * Defines a callback to call when the joystick is touched
  111082. * @param action defines the callback
  111083. */
  111084. setActionOnTouch(action: () => any): void;
  111085. /**
  111086. * Defines which axis you'd like to control for left & right
  111087. * @param axis defines the axis to use
  111088. */
  111089. setAxisForLeftRight(axis: JoystickAxis): void;
  111090. /**
  111091. * Defines which axis you'd like to control for up & down
  111092. * @param axis defines the axis to use
  111093. */
  111094. setAxisForUpDown(axis: JoystickAxis): void;
  111095. private _drawVirtualJoystick;
  111096. /**
  111097. * Release internal HTML canvas
  111098. */
  111099. releaseCanvas(): void;
  111100. }
  111101. }
  111102. declare module BABYLON {
  111103. interface FreeCameraInputsManager {
  111104. /**
  111105. * Add virtual joystick input support to the input manager.
  111106. * @returns the current input manager
  111107. */
  111108. addVirtualJoystick(): FreeCameraInputsManager;
  111109. }
  111110. /**
  111111. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111113. */
  111114. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111115. /**
  111116. * Defines the camera the input is attached to.
  111117. */
  111118. camera: FreeCamera;
  111119. private _leftjoystick;
  111120. private _rightjoystick;
  111121. /**
  111122. * Gets the left stick of the virtual joystick.
  111123. * @returns The virtual Joystick
  111124. */
  111125. getLeftJoystick(): VirtualJoystick;
  111126. /**
  111127. * Gets the right stick of the virtual joystick.
  111128. * @returns The virtual Joystick
  111129. */
  111130. getRightJoystick(): VirtualJoystick;
  111131. /**
  111132. * Update the current camera state depending on the inputs that have been used this frame.
  111133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111134. */
  111135. checkInputs(): void;
  111136. /**
  111137. * Attach the input controls to a specific dom element to get the input from.
  111138. * @param element Defines the element the controls should be listened from
  111139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111140. */
  111141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111142. /**
  111143. * Detach the current controls from the specified dom element.
  111144. * @param element Defines the element to stop listening the inputs from
  111145. */
  111146. detachControl(element: Nullable<HTMLElement>): void;
  111147. /**
  111148. * Gets the class name of the current intput.
  111149. * @returns the class name
  111150. */
  111151. getClassName(): string;
  111152. /**
  111153. * Get the friendly name associated with the input class.
  111154. * @returns the input friendly name
  111155. */
  111156. getSimpleName(): string;
  111157. }
  111158. }
  111159. declare module BABYLON {
  111160. /**
  111161. * This represents a FPS type of camera controlled by touch.
  111162. * This is like a universal camera minus the Gamepad controls.
  111163. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111164. */
  111165. export class TouchCamera extends FreeCamera {
  111166. /**
  111167. * Defines the touch sensibility for rotation.
  111168. * The higher the faster.
  111169. */
  111170. get touchAngularSensibility(): number;
  111171. set touchAngularSensibility(value: number);
  111172. /**
  111173. * Defines the touch sensibility for move.
  111174. * The higher the faster.
  111175. */
  111176. get touchMoveSensibility(): number;
  111177. set touchMoveSensibility(value: number);
  111178. /**
  111179. * Instantiates a new touch camera.
  111180. * This represents a FPS type of camera controlled by touch.
  111181. * This is like a universal camera minus the Gamepad controls.
  111182. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111183. * @param name Define the name of the camera in the scene
  111184. * @param position Define the start position of the camera in the scene
  111185. * @param scene Define the scene the camera belongs to
  111186. */
  111187. constructor(name: string, position: Vector3, scene: Scene);
  111188. /**
  111189. * Gets the current object class name.
  111190. * @return the class name
  111191. */
  111192. getClassName(): string;
  111193. /** @hidden */
  111194. _setupInputs(): void;
  111195. }
  111196. }
  111197. declare module BABYLON {
  111198. /**
  111199. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  111200. * being tilted forward or back and left or right.
  111201. */
  111202. export class DeviceOrientationCamera extends FreeCamera {
  111203. private _initialQuaternion;
  111204. private _quaternionCache;
  111205. private _tmpDragQuaternion;
  111206. private _disablePointerInputWhenUsingDeviceOrientation;
  111207. /**
  111208. * Creates a new device orientation camera
  111209. * @param name The name of the camera
  111210. * @param position The start position camera
  111211. * @param scene The scene the camera belongs to
  111212. */
  111213. constructor(name: string, position: Vector3, scene: Scene);
  111214. /**
  111215. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  111216. */
  111217. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  111218. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  111219. private _dragFactor;
  111220. /**
  111221. * Enabled turning on the y axis when the orientation sensor is active
  111222. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  111223. */
  111224. enableHorizontalDragging(dragFactor?: number): void;
  111225. /**
  111226. * Gets the current instance class name ("DeviceOrientationCamera").
  111227. * This helps avoiding instanceof at run time.
  111228. * @returns the class name
  111229. */
  111230. getClassName(): string;
  111231. /**
  111232. * @hidden
  111233. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  111234. */
  111235. _checkInputs(): void;
  111236. /**
  111237. * Reset the camera to its default orientation on the specified axis only.
  111238. * @param axis The axis to reset
  111239. */
  111240. resetToCurrentRotation(axis?: Axis): void;
  111241. }
  111242. }
  111243. declare module BABYLON {
  111244. /**
  111245. * Defines supported buttons for XBox360 compatible gamepads
  111246. */
  111247. export enum Xbox360Button {
  111248. /** A */
  111249. A = 0,
  111250. /** B */
  111251. B = 1,
  111252. /** X */
  111253. X = 2,
  111254. /** Y */
  111255. Y = 3,
  111256. /** Start */
  111257. Start = 4,
  111258. /** Back */
  111259. Back = 5,
  111260. /** Left button */
  111261. LB = 6,
  111262. /** Right button */
  111263. RB = 7,
  111264. /** Left stick */
  111265. LeftStick = 8,
  111266. /** Right stick */
  111267. RightStick = 9
  111268. }
  111269. /** Defines values for XBox360 DPad */
  111270. export enum Xbox360Dpad {
  111271. /** Up */
  111272. Up = 0,
  111273. /** Down */
  111274. Down = 1,
  111275. /** Left */
  111276. Left = 2,
  111277. /** Right */
  111278. Right = 3
  111279. }
  111280. /**
  111281. * Defines a XBox360 gamepad
  111282. */
  111283. export class Xbox360Pad extends Gamepad {
  111284. private _leftTrigger;
  111285. private _rightTrigger;
  111286. private _onlefttriggerchanged;
  111287. private _onrighttriggerchanged;
  111288. private _onbuttondown;
  111289. private _onbuttonup;
  111290. private _ondpaddown;
  111291. private _ondpadup;
  111292. /** Observable raised when a button is pressed */
  111293. onButtonDownObservable: Observable<Xbox360Button>;
  111294. /** Observable raised when a button is released */
  111295. onButtonUpObservable: Observable<Xbox360Button>;
  111296. /** Observable raised when a pad is pressed */
  111297. onPadDownObservable: Observable<Xbox360Dpad>;
  111298. /** Observable raised when a pad is released */
  111299. onPadUpObservable: Observable<Xbox360Dpad>;
  111300. private _buttonA;
  111301. private _buttonB;
  111302. private _buttonX;
  111303. private _buttonY;
  111304. private _buttonBack;
  111305. private _buttonStart;
  111306. private _buttonLB;
  111307. private _buttonRB;
  111308. private _buttonLeftStick;
  111309. private _buttonRightStick;
  111310. private _dPadUp;
  111311. private _dPadDown;
  111312. private _dPadLeft;
  111313. private _dPadRight;
  111314. private _isXboxOnePad;
  111315. /**
  111316. * Creates a new XBox360 gamepad object
  111317. * @param id defines the id of this gamepad
  111318. * @param index defines its index
  111319. * @param gamepad defines the internal HTML gamepad object
  111320. * @param xboxOne defines if it is a XBox One gamepad
  111321. */
  111322. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  111323. /**
  111324. * Defines the callback to call when left trigger is pressed
  111325. * @param callback defines the callback to use
  111326. */
  111327. onlefttriggerchanged(callback: (value: number) => void): void;
  111328. /**
  111329. * Defines the callback to call when right trigger is pressed
  111330. * @param callback defines the callback to use
  111331. */
  111332. onrighttriggerchanged(callback: (value: number) => void): void;
  111333. /**
  111334. * Gets the left trigger value
  111335. */
  111336. get leftTrigger(): number;
  111337. /**
  111338. * Sets the left trigger value
  111339. */
  111340. set leftTrigger(newValue: number);
  111341. /**
  111342. * Gets the right trigger value
  111343. */
  111344. get rightTrigger(): number;
  111345. /**
  111346. * Sets the right trigger value
  111347. */
  111348. set rightTrigger(newValue: number);
  111349. /**
  111350. * Defines the callback to call when a button is pressed
  111351. * @param callback defines the callback to use
  111352. */
  111353. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  111354. /**
  111355. * Defines the callback to call when a button is released
  111356. * @param callback defines the callback to use
  111357. */
  111358. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  111359. /**
  111360. * Defines the callback to call when a pad is pressed
  111361. * @param callback defines the callback to use
  111362. */
  111363. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  111364. /**
  111365. * Defines the callback to call when a pad is released
  111366. * @param callback defines the callback to use
  111367. */
  111368. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  111369. private _setButtonValue;
  111370. private _setDPadValue;
  111371. /**
  111372. * Gets the value of the `A` button
  111373. */
  111374. get buttonA(): number;
  111375. /**
  111376. * Sets the value of the `A` button
  111377. */
  111378. set buttonA(value: number);
  111379. /**
  111380. * Gets the value of the `B` button
  111381. */
  111382. get buttonB(): number;
  111383. /**
  111384. * Sets the value of the `B` button
  111385. */
  111386. set buttonB(value: number);
  111387. /**
  111388. * Gets the value of the `X` button
  111389. */
  111390. get buttonX(): number;
  111391. /**
  111392. * Sets the value of the `X` button
  111393. */
  111394. set buttonX(value: number);
  111395. /**
  111396. * Gets the value of the `Y` button
  111397. */
  111398. get buttonY(): number;
  111399. /**
  111400. * Sets the value of the `Y` button
  111401. */
  111402. set buttonY(value: number);
  111403. /**
  111404. * Gets the value of the `Start` button
  111405. */
  111406. get buttonStart(): number;
  111407. /**
  111408. * Sets the value of the `Start` button
  111409. */
  111410. set buttonStart(value: number);
  111411. /**
  111412. * Gets the value of the `Back` button
  111413. */
  111414. get buttonBack(): number;
  111415. /**
  111416. * Sets the value of the `Back` button
  111417. */
  111418. set buttonBack(value: number);
  111419. /**
  111420. * Gets the value of the `Left` button
  111421. */
  111422. get buttonLB(): number;
  111423. /**
  111424. * Sets the value of the `Left` button
  111425. */
  111426. set buttonLB(value: number);
  111427. /**
  111428. * Gets the value of the `Right` button
  111429. */
  111430. get buttonRB(): number;
  111431. /**
  111432. * Sets the value of the `Right` button
  111433. */
  111434. set buttonRB(value: number);
  111435. /**
  111436. * Gets the value of the Left joystick
  111437. */
  111438. get buttonLeftStick(): number;
  111439. /**
  111440. * Sets the value of the Left joystick
  111441. */
  111442. set buttonLeftStick(value: number);
  111443. /**
  111444. * Gets the value of the Right joystick
  111445. */
  111446. get buttonRightStick(): number;
  111447. /**
  111448. * Sets the value of the Right joystick
  111449. */
  111450. set buttonRightStick(value: number);
  111451. /**
  111452. * Gets the value of D-pad up
  111453. */
  111454. get dPadUp(): number;
  111455. /**
  111456. * Sets the value of D-pad up
  111457. */
  111458. set dPadUp(value: number);
  111459. /**
  111460. * Gets the value of D-pad down
  111461. */
  111462. get dPadDown(): number;
  111463. /**
  111464. * Sets the value of D-pad down
  111465. */
  111466. set dPadDown(value: number);
  111467. /**
  111468. * Gets the value of D-pad left
  111469. */
  111470. get dPadLeft(): number;
  111471. /**
  111472. * Sets the value of D-pad left
  111473. */
  111474. set dPadLeft(value: number);
  111475. /**
  111476. * Gets the value of D-pad right
  111477. */
  111478. get dPadRight(): number;
  111479. /**
  111480. * Sets the value of D-pad right
  111481. */
  111482. set dPadRight(value: number);
  111483. /**
  111484. * Force the gamepad to synchronize with device values
  111485. */
  111486. update(): void;
  111487. /**
  111488. * Disposes the gamepad
  111489. */
  111490. dispose(): void;
  111491. }
  111492. }
  111493. declare module BABYLON {
  111494. /**
  111495. * Defines supported buttons for DualShock compatible gamepads
  111496. */
  111497. export enum DualShockButton {
  111498. /** Cross */
  111499. Cross = 0,
  111500. /** Circle */
  111501. Circle = 1,
  111502. /** Square */
  111503. Square = 2,
  111504. /** Triangle */
  111505. Triangle = 3,
  111506. /** Options */
  111507. Options = 4,
  111508. /** Share */
  111509. Share = 5,
  111510. /** L1 */
  111511. L1 = 6,
  111512. /** R1 */
  111513. R1 = 7,
  111514. /** Left stick */
  111515. LeftStick = 8,
  111516. /** Right stick */
  111517. RightStick = 9
  111518. }
  111519. /** Defines values for DualShock DPad */
  111520. export enum DualShockDpad {
  111521. /** Up */
  111522. Up = 0,
  111523. /** Down */
  111524. Down = 1,
  111525. /** Left */
  111526. Left = 2,
  111527. /** Right */
  111528. Right = 3
  111529. }
  111530. /**
  111531. * Defines a DualShock gamepad
  111532. */
  111533. export class DualShockPad extends Gamepad {
  111534. private _leftTrigger;
  111535. private _rightTrigger;
  111536. private _onlefttriggerchanged;
  111537. private _onrighttriggerchanged;
  111538. private _onbuttondown;
  111539. private _onbuttonup;
  111540. private _ondpaddown;
  111541. private _ondpadup;
  111542. /** Observable raised when a button is pressed */
  111543. onButtonDownObservable: Observable<DualShockButton>;
  111544. /** Observable raised when a button is released */
  111545. onButtonUpObservable: Observable<DualShockButton>;
  111546. /** Observable raised when a pad is pressed */
  111547. onPadDownObservable: Observable<DualShockDpad>;
  111548. /** Observable raised when a pad is released */
  111549. onPadUpObservable: Observable<DualShockDpad>;
  111550. private _buttonCross;
  111551. private _buttonCircle;
  111552. private _buttonSquare;
  111553. private _buttonTriangle;
  111554. private _buttonShare;
  111555. private _buttonOptions;
  111556. private _buttonL1;
  111557. private _buttonR1;
  111558. private _buttonLeftStick;
  111559. private _buttonRightStick;
  111560. private _dPadUp;
  111561. private _dPadDown;
  111562. private _dPadLeft;
  111563. private _dPadRight;
  111564. /**
  111565. * Creates a new DualShock gamepad object
  111566. * @param id defines the id of this gamepad
  111567. * @param index defines its index
  111568. * @param gamepad defines the internal HTML gamepad object
  111569. */
  111570. constructor(id: string, index: number, gamepad: any);
  111571. /**
  111572. * Defines the callback to call when left trigger is pressed
  111573. * @param callback defines the callback to use
  111574. */
  111575. onlefttriggerchanged(callback: (value: number) => void): void;
  111576. /**
  111577. * Defines the callback to call when right trigger is pressed
  111578. * @param callback defines the callback to use
  111579. */
  111580. onrighttriggerchanged(callback: (value: number) => void): void;
  111581. /**
  111582. * Gets the left trigger value
  111583. */
  111584. get leftTrigger(): number;
  111585. /**
  111586. * Sets the left trigger value
  111587. */
  111588. set leftTrigger(newValue: number);
  111589. /**
  111590. * Gets the right trigger value
  111591. */
  111592. get rightTrigger(): number;
  111593. /**
  111594. * Sets the right trigger value
  111595. */
  111596. set rightTrigger(newValue: number);
  111597. /**
  111598. * Defines the callback to call when a button is pressed
  111599. * @param callback defines the callback to use
  111600. */
  111601. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  111602. /**
  111603. * Defines the callback to call when a button is released
  111604. * @param callback defines the callback to use
  111605. */
  111606. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  111607. /**
  111608. * Defines the callback to call when a pad is pressed
  111609. * @param callback defines the callback to use
  111610. */
  111611. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  111612. /**
  111613. * Defines the callback to call when a pad is released
  111614. * @param callback defines the callback to use
  111615. */
  111616. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  111617. private _setButtonValue;
  111618. private _setDPadValue;
  111619. /**
  111620. * Gets the value of the `Cross` button
  111621. */
  111622. get buttonCross(): number;
  111623. /**
  111624. * Sets the value of the `Cross` button
  111625. */
  111626. set buttonCross(value: number);
  111627. /**
  111628. * Gets the value of the `Circle` button
  111629. */
  111630. get buttonCircle(): number;
  111631. /**
  111632. * Sets the value of the `Circle` button
  111633. */
  111634. set buttonCircle(value: number);
  111635. /**
  111636. * Gets the value of the `Square` button
  111637. */
  111638. get buttonSquare(): number;
  111639. /**
  111640. * Sets the value of the `Square` button
  111641. */
  111642. set buttonSquare(value: number);
  111643. /**
  111644. * Gets the value of the `Triangle` button
  111645. */
  111646. get buttonTriangle(): number;
  111647. /**
  111648. * Sets the value of the `Triangle` button
  111649. */
  111650. set buttonTriangle(value: number);
  111651. /**
  111652. * Gets the value of the `Options` button
  111653. */
  111654. get buttonOptions(): number;
  111655. /**
  111656. * Sets the value of the `Options` button
  111657. */
  111658. set buttonOptions(value: number);
  111659. /**
  111660. * Gets the value of the `Share` button
  111661. */
  111662. get buttonShare(): number;
  111663. /**
  111664. * Sets the value of the `Share` button
  111665. */
  111666. set buttonShare(value: number);
  111667. /**
  111668. * Gets the value of the `L1` button
  111669. */
  111670. get buttonL1(): number;
  111671. /**
  111672. * Sets the value of the `L1` button
  111673. */
  111674. set buttonL1(value: number);
  111675. /**
  111676. * Gets the value of the `R1` button
  111677. */
  111678. get buttonR1(): number;
  111679. /**
  111680. * Sets the value of the `R1` button
  111681. */
  111682. set buttonR1(value: number);
  111683. /**
  111684. * Gets the value of the Left joystick
  111685. */
  111686. get buttonLeftStick(): number;
  111687. /**
  111688. * Sets the value of the Left joystick
  111689. */
  111690. set buttonLeftStick(value: number);
  111691. /**
  111692. * Gets the value of the Right joystick
  111693. */
  111694. get buttonRightStick(): number;
  111695. /**
  111696. * Sets the value of the Right joystick
  111697. */
  111698. set buttonRightStick(value: number);
  111699. /**
  111700. * Gets the value of D-pad up
  111701. */
  111702. get dPadUp(): number;
  111703. /**
  111704. * Sets the value of D-pad up
  111705. */
  111706. set dPadUp(value: number);
  111707. /**
  111708. * Gets the value of D-pad down
  111709. */
  111710. get dPadDown(): number;
  111711. /**
  111712. * Sets the value of D-pad down
  111713. */
  111714. set dPadDown(value: number);
  111715. /**
  111716. * Gets the value of D-pad left
  111717. */
  111718. get dPadLeft(): number;
  111719. /**
  111720. * Sets the value of D-pad left
  111721. */
  111722. set dPadLeft(value: number);
  111723. /**
  111724. * Gets the value of D-pad right
  111725. */
  111726. get dPadRight(): number;
  111727. /**
  111728. * Sets the value of D-pad right
  111729. */
  111730. set dPadRight(value: number);
  111731. /**
  111732. * Force the gamepad to synchronize with device values
  111733. */
  111734. update(): void;
  111735. /**
  111736. * Disposes the gamepad
  111737. */
  111738. dispose(): void;
  111739. }
  111740. }
  111741. declare module BABYLON {
  111742. /**
  111743. * Manager for handling gamepads
  111744. */
  111745. export class GamepadManager {
  111746. private _scene?;
  111747. private _babylonGamepads;
  111748. private _oneGamepadConnected;
  111749. /** @hidden */
  111750. _isMonitoring: boolean;
  111751. private _gamepadEventSupported;
  111752. private _gamepadSupport?;
  111753. /**
  111754. * observable to be triggered when the gamepad controller has been connected
  111755. */
  111756. onGamepadConnectedObservable: Observable<Gamepad>;
  111757. /**
  111758. * observable to be triggered when the gamepad controller has been disconnected
  111759. */
  111760. onGamepadDisconnectedObservable: Observable<Gamepad>;
  111761. private _onGamepadConnectedEvent;
  111762. private _onGamepadDisconnectedEvent;
  111763. /**
  111764. * Initializes the gamepad manager
  111765. * @param _scene BabylonJS scene
  111766. */
  111767. constructor(_scene?: Scene | undefined);
  111768. /**
  111769. * The gamepads in the game pad manager
  111770. */
  111771. get gamepads(): Gamepad[];
  111772. /**
  111773. * Get the gamepad controllers based on type
  111774. * @param type The type of gamepad controller
  111775. * @returns Nullable gamepad
  111776. */
  111777. getGamepadByType(type?: number): Nullable<Gamepad>;
  111778. /**
  111779. * Disposes the gamepad manager
  111780. */
  111781. dispose(): void;
  111782. private _addNewGamepad;
  111783. private _startMonitoringGamepads;
  111784. private _stopMonitoringGamepads;
  111785. /** @hidden */
  111786. _checkGamepadsStatus(): void;
  111787. private _updateGamepadObjects;
  111788. }
  111789. }
  111790. declare module BABYLON {
  111791. interface Scene {
  111792. /** @hidden */
  111793. _gamepadManager: Nullable<GamepadManager>;
  111794. /**
  111795. * Gets the gamepad manager associated with the scene
  111796. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  111797. */
  111798. gamepadManager: GamepadManager;
  111799. }
  111800. /**
  111801. * Interface representing a free camera inputs manager
  111802. */
  111803. interface FreeCameraInputsManager {
  111804. /**
  111805. * Adds gamepad input support to the FreeCameraInputsManager.
  111806. * @returns the FreeCameraInputsManager
  111807. */
  111808. addGamepad(): FreeCameraInputsManager;
  111809. }
  111810. /**
  111811. * Interface representing an arc rotate camera inputs manager
  111812. */
  111813. interface ArcRotateCameraInputsManager {
  111814. /**
  111815. * Adds gamepad input support to the ArcRotateCamera InputManager.
  111816. * @returns the camera inputs manager
  111817. */
  111818. addGamepad(): ArcRotateCameraInputsManager;
  111819. }
  111820. /**
  111821. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  111822. */
  111823. export class GamepadSystemSceneComponent implements ISceneComponent {
  111824. /**
  111825. * The component name helpfull to identify the component in the list of scene components.
  111826. */
  111827. readonly name: string;
  111828. /**
  111829. * The scene the component belongs to.
  111830. */
  111831. scene: Scene;
  111832. /**
  111833. * Creates a new instance of the component for the given scene
  111834. * @param scene Defines the scene to register the component in
  111835. */
  111836. constructor(scene: Scene);
  111837. /**
  111838. * Registers the component in a given scene
  111839. */
  111840. register(): void;
  111841. /**
  111842. * Rebuilds the elements related to this component in case of
  111843. * context lost for instance.
  111844. */
  111845. rebuild(): void;
  111846. /**
  111847. * Disposes the component and the associated ressources
  111848. */
  111849. dispose(): void;
  111850. private _beforeCameraUpdate;
  111851. }
  111852. }
  111853. declare module BABYLON {
  111854. /**
  111855. * 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,
  111856. * which still works and will still be found in many Playgrounds.
  111857. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111858. */
  111859. export class UniversalCamera extends TouchCamera {
  111860. /**
  111861. * Defines the gamepad rotation sensiblity.
  111862. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111863. */
  111864. get gamepadAngularSensibility(): number;
  111865. set gamepadAngularSensibility(value: number);
  111866. /**
  111867. * Defines the gamepad move sensiblity.
  111868. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111869. */
  111870. get gamepadMoveSensibility(): number;
  111871. set gamepadMoveSensibility(value: number);
  111872. /**
  111873. * 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,
  111874. * which still works and will still be found in many Playgrounds.
  111875. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111876. * @param name Define the name of the camera in the scene
  111877. * @param position Define the start position of the camera in the scene
  111878. * @param scene Define the scene the camera belongs to
  111879. */
  111880. constructor(name: string, position: Vector3, scene: Scene);
  111881. /**
  111882. * Gets the current object class name.
  111883. * @return the class name
  111884. */
  111885. getClassName(): string;
  111886. }
  111887. }
  111888. declare module BABYLON {
  111889. /**
  111890. * This represents a FPS type of camera. This is only here for back compat purpose.
  111891. * Please use the UniversalCamera instead as both are identical.
  111892. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111893. */
  111894. export class GamepadCamera extends UniversalCamera {
  111895. /**
  111896. * Instantiates a new Gamepad Camera
  111897. * This represents a FPS type of camera. This is only here for back compat purpose.
  111898. * Please use the UniversalCamera instead as both are identical.
  111899. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111900. * @param name Define the name of the camera in the scene
  111901. * @param position Define the start position of the camera in the scene
  111902. * @param scene Define the scene the camera belongs to
  111903. */
  111904. constructor(name: string, position: Vector3, scene: Scene);
  111905. /**
  111906. * Gets the current object class name.
  111907. * @return the class name
  111908. */
  111909. getClassName(): string;
  111910. }
  111911. }
  111912. declare module BABYLON {
  111913. /** @hidden */
  111914. export var passPixelShader: {
  111915. name: string;
  111916. shader: string;
  111917. };
  111918. }
  111919. declare module BABYLON {
  111920. /** @hidden */
  111921. export var passCubePixelShader: {
  111922. name: string;
  111923. shader: string;
  111924. };
  111925. }
  111926. declare module BABYLON {
  111927. /**
  111928. * PassPostProcess which produces an output the same as it's input
  111929. */
  111930. export class PassPostProcess extends PostProcess {
  111931. /**
  111932. * Creates the PassPostProcess
  111933. * @param name The name of the effect.
  111934. * @param options The required width/height ratio to downsize to before computing the render pass.
  111935. * @param camera The camera to apply the render pass to.
  111936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111937. * @param engine The engine which the post process will be applied. (default: current engine)
  111938. * @param reusable If the post process can be reused on the same frame. (default: false)
  111939. * @param textureType The type of texture to be used when performing the post processing.
  111940. * @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)
  111941. */
  111942. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111943. }
  111944. /**
  111945. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  111946. */
  111947. export class PassCubePostProcess extends PostProcess {
  111948. private _face;
  111949. /**
  111950. * Gets or sets the cube face to display.
  111951. * * 0 is +X
  111952. * * 1 is -X
  111953. * * 2 is +Y
  111954. * * 3 is -Y
  111955. * * 4 is +Z
  111956. * * 5 is -Z
  111957. */
  111958. get face(): number;
  111959. set face(value: number);
  111960. /**
  111961. * Creates the PassCubePostProcess
  111962. * @param name The name of the effect.
  111963. * @param options The required width/height ratio to downsize to before computing the render pass.
  111964. * @param camera The camera to apply the render pass to.
  111965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111966. * @param engine The engine which the post process will be applied. (default: current engine)
  111967. * @param reusable If the post process can be reused on the same frame. (default: false)
  111968. * @param textureType The type of texture to be used when performing the post processing.
  111969. * @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)
  111970. */
  111971. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111972. }
  111973. }
  111974. declare module BABYLON {
  111975. /** @hidden */
  111976. export var anaglyphPixelShader: {
  111977. name: string;
  111978. shader: string;
  111979. };
  111980. }
  111981. declare module BABYLON {
  111982. /**
  111983. * Postprocess used to generate anaglyphic rendering
  111984. */
  111985. export class AnaglyphPostProcess extends PostProcess {
  111986. private _passedProcess;
  111987. /**
  111988. * Creates a new AnaglyphPostProcess
  111989. * @param name defines postprocess name
  111990. * @param options defines creation options or target ratio scale
  111991. * @param rigCameras defines cameras using this postprocess
  111992. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  111993. * @param engine defines hosting engine
  111994. * @param reusable defines if the postprocess will be reused multiple times per frame
  111995. */
  111996. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  111997. }
  111998. }
  111999. declare module BABYLON {
  112000. /**
  112001. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  112002. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112003. */
  112004. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  112005. /**
  112006. * Creates a new AnaglyphArcRotateCamera
  112007. * @param name defines camera name
  112008. * @param alpha defines alpha angle (in radians)
  112009. * @param beta defines beta angle (in radians)
  112010. * @param radius defines radius
  112011. * @param target defines camera target
  112012. * @param interaxialDistance defines distance between each color axis
  112013. * @param scene defines the hosting scene
  112014. */
  112015. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  112016. /**
  112017. * Gets camera class name
  112018. * @returns AnaglyphArcRotateCamera
  112019. */
  112020. getClassName(): string;
  112021. }
  112022. }
  112023. declare module BABYLON {
  112024. /**
  112025. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  112026. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112027. */
  112028. export class AnaglyphFreeCamera extends FreeCamera {
  112029. /**
  112030. * Creates a new AnaglyphFreeCamera
  112031. * @param name defines camera name
  112032. * @param position defines initial position
  112033. * @param interaxialDistance defines distance between each color axis
  112034. * @param scene defines the hosting scene
  112035. */
  112036. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112037. /**
  112038. * Gets camera class name
  112039. * @returns AnaglyphFreeCamera
  112040. */
  112041. getClassName(): string;
  112042. }
  112043. }
  112044. declare module BABYLON {
  112045. /**
  112046. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112047. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112048. */
  112049. export class AnaglyphGamepadCamera extends GamepadCamera {
  112050. /**
  112051. * Creates a new AnaglyphGamepadCamera
  112052. * @param name defines camera name
  112053. * @param position defines initial position
  112054. * @param interaxialDistance defines distance between each color axis
  112055. * @param scene defines the hosting scene
  112056. */
  112057. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112058. /**
  112059. * Gets camera class name
  112060. * @returns AnaglyphGamepadCamera
  112061. */
  112062. getClassName(): string;
  112063. }
  112064. }
  112065. declare module BABYLON {
  112066. /**
  112067. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112068. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112069. */
  112070. export class AnaglyphUniversalCamera extends UniversalCamera {
  112071. /**
  112072. * Creates a new AnaglyphUniversalCamera
  112073. * @param name defines camera name
  112074. * @param position defines initial position
  112075. * @param interaxialDistance defines distance between each color axis
  112076. * @param scene defines the hosting scene
  112077. */
  112078. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112079. /**
  112080. * Gets camera class name
  112081. * @returns AnaglyphUniversalCamera
  112082. */
  112083. getClassName(): string;
  112084. }
  112085. }
  112086. declare module BABYLON {
  112087. /** @hidden */
  112088. export var stereoscopicInterlacePixelShader: {
  112089. name: string;
  112090. shader: string;
  112091. };
  112092. }
  112093. declare module BABYLON {
  112094. /**
  112095. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112096. */
  112097. export class StereoscopicInterlacePostProcess extends PostProcess {
  112098. private _stepSize;
  112099. private _passedProcess;
  112100. /**
  112101. * Initializes a StereoscopicInterlacePostProcess
  112102. * @param name The name of the effect.
  112103. * @param rigCameras The rig cameras to be appled to the post process
  112104. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112106. * @param engine The engine which the post process will be applied. (default: current engine)
  112107. * @param reusable If the post process can be reused on the same frame. (default: false)
  112108. */
  112109. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112110. }
  112111. }
  112112. declare module BABYLON {
  112113. /**
  112114. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112115. * @see http://doc.babylonjs.com/features/cameras
  112116. */
  112117. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112118. /**
  112119. * Creates a new StereoscopicArcRotateCamera
  112120. * @param name defines camera name
  112121. * @param alpha defines alpha angle (in radians)
  112122. * @param beta defines beta angle (in radians)
  112123. * @param radius defines radius
  112124. * @param target defines camera target
  112125. * @param interaxialDistance defines distance between each color axis
  112126. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112127. * @param scene defines the hosting scene
  112128. */
  112129. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112130. /**
  112131. * Gets camera class name
  112132. * @returns StereoscopicArcRotateCamera
  112133. */
  112134. getClassName(): string;
  112135. }
  112136. }
  112137. declare module BABYLON {
  112138. /**
  112139. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112140. * @see http://doc.babylonjs.com/features/cameras
  112141. */
  112142. export class StereoscopicFreeCamera extends FreeCamera {
  112143. /**
  112144. * Creates a new StereoscopicFreeCamera
  112145. * @param name defines camera name
  112146. * @param position defines initial position
  112147. * @param interaxialDistance defines distance between each color axis
  112148. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112149. * @param scene defines the hosting scene
  112150. */
  112151. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112152. /**
  112153. * Gets camera class name
  112154. * @returns StereoscopicFreeCamera
  112155. */
  112156. getClassName(): string;
  112157. }
  112158. }
  112159. declare module BABYLON {
  112160. /**
  112161. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  112162. * @see http://doc.babylonjs.com/features/cameras
  112163. */
  112164. export class StereoscopicGamepadCamera extends GamepadCamera {
  112165. /**
  112166. * Creates a new StereoscopicGamepadCamera
  112167. * @param name defines camera name
  112168. * @param position defines initial position
  112169. * @param interaxialDistance defines distance between each color axis
  112170. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112171. * @param scene defines the hosting scene
  112172. */
  112173. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112174. /**
  112175. * Gets camera class name
  112176. * @returns StereoscopicGamepadCamera
  112177. */
  112178. getClassName(): string;
  112179. }
  112180. }
  112181. declare module BABYLON {
  112182. /**
  112183. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  112184. * @see http://doc.babylonjs.com/features/cameras
  112185. */
  112186. export class StereoscopicUniversalCamera extends UniversalCamera {
  112187. /**
  112188. * Creates a new StereoscopicUniversalCamera
  112189. * @param name defines camera name
  112190. * @param position defines initial position
  112191. * @param interaxialDistance defines distance between each color axis
  112192. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112193. * @param scene defines the hosting scene
  112194. */
  112195. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112196. /**
  112197. * Gets camera class name
  112198. * @returns StereoscopicUniversalCamera
  112199. */
  112200. getClassName(): string;
  112201. }
  112202. }
  112203. declare module BABYLON {
  112204. /**
  112205. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  112206. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112207. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112208. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112209. */
  112210. export class VirtualJoysticksCamera extends FreeCamera {
  112211. /**
  112212. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  112213. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112214. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112215. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112216. * @param name Define the name of the camera in the scene
  112217. * @param position Define the start position of the camera in the scene
  112218. * @param scene Define the scene the camera belongs to
  112219. */
  112220. constructor(name: string, position: Vector3, scene: Scene);
  112221. /**
  112222. * Gets the current object class name.
  112223. * @return the class name
  112224. */
  112225. getClassName(): string;
  112226. }
  112227. }
  112228. declare module BABYLON {
  112229. /**
  112230. * This represents all the required metrics to create a VR camera.
  112231. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  112232. */
  112233. export class VRCameraMetrics {
  112234. /**
  112235. * Define the horizontal resolution off the screen.
  112236. */
  112237. hResolution: number;
  112238. /**
  112239. * Define the vertical resolution off the screen.
  112240. */
  112241. vResolution: number;
  112242. /**
  112243. * Define the horizontal screen size.
  112244. */
  112245. hScreenSize: number;
  112246. /**
  112247. * Define the vertical screen size.
  112248. */
  112249. vScreenSize: number;
  112250. /**
  112251. * Define the vertical screen center position.
  112252. */
  112253. vScreenCenter: number;
  112254. /**
  112255. * Define the distance of the eyes to the screen.
  112256. */
  112257. eyeToScreenDistance: number;
  112258. /**
  112259. * Define the distance between both lenses
  112260. */
  112261. lensSeparationDistance: number;
  112262. /**
  112263. * Define the distance between both viewer's eyes.
  112264. */
  112265. interpupillaryDistance: number;
  112266. /**
  112267. * Define the distortion factor of the VR postprocess.
  112268. * Please, touch with care.
  112269. */
  112270. distortionK: number[];
  112271. /**
  112272. * Define the chromatic aberration correction factors for the VR post process.
  112273. */
  112274. chromaAbCorrection: number[];
  112275. /**
  112276. * Define the scale factor of the post process.
  112277. * The smaller the better but the slower.
  112278. */
  112279. postProcessScaleFactor: number;
  112280. /**
  112281. * Define an offset for the lens center.
  112282. */
  112283. lensCenterOffset: number;
  112284. /**
  112285. * Define if the current vr camera should compensate the distortion of the lense or not.
  112286. */
  112287. compensateDistortion: boolean;
  112288. /**
  112289. * Defines if multiview should be enabled when rendering (Default: false)
  112290. */
  112291. multiviewEnabled: boolean;
  112292. /**
  112293. * Gets the rendering aspect ratio based on the provided resolutions.
  112294. */
  112295. get aspectRatio(): number;
  112296. /**
  112297. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  112298. */
  112299. get aspectRatioFov(): number;
  112300. /**
  112301. * @hidden
  112302. */
  112303. get leftHMatrix(): Matrix;
  112304. /**
  112305. * @hidden
  112306. */
  112307. get rightHMatrix(): Matrix;
  112308. /**
  112309. * @hidden
  112310. */
  112311. get leftPreViewMatrix(): Matrix;
  112312. /**
  112313. * @hidden
  112314. */
  112315. get rightPreViewMatrix(): Matrix;
  112316. /**
  112317. * Get the default VRMetrics based on the most generic setup.
  112318. * @returns the default vr metrics
  112319. */
  112320. static GetDefault(): VRCameraMetrics;
  112321. }
  112322. }
  112323. declare module BABYLON {
  112324. /** @hidden */
  112325. export var vrDistortionCorrectionPixelShader: {
  112326. name: string;
  112327. shader: string;
  112328. };
  112329. }
  112330. declare module BABYLON {
  112331. /**
  112332. * VRDistortionCorrectionPostProcess used for mobile VR
  112333. */
  112334. export class VRDistortionCorrectionPostProcess extends PostProcess {
  112335. private _isRightEye;
  112336. private _distortionFactors;
  112337. private _postProcessScaleFactor;
  112338. private _lensCenterOffset;
  112339. private _scaleIn;
  112340. private _scaleFactor;
  112341. private _lensCenter;
  112342. /**
  112343. * Initializes the VRDistortionCorrectionPostProcess
  112344. * @param name The name of the effect.
  112345. * @param camera The camera to apply the render pass to.
  112346. * @param isRightEye If this is for the right eye distortion
  112347. * @param vrMetrics All the required metrics for the VR camera
  112348. */
  112349. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  112350. }
  112351. }
  112352. declare module BABYLON {
  112353. /**
  112354. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  112355. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112356. */
  112357. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  112358. /**
  112359. * Creates a new VRDeviceOrientationArcRotateCamera
  112360. * @param name defines camera name
  112361. * @param alpha defines the camera rotation along the logitudinal axis
  112362. * @param beta defines the camera rotation along the latitudinal axis
  112363. * @param radius defines the camera distance from its target
  112364. * @param target defines the camera target
  112365. * @param scene defines the scene the camera belongs to
  112366. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112367. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112368. */
  112369. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112370. /**
  112371. * Gets camera class name
  112372. * @returns VRDeviceOrientationArcRotateCamera
  112373. */
  112374. getClassName(): string;
  112375. }
  112376. }
  112377. declare module BABYLON {
  112378. /**
  112379. * Camera used to simulate VR rendering (based on FreeCamera)
  112380. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112381. */
  112382. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  112383. /**
  112384. * Creates a new VRDeviceOrientationFreeCamera
  112385. * @param name defines camera name
  112386. * @param position defines the start position of the camera
  112387. * @param scene defines the scene the camera belongs to
  112388. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112389. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112390. */
  112391. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112392. /**
  112393. * Gets camera class name
  112394. * @returns VRDeviceOrientationFreeCamera
  112395. */
  112396. getClassName(): string;
  112397. }
  112398. }
  112399. declare module BABYLON {
  112400. /**
  112401. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  112402. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112403. */
  112404. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  112405. /**
  112406. * Creates a new VRDeviceOrientationGamepadCamera
  112407. * @param name defines camera name
  112408. * @param position defines the start position of the camera
  112409. * @param scene defines the scene the camera belongs to
  112410. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112411. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112412. */
  112413. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112414. /**
  112415. * Gets camera class name
  112416. * @returns VRDeviceOrientationGamepadCamera
  112417. */
  112418. getClassName(): string;
  112419. }
  112420. }
  112421. declare module BABYLON {
  112422. /** @hidden */
  112423. export var imageProcessingPixelShader: {
  112424. name: string;
  112425. shader: string;
  112426. };
  112427. }
  112428. declare module BABYLON {
  112429. /**
  112430. * ImageProcessingPostProcess
  112431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  112432. */
  112433. export class ImageProcessingPostProcess extends PostProcess {
  112434. /**
  112435. * Default configuration related to image processing available in the PBR Material.
  112436. */
  112437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112438. /**
  112439. * Gets the image processing configuration used either in this material.
  112440. */
  112441. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  112442. /**
  112443. * Sets the Default image processing configuration used either in the this material.
  112444. *
  112445. * If sets to null, the scene one is in use.
  112446. */
  112447. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  112448. /**
  112449. * Keep track of the image processing observer to allow dispose and replace.
  112450. */
  112451. private _imageProcessingObserver;
  112452. /**
  112453. * Attaches a new image processing configuration to the PBR Material.
  112454. * @param configuration
  112455. */
  112456. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  112457. /**
  112458. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112459. */
  112460. get colorCurves(): Nullable<ColorCurves>;
  112461. /**
  112462. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112463. */
  112464. set colorCurves(value: Nullable<ColorCurves>);
  112465. /**
  112466. * Gets wether the color curves effect is enabled.
  112467. */
  112468. get colorCurvesEnabled(): boolean;
  112469. /**
  112470. * Sets wether the color curves effect is enabled.
  112471. */
  112472. set colorCurvesEnabled(value: boolean);
  112473. /**
  112474. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112475. */
  112476. get colorGradingTexture(): Nullable<BaseTexture>;
  112477. /**
  112478. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112479. */
  112480. set colorGradingTexture(value: Nullable<BaseTexture>);
  112481. /**
  112482. * Gets wether the color grading effect is enabled.
  112483. */
  112484. get colorGradingEnabled(): boolean;
  112485. /**
  112486. * Gets wether the color grading effect is enabled.
  112487. */
  112488. set colorGradingEnabled(value: boolean);
  112489. /**
  112490. * Gets exposure used in the effect.
  112491. */
  112492. get exposure(): number;
  112493. /**
  112494. * Sets exposure used in the effect.
  112495. */
  112496. set exposure(value: number);
  112497. /**
  112498. * Gets wether tonemapping is enabled or not.
  112499. */
  112500. get toneMappingEnabled(): boolean;
  112501. /**
  112502. * Sets wether tonemapping is enabled or not
  112503. */
  112504. set toneMappingEnabled(value: boolean);
  112505. /**
  112506. * Gets the type of tone mapping effect.
  112507. */
  112508. get toneMappingType(): number;
  112509. /**
  112510. * Sets the type of tone mapping effect.
  112511. */
  112512. set toneMappingType(value: number);
  112513. /**
  112514. * Gets contrast used in the effect.
  112515. */
  112516. get contrast(): number;
  112517. /**
  112518. * Sets contrast used in the effect.
  112519. */
  112520. set contrast(value: number);
  112521. /**
  112522. * Gets Vignette stretch size.
  112523. */
  112524. get vignetteStretch(): number;
  112525. /**
  112526. * Sets Vignette stretch size.
  112527. */
  112528. set vignetteStretch(value: number);
  112529. /**
  112530. * Gets Vignette centre X Offset.
  112531. */
  112532. get vignetteCentreX(): number;
  112533. /**
  112534. * Sets Vignette centre X Offset.
  112535. */
  112536. set vignetteCentreX(value: number);
  112537. /**
  112538. * Gets Vignette centre Y Offset.
  112539. */
  112540. get vignetteCentreY(): number;
  112541. /**
  112542. * Sets Vignette centre Y Offset.
  112543. */
  112544. set vignetteCentreY(value: number);
  112545. /**
  112546. * Gets Vignette weight or intensity of the vignette effect.
  112547. */
  112548. get vignetteWeight(): number;
  112549. /**
  112550. * Sets Vignette weight or intensity of the vignette effect.
  112551. */
  112552. set vignetteWeight(value: number);
  112553. /**
  112554. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112555. * if vignetteEnabled is set to true.
  112556. */
  112557. get vignetteColor(): Color4;
  112558. /**
  112559. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112560. * if vignetteEnabled is set to true.
  112561. */
  112562. set vignetteColor(value: Color4);
  112563. /**
  112564. * Gets Camera field of view used by the Vignette effect.
  112565. */
  112566. get vignetteCameraFov(): number;
  112567. /**
  112568. * Sets Camera field of view used by the Vignette effect.
  112569. */
  112570. set vignetteCameraFov(value: number);
  112571. /**
  112572. * Gets the vignette blend mode allowing different kind of effect.
  112573. */
  112574. get vignetteBlendMode(): number;
  112575. /**
  112576. * Sets the vignette blend mode allowing different kind of effect.
  112577. */
  112578. set vignetteBlendMode(value: number);
  112579. /**
  112580. * Gets wether the vignette effect is enabled.
  112581. */
  112582. get vignetteEnabled(): boolean;
  112583. /**
  112584. * Sets wether the vignette effect is enabled.
  112585. */
  112586. set vignetteEnabled(value: boolean);
  112587. private _fromLinearSpace;
  112588. /**
  112589. * Gets wether the input of the processing is in Gamma or Linear Space.
  112590. */
  112591. get fromLinearSpace(): boolean;
  112592. /**
  112593. * Sets wether the input of the processing is in Gamma or Linear Space.
  112594. */
  112595. set fromLinearSpace(value: boolean);
  112596. /**
  112597. * Defines cache preventing GC.
  112598. */
  112599. private _defines;
  112600. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  112601. /**
  112602. * "ImageProcessingPostProcess"
  112603. * @returns "ImageProcessingPostProcess"
  112604. */
  112605. getClassName(): string;
  112606. protected _updateParameters(): void;
  112607. dispose(camera?: Camera): void;
  112608. }
  112609. }
  112610. declare module BABYLON {
  112611. /**
  112612. * Class containing static functions to help procedurally build meshes
  112613. */
  112614. export class GroundBuilder {
  112615. /**
  112616. * Creates a ground mesh
  112617. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  112618. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  112619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112620. * @param name defines the name of the mesh
  112621. * @param options defines the options used to create the mesh
  112622. * @param scene defines the hosting scene
  112623. * @returns the ground mesh
  112624. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  112625. */
  112626. static CreateGround(name: string, options: {
  112627. width?: number;
  112628. height?: number;
  112629. subdivisions?: number;
  112630. subdivisionsX?: number;
  112631. subdivisionsY?: number;
  112632. updatable?: boolean;
  112633. }, scene: any): Mesh;
  112634. /**
  112635. * Creates a tiled ground mesh
  112636. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  112637. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  112638. * * 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
  112639. * * 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
  112640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112641. * @param name defines the name of the mesh
  112642. * @param options defines the options used to create the mesh
  112643. * @param scene defines the hosting scene
  112644. * @returns the tiled ground mesh
  112645. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  112646. */
  112647. static CreateTiledGround(name: string, options: {
  112648. xmin: number;
  112649. zmin: number;
  112650. xmax: number;
  112651. zmax: number;
  112652. subdivisions?: {
  112653. w: number;
  112654. h: number;
  112655. };
  112656. precision?: {
  112657. w: number;
  112658. h: number;
  112659. };
  112660. updatable?: boolean;
  112661. }, scene?: Nullable<Scene>): Mesh;
  112662. /**
  112663. * Creates a ground mesh from a height map
  112664. * * The parameter `url` sets the URL of the height map image resource.
  112665. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  112666. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  112667. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  112668. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  112669. * * 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.
  112670. * * 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).
  112671. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  112672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112673. * @param name defines the name of the mesh
  112674. * @param url defines the url to the height map
  112675. * @param options defines the options used to create the mesh
  112676. * @param scene defines the hosting scene
  112677. * @returns the ground mesh
  112678. * @see https://doc.babylonjs.com/babylon101/height_map
  112679. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  112680. */
  112681. static CreateGroundFromHeightMap(name: string, url: string, options: {
  112682. width?: number;
  112683. height?: number;
  112684. subdivisions?: number;
  112685. minHeight?: number;
  112686. maxHeight?: number;
  112687. colorFilter?: Color3;
  112688. alphaFilter?: number;
  112689. updatable?: boolean;
  112690. onReady?: (mesh: GroundMesh) => void;
  112691. }, scene?: Nullable<Scene>): GroundMesh;
  112692. }
  112693. }
  112694. declare module BABYLON {
  112695. /**
  112696. * Class containing static functions to help procedurally build meshes
  112697. */
  112698. export class TorusBuilder {
  112699. /**
  112700. * Creates a torus mesh
  112701. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  112702. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  112703. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  112704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112707. * @param name defines the name of the mesh
  112708. * @param options defines the options used to create the mesh
  112709. * @param scene defines the hosting scene
  112710. * @returns the torus mesh
  112711. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  112712. */
  112713. static CreateTorus(name: string, options: {
  112714. diameter?: number;
  112715. thickness?: number;
  112716. tessellation?: number;
  112717. updatable?: boolean;
  112718. sideOrientation?: number;
  112719. frontUVs?: Vector4;
  112720. backUVs?: Vector4;
  112721. }, scene: any): Mesh;
  112722. }
  112723. }
  112724. declare module BABYLON {
  112725. /**
  112726. * Class containing static functions to help procedurally build meshes
  112727. */
  112728. export class CylinderBuilder {
  112729. /**
  112730. * Creates a cylinder or a cone mesh
  112731. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  112732. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  112733. * * 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.
  112734. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  112735. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  112736. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  112737. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  112738. * * 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).
  112739. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  112740. * * 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).
  112741. * * 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
  112742. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  112743. * * 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
  112744. * * 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.
  112745. * * If `enclose` is false, a ring surface is one element.
  112746. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  112747. * * 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
  112748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112751. * @param name defines the name of the mesh
  112752. * @param options defines the options used to create the mesh
  112753. * @param scene defines the hosting scene
  112754. * @returns the cylinder mesh
  112755. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  112756. */
  112757. static CreateCylinder(name: string, options: {
  112758. height?: number;
  112759. diameterTop?: number;
  112760. diameterBottom?: number;
  112761. diameter?: number;
  112762. tessellation?: number;
  112763. subdivisions?: number;
  112764. arc?: number;
  112765. faceColors?: Color4[];
  112766. faceUV?: Vector4[];
  112767. updatable?: boolean;
  112768. hasRings?: boolean;
  112769. enclose?: boolean;
  112770. cap?: number;
  112771. sideOrientation?: number;
  112772. frontUVs?: Vector4;
  112773. backUVs?: Vector4;
  112774. }, scene: any): Mesh;
  112775. }
  112776. }
  112777. declare module BABYLON {
  112778. /**
  112779. * States of the webXR experience
  112780. */
  112781. export enum WebXRState {
  112782. /**
  112783. * Transitioning to being in XR mode
  112784. */
  112785. ENTERING_XR = 0,
  112786. /**
  112787. * Transitioning to non XR mode
  112788. */
  112789. EXITING_XR = 1,
  112790. /**
  112791. * In XR mode and presenting
  112792. */
  112793. IN_XR = 2,
  112794. /**
  112795. * Not entered XR mode
  112796. */
  112797. NOT_IN_XR = 3
  112798. }
  112799. /**
  112800. * Abstraction of the XR render target
  112801. */
  112802. export interface WebXRRenderTarget extends IDisposable {
  112803. /**
  112804. * xrpresent context of the canvas which can be used to display/mirror xr content
  112805. */
  112806. canvasContext: WebGLRenderingContext;
  112807. /**
  112808. * xr layer for the canvas
  112809. */
  112810. xrLayer: Nullable<XRWebGLLayer>;
  112811. /**
  112812. * Initializes the xr layer for the session
  112813. * @param xrSession xr session
  112814. * @returns a promise that will resolve once the XR Layer has been created
  112815. */
  112816. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  112817. }
  112818. }
  112819. declare module BABYLON {
  112820. /**
  112821. * COnfiguration object for WebXR output canvas
  112822. */
  112823. export class WebXRManagedOutputCanvasOptions {
  112824. /**
  112825. * Options for this XR Layer output
  112826. */
  112827. canvasOptions: XRWebGLLayerOptions;
  112828. /**
  112829. * CSS styling for a newly created canvas (if not provided)
  112830. */
  112831. newCanvasCssStyle?: string;
  112832. /**
  112833. * Get the default values of the configuration object
  112834. * @returns default values of this configuration object
  112835. */
  112836. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  112837. }
  112838. /**
  112839. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  112840. */
  112841. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  112842. private configuration;
  112843. private _engine;
  112844. private _canvas;
  112845. /**
  112846. * xrpresent context of the canvas which can be used to display/mirror xr content
  112847. */
  112848. canvasContext: WebGLRenderingContext;
  112849. /**
  112850. * xr layer for the canvas
  112851. */
  112852. xrLayer: Nullable<XRWebGLLayer>;
  112853. /**
  112854. * Initializes the xr layer for the session
  112855. * @param xrSession xr session
  112856. * @returns a promise that will resolve once the XR Layer has been created
  112857. */
  112858. initializeXRLayerAsync(xrSession: any): any;
  112859. /**
  112860. * Initializes the canvas to be added/removed upon entering/exiting xr
  112861. * @param engine the Babylon engine
  112862. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  112863. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  112864. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  112865. */
  112866. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  112867. /**
  112868. * Disposes of the object
  112869. */
  112870. dispose(): void;
  112871. private _setManagedOutputCanvas;
  112872. private _addCanvas;
  112873. private _removeCanvas;
  112874. }
  112875. }
  112876. declare module BABYLON {
  112877. /**
  112878. * Manages an XRSession to work with Babylon's engine
  112879. * @see https://doc.babylonjs.com/how_to/webxr
  112880. */
  112881. export class WebXRSessionManager implements IDisposable {
  112882. /** The scene which the session should be created for */
  112883. scene: Scene;
  112884. /**
  112885. * Fires every time a new xrFrame arrives which can be used to update the camera
  112886. */
  112887. onXRFrameObservable: Observable<XRFrame>;
  112888. /**
  112889. * Fires when the xr session is ended either by the device or manually done
  112890. */
  112891. onXRSessionEnded: Observable<any>;
  112892. /**
  112893. * Fires when the xr session is ended either by the device or manually done
  112894. */
  112895. onXRSessionInit: Observable<XRSession>;
  112896. /**
  112897. * Underlying xr session
  112898. */
  112899. session: XRSession;
  112900. /**
  112901. * Type of reference space used when creating the session
  112902. */
  112903. referenceSpace: XRReferenceSpace;
  112904. /**
  112905. * Current XR frame
  112906. */
  112907. currentFrame: Nullable<XRFrame>;
  112908. /** WebXR timestamp updated every frame */
  112909. currentTimestamp: number;
  112910. private _xrNavigator;
  112911. private baseLayer;
  112912. private _rttProvider;
  112913. private _sessionEnded;
  112914. /**
  112915. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  112916. * @param scene The scene which the session should be created for
  112917. */
  112918. constructor(
  112919. /** The scene which the session should be created for */
  112920. scene: Scene);
  112921. /**
  112922. * Initializes the manager
  112923. * After initialization enterXR can be called to start an XR session
  112924. * @returns Promise which resolves after it is initialized
  112925. */
  112926. initializeAsync(): Promise<void>;
  112927. /**
  112928. * Initializes an xr session
  112929. * @param xrSessionMode mode to initialize
  112930. * @param optionalFeatures defines optional values to pass to the session builder
  112931. * @returns a promise which will resolve once the session has been initialized
  112932. */
  112933. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  112934. /**
  112935. * Sets the reference space on the xr session
  112936. * @param referenceSpace space to set
  112937. * @returns a promise that will resolve once the reference space has been set
  112938. */
  112939. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  112940. /**
  112941. * Updates the render state of the session
  112942. * @param state state to set
  112943. * @returns a promise that resolves once the render state has been updated
  112944. */
  112945. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  112946. /**
  112947. * Starts rendering to the xr layer
  112948. * @returns a promise that will resolve once rendering has started
  112949. */
  112950. startRenderingToXRAsync(): Promise<void>;
  112951. /**
  112952. * Gets the correct render target texture to be rendered this frame for this eye
  112953. * @param eye the eye for which to get the render target
  112954. * @returns the render target for the specified eye
  112955. */
  112956. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  112957. /**
  112958. * Stops the xrSession and restores the renderloop
  112959. * @returns Promise which resolves after it exits XR
  112960. */
  112961. exitXRAsync(): Promise<void>;
  112962. /**
  112963. * Checks if a session would be supported for the creation options specified
  112964. * @param sessionMode session mode to check if supported eg. immersive-vr
  112965. * @returns true if supported
  112966. */
  112967. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  112968. /**
  112969. * Creates a WebXRRenderTarget object for the XR session
  112970. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  112971. * @param options optional options to provide when creating a new render target
  112972. * @returns a WebXR render target to which the session can render
  112973. */
  112974. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  112975. /**
  112976. * @hidden
  112977. * Converts the render layer of xrSession to a render target
  112978. * @param session session to create render target for
  112979. * @param scene scene the new render target should be created for
  112980. * @param baseLayer the webgl layer to create the render target for
  112981. */
  112982. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  112983. /**
  112984. * Disposes of the session manager
  112985. */
  112986. dispose(): void;
  112987. /**
  112988. * Gets a promise returning true when fullfiled if the given session mode is supported
  112989. * @param sessionMode defines the session to test
  112990. * @returns a promise
  112991. */
  112992. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  112993. }
  112994. }
  112995. declare module BABYLON {
  112996. /**
  112997. * WebXR Camera which holds the views for the xrSession
  112998. * @see https://doc.babylonjs.com/how_to/webxr
  112999. */
  113000. export class WebXRCamera extends FreeCamera {
  113001. /**
  113002. * Is the camera in debug mode. Used when using an emulator
  113003. */
  113004. debugMode: boolean;
  113005. /**
  113006. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  113007. * @param name the name of the camera
  113008. * @param scene the scene to add the camera to
  113009. */
  113010. constructor(name: string, scene: Scene);
  113011. private _updateNumberOfRigCameras;
  113012. /** @hidden */
  113013. _updateForDualEyeDebugging(): void;
  113014. /**
  113015. * Updates the cameras position from the current pose information of the XR session
  113016. * @param xrSessionManager the session containing pose information
  113017. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  113018. */
  113019. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  113020. }
  113021. }
  113022. declare module BABYLON {
  113023. /**
  113024. * Defining the interface required for a (webxr) feature
  113025. */
  113026. export interface IWebXRFeature extends IDisposable {
  113027. /**
  113028. * Attach the feature to the session
  113029. * Will usually be called by the features manager
  113030. *
  113031. * @returns true if successful.
  113032. */
  113033. attach(): boolean;
  113034. /**
  113035. * Detach the feature from the session
  113036. * Will usually be called by the features manager
  113037. *
  113038. * @returns true if successful.
  113039. */
  113040. detach(): boolean;
  113041. }
  113042. /**
  113043. * Defining the constructor of a feature. Used to register the modules.
  113044. */
  113045. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113046. /**
  113047. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113048. * It is mainly used in AR sessions.
  113049. *
  113050. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113051. */
  113052. export class WebXRFeaturesManager implements IDisposable {
  113053. private _xrSessionManager;
  113054. private static readonly _AvailableFeatures;
  113055. /**
  113056. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113057. * Mainly used internally.
  113058. *
  113059. * @param featureName the name of the feature to register
  113060. * @param constructorFunction the function used to construct the module
  113061. * @param version the (babylon) version of the module
  113062. * @param stable is that a stable version of this module
  113063. */
  113064. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113065. /**
  113066. * Returns a constructor of a specific feature.
  113067. *
  113068. * @param featureName the name of the feature to construct
  113069. * @param version the version of the feature to load
  113070. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113071. * @param options optional options provided to the module.
  113072. * @returns a function that, when called, will return a new instance of this feature
  113073. */
  113074. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113075. /**
  113076. * Return the latest unstable version of this feature
  113077. * @param featureName the name of the feature to search
  113078. * @returns the version number. if not found will return -1
  113079. */
  113080. static GetLatestVersionOfFeature(featureName: string): number;
  113081. /**
  113082. * Return the latest stable version of this feature
  113083. * @param featureName the name of the feature to search
  113084. * @returns the version number. if not found will return -1
  113085. */
  113086. static GetStableVersionOfFeature(featureName: string): number;
  113087. /**
  113088. * Can be used to return the list of features currently registered
  113089. *
  113090. * @returns an Array of available features
  113091. */
  113092. static GetAvailableFeatures(): string[];
  113093. /**
  113094. * Gets the versions available for a specific feature
  113095. * @param featureName the name of the feature
  113096. * @returns an array with the available versions
  113097. */
  113098. static GetAvailableVersions(featureName: string): string[];
  113099. private _features;
  113100. /**
  113101. * constructs a new features manages.
  113102. *
  113103. * @param _xrSessionManager an instance of WebXRSessionManager
  113104. */
  113105. constructor(_xrSessionManager: WebXRSessionManager);
  113106. /**
  113107. * 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.
  113108. *
  113109. * @param featureName the name of the feature to load or the class of the feature
  113110. * @param version optional version to load. if not provided the latest version will be enabled
  113111. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113112. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113113. * @returns a new constructed feature or throws an error if feature not found.
  113114. */
  113115. enableFeature(featureName: string | {
  113116. Name: string;
  113117. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113118. /**
  113119. * Used to disable an already-enabled feature
  113120. * @param featureName the feature to disable
  113121. * @returns true if disable was successful
  113122. */
  113123. disableFeature(featureName: string | {
  113124. Name: string;
  113125. }): boolean;
  113126. /**
  113127. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  113128. * Can be used during a session to start a feature
  113129. * @param featureName the name of feature to attach
  113130. */
  113131. attachFeature(featureName: string): void;
  113132. /**
  113133. * Can be used inside a session or when the session ends to detach a specific feature
  113134. * @param featureName the name of the feature to detach
  113135. */
  113136. detachFeature(featureName: string): void;
  113137. /**
  113138. * Get the list of enabled features
  113139. * @returns an array of enabled features
  113140. */
  113141. getEnabledFeatures(): string[];
  113142. /**
  113143. * get the implementation of an enabled feature.
  113144. * @param featureName the name of the feature to load
  113145. * @returns the feature class, if found
  113146. */
  113147. getEnabledFeature(featureName: string): IWebXRFeature;
  113148. /**
  113149. * dispose this features manager
  113150. */
  113151. dispose(): void;
  113152. }
  113153. }
  113154. declare module BABYLON {
  113155. /**
  113156. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  113157. * @see https://doc.babylonjs.com/how_to/webxr
  113158. */
  113159. export class WebXRExperienceHelper implements IDisposable {
  113160. private scene;
  113161. /**
  113162. * 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
  113163. */
  113164. container: AbstractMesh;
  113165. /**
  113166. * Camera used to render xr content
  113167. */
  113168. camera: WebXRCamera;
  113169. /**
  113170. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  113171. */
  113172. state: WebXRState;
  113173. private _setState;
  113174. private static _TmpVector;
  113175. /**
  113176. * Fires when the state of the experience helper has changed
  113177. */
  113178. onStateChangedObservable: Observable<WebXRState>;
  113179. /** Session manager used to keep track of xr session */
  113180. sessionManager: WebXRSessionManager;
  113181. /** A features manager for this xr session */
  113182. featuresManager: WebXRFeaturesManager;
  113183. private _nonVRCamera;
  113184. private _originalSceneAutoClear;
  113185. private _supported;
  113186. /**
  113187. * Creates the experience helper
  113188. * @param scene the scene to attach the experience helper to
  113189. * @returns a promise for the experience helper
  113190. */
  113191. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  113192. /**
  113193. * Creates a WebXRExperienceHelper
  113194. * @param scene The scene the helper should be created in
  113195. */
  113196. private constructor();
  113197. /**
  113198. * Exits XR mode and returns the scene to its original state
  113199. * @returns promise that resolves after xr mode has exited
  113200. */
  113201. exitXRAsync(): Promise<void>;
  113202. /**
  113203. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  113204. * @param sessionMode options for the XR session
  113205. * @param referenceSpaceType frame of reference of the XR session
  113206. * @param renderTarget the output canvas that will be used to enter XR mode
  113207. * @returns promise that resolves after xr mode has entered
  113208. */
  113209. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  113210. /**
  113211. * Updates the global position of the camera by moving the camera's container
  113212. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  113213. * @param position The desired global position of the camera
  113214. */
  113215. setPositionOfCameraUsingContainer(position: Vector3): void;
  113216. /**
  113217. * Rotates the xr camera by rotating the camera's container around the camera's position
  113218. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  113219. * @param rotation the desired quaternion rotation to apply to the camera
  113220. */
  113221. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  113222. /**
  113223. * Disposes of the experience helper
  113224. */
  113225. dispose(): void;
  113226. }
  113227. }
  113228. declare module BABYLON {
  113229. /**
  113230. * Represents an XR input
  113231. */
  113232. export class WebXRController {
  113233. private scene;
  113234. /** The underlying input source for the controller */
  113235. inputSource: XRInputSource;
  113236. private parentContainer;
  113237. /**
  113238. * 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
  113239. */
  113240. grip?: AbstractMesh;
  113241. /**
  113242. * Pointer which can be used to select objects or attach a visible laser to
  113243. */
  113244. pointer: AbstractMesh;
  113245. private _gamepadMode;
  113246. /**
  113247. * If available, this is the gamepad object related to this controller.
  113248. * Using this object it is possible to get click events and trackpad changes of the
  113249. * webxr controller that is currently being used.
  113250. */
  113251. gamepadController?: WebVRController;
  113252. /**
  113253. * Event that fires when the controller is removed/disposed
  113254. */
  113255. onDisposeObservable: Observable<{}>;
  113256. private _tmpQuaternion;
  113257. private _tmpVector;
  113258. /**
  113259. * Creates the controller
  113260. * @see https://doc.babylonjs.com/how_to/webxr
  113261. * @param scene the scene which the controller should be associated to
  113262. * @param inputSource the underlying input source for the controller
  113263. * @param parentContainer parent that the controller meshes should be children of
  113264. */
  113265. constructor(scene: Scene,
  113266. /** The underlying input source for the controller */
  113267. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  113268. /**
  113269. * Updates the controller pose based on the given XRFrame
  113270. * @param xrFrame xr frame to update the pose with
  113271. * @param referenceSpace reference space to use
  113272. */
  113273. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  113274. /**
  113275. * Gets a world space ray coming from the controller
  113276. * @param result the resulting ray
  113277. */
  113278. getWorldPointerRayToRef(result: Ray): void;
  113279. /**
  113280. * Get the scene associated with this controller
  113281. * @returns the scene object
  113282. */
  113283. getScene(): Scene;
  113284. /**
  113285. * Disposes of the object
  113286. */
  113287. dispose(): void;
  113288. }
  113289. }
  113290. declare module BABYLON {
  113291. /**
  113292. * XR input used to track XR inputs such as controllers/rays
  113293. */
  113294. export class WebXRInput implements IDisposable {
  113295. /**
  113296. * Base experience the input listens to
  113297. */
  113298. baseExperience: WebXRExperienceHelper;
  113299. /**
  113300. * XR controllers being tracked
  113301. */
  113302. controllers: Array<WebXRController>;
  113303. private _frameObserver;
  113304. private _stateObserver;
  113305. /**
  113306. * Event when a controller has been connected/added
  113307. */
  113308. onControllerAddedObservable: Observable<WebXRController>;
  113309. /**
  113310. * Event when a controller has been removed/disconnected
  113311. */
  113312. onControllerRemovedObservable: Observable<WebXRController>;
  113313. /**
  113314. * Initializes the WebXRInput
  113315. * @param baseExperience experience helper which the input should be created for
  113316. */
  113317. constructor(
  113318. /**
  113319. * Base experience the input listens to
  113320. */
  113321. baseExperience: WebXRExperienceHelper);
  113322. private _onInputSourcesChange;
  113323. private _addAndRemoveControllers;
  113324. /**
  113325. * Disposes of the object
  113326. */
  113327. dispose(): void;
  113328. }
  113329. }
  113330. declare module BABYLON {
  113331. /**
  113332. * Class used to represent data loading progression
  113333. */
  113334. export class SceneLoaderProgressEvent {
  113335. /** defines if data length to load can be evaluated */
  113336. readonly lengthComputable: boolean;
  113337. /** defines the loaded data length */
  113338. readonly loaded: number;
  113339. /** defines the data length to load */
  113340. readonly total: number;
  113341. /**
  113342. * Create a new progress event
  113343. * @param lengthComputable defines if data length to load can be evaluated
  113344. * @param loaded defines the loaded data length
  113345. * @param total defines the data length to load
  113346. */
  113347. constructor(
  113348. /** defines if data length to load can be evaluated */
  113349. lengthComputable: boolean,
  113350. /** defines the loaded data length */
  113351. loaded: number,
  113352. /** defines the data length to load */
  113353. total: number);
  113354. /**
  113355. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  113356. * @param event defines the source event
  113357. * @returns a new SceneLoaderProgressEvent
  113358. */
  113359. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  113360. }
  113361. /**
  113362. * Interface used by SceneLoader plugins to define supported file extensions
  113363. */
  113364. export interface ISceneLoaderPluginExtensions {
  113365. /**
  113366. * Defines the list of supported extensions
  113367. */
  113368. [extension: string]: {
  113369. isBinary: boolean;
  113370. };
  113371. }
  113372. /**
  113373. * Interface used by SceneLoader plugin factory
  113374. */
  113375. export interface ISceneLoaderPluginFactory {
  113376. /**
  113377. * Defines the name of the factory
  113378. */
  113379. name: string;
  113380. /**
  113381. * Function called to create a new plugin
  113382. * @return the new plugin
  113383. */
  113384. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  113385. /**
  113386. * The callback that returns true if the data can be directly loaded.
  113387. * @param data string containing the file data
  113388. * @returns if the data can be loaded directly
  113389. */
  113390. canDirectLoad?(data: string): boolean;
  113391. }
  113392. /**
  113393. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  113394. */
  113395. export interface ISceneLoaderPluginBase {
  113396. /**
  113397. * The friendly name of this plugin.
  113398. */
  113399. name: string;
  113400. /**
  113401. * The file extensions supported by this plugin.
  113402. */
  113403. extensions: string | ISceneLoaderPluginExtensions;
  113404. /**
  113405. * The callback called when loading from a url.
  113406. * @param scene scene loading this url
  113407. * @param url url to load
  113408. * @param onSuccess callback called when the file successfully loads
  113409. * @param onProgress callback called while file is loading (if the server supports this mode)
  113410. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113411. * @param onError callback called when the file fails to load
  113412. * @returns a file request object
  113413. */
  113414. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113415. /**
  113416. * The callback called when loading from a file object.
  113417. * @param scene scene loading this file
  113418. * @param file defines the file to load
  113419. * @param onSuccess defines the callback to call when data is loaded
  113420. * @param onProgress defines the callback to call during loading process
  113421. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  113422. * @param onError defines the callback to call when an error occurs
  113423. * @returns a file request object
  113424. */
  113425. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113426. /**
  113427. * The callback that returns true if the data can be directly loaded.
  113428. * @param data string containing the file data
  113429. * @returns if the data can be loaded directly
  113430. */
  113431. canDirectLoad?(data: string): boolean;
  113432. /**
  113433. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  113434. * @param scene scene loading this data
  113435. * @param data string containing the data
  113436. * @returns data to pass to the plugin
  113437. */
  113438. directLoad?(scene: Scene, data: string): any;
  113439. /**
  113440. * The callback that allows custom handling of the root url based on the response url.
  113441. * @param rootUrl the original root url
  113442. * @param responseURL the response url if available
  113443. * @returns the new root url
  113444. */
  113445. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  113446. }
  113447. /**
  113448. * Interface used to define a SceneLoader plugin
  113449. */
  113450. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  113451. /**
  113452. * Import meshes into a scene.
  113453. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113454. * @param scene The scene to import into
  113455. * @param data The data to import
  113456. * @param rootUrl The root url for scene and resources
  113457. * @param meshes The meshes array to import into
  113458. * @param particleSystems The particle systems array to import into
  113459. * @param skeletons The skeletons array to import into
  113460. * @param onError The callback when import fails
  113461. * @returns True if successful or false otherwise
  113462. */
  113463. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  113464. /**
  113465. * Load into a scene.
  113466. * @param scene The scene to load into
  113467. * @param data The data to import
  113468. * @param rootUrl The root url for scene and resources
  113469. * @param onError The callback when import fails
  113470. * @returns True if successful or false otherwise
  113471. */
  113472. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  113473. /**
  113474. * Load into an asset container.
  113475. * @param scene The scene to load into
  113476. * @param data The data to import
  113477. * @param rootUrl The root url for scene and resources
  113478. * @param onError The callback when import fails
  113479. * @returns The loaded asset container
  113480. */
  113481. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  113482. }
  113483. /**
  113484. * Interface used to define an async SceneLoader plugin
  113485. */
  113486. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  113487. /**
  113488. * Import meshes into a scene.
  113489. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113490. * @param scene The scene to import into
  113491. * @param data The data to import
  113492. * @param rootUrl The root url for scene and resources
  113493. * @param onProgress The callback when the load progresses
  113494. * @param fileName Defines the name of the file to load
  113495. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  113496. */
  113497. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  113498. meshes: AbstractMesh[];
  113499. particleSystems: IParticleSystem[];
  113500. skeletons: Skeleton[];
  113501. animationGroups: AnimationGroup[];
  113502. }>;
  113503. /**
  113504. * Load into a scene.
  113505. * @param scene The scene to load into
  113506. * @param data The data to import
  113507. * @param rootUrl The root url for scene and resources
  113508. * @param onProgress The callback when the load progresses
  113509. * @param fileName Defines the name of the file to load
  113510. * @returns Nothing
  113511. */
  113512. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  113513. /**
  113514. * Load into an asset container.
  113515. * @param scene The scene to load into
  113516. * @param data The data to import
  113517. * @param rootUrl The root url for scene and resources
  113518. * @param onProgress The callback when the load progresses
  113519. * @param fileName Defines the name of the file to load
  113520. * @returns The loaded asset container
  113521. */
  113522. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  113523. }
  113524. /**
  113525. * Mode that determines how to handle old animation groups before loading new ones.
  113526. */
  113527. export enum SceneLoaderAnimationGroupLoadingMode {
  113528. /**
  113529. * Reset all old animations to initial state then dispose them.
  113530. */
  113531. Clean = 0,
  113532. /**
  113533. * Stop all old animations.
  113534. */
  113535. Stop = 1,
  113536. /**
  113537. * Restart old animations from first frame.
  113538. */
  113539. Sync = 2,
  113540. /**
  113541. * Old animations remains untouched.
  113542. */
  113543. NoSync = 3
  113544. }
  113545. /**
  113546. * Class used to load scene from various file formats using registered plugins
  113547. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  113548. */
  113549. export class SceneLoader {
  113550. /**
  113551. * No logging while loading
  113552. */
  113553. static readonly NO_LOGGING: number;
  113554. /**
  113555. * Minimal logging while loading
  113556. */
  113557. static readonly MINIMAL_LOGGING: number;
  113558. /**
  113559. * Summary logging while loading
  113560. */
  113561. static readonly SUMMARY_LOGGING: number;
  113562. /**
  113563. * Detailled logging while loading
  113564. */
  113565. static readonly DETAILED_LOGGING: number;
  113566. /**
  113567. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  113568. */
  113569. static get ForceFullSceneLoadingForIncremental(): boolean;
  113570. static set ForceFullSceneLoadingForIncremental(value: boolean);
  113571. /**
  113572. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  113573. */
  113574. static get ShowLoadingScreen(): boolean;
  113575. static set ShowLoadingScreen(value: boolean);
  113576. /**
  113577. * Defines the current logging level (while loading the scene)
  113578. * @ignorenaming
  113579. */
  113580. static get loggingLevel(): number;
  113581. static set loggingLevel(value: number);
  113582. /**
  113583. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  113584. */
  113585. static get CleanBoneMatrixWeights(): boolean;
  113586. static set CleanBoneMatrixWeights(value: boolean);
  113587. /**
  113588. * Event raised when a plugin is used to load a scene
  113589. */
  113590. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  113591. private static _registeredPlugins;
  113592. private static _getDefaultPlugin;
  113593. private static _getPluginForExtension;
  113594. private static _getPluginForDirectLoad;
  113595. private static _getPluginForFilename;
  113596. private static _getDirectLoad;
  113597. private static _loadData;
  113598. private static _getFileInfo;
  113599. /**
  113600. * Gets a plugin that can load the given extension
  113601. * @param extension defines the extension to load
  113602. * @returns a plugin or null if none works
  113603. */
  113604. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  113605. /**
  113606. * Gets a boolean indicating that the given extension can be loaded
  113607. * @param extension defines the extension to load
  113608. * @returns true if the extension is supported
  113609. */
  113610. static IsPluginForExtensionAvailable(extension: string): boolean;
  113611. /**
  113612. * Adds a new plugin to the list of registered plugins
  113613. * @param plugin defines the plugin to add
  113614. */
  113615. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  113616. /**
  113617. * Import meshes into a scene
  113618. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113619. * @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)
  113620. * @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)
  113621. * @param scene the instance of BABYLON.Scene to append to
  113622. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  113623. * @param onProgress a callback with a progress event for each file being loaded
  113624. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113625. * @param pluginExtension the extension used to determine the plugin
  113626. * @returns The loaded plugin
  113627. */
  113628. 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>;
  113629. /**
  113630. * Import meshes into a scene
  113631. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113632. * @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)
  113633. * @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)
  113634. * @param scene the instance of BABYLON.Scene to append to
  113635. * @param onProgress a callback with a progress event for each file being loaded
  113636. * @param pluginExtension the extension used to determine the plugin
  113637. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  113638. */
  113639. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  113640. meshes: AbstractMesh[];
  113641. particleSystems: IParticleSystem[];
  113642. skeletons: Skeleton[];
  113643. animationGroups: AnimationGroup[];
  113644. }>;
  113645. /**
  113646. * Load a scene
  113647. * @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)
  113648. * @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)
  113649. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113650. * @param onSuccess a callback with the scene when import succeeds
  113651. * @param onProgress a callback with a progress event for each file being loaded
  113652. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113653. * @param pluginExtension the extension used to determine the plugin
  113654. * @returns The loaded plugin
  113655. */
  113656. 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>;
  113657. /**
  113658. * Load a scene
  113659. * @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)
  113660. * @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)
  113661. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113662. * @param onProgress a callback with a progress event for each file being loaded
  113663. * @param pluginExtension the extension used to determine the plugin
  113664. * @returns The loaded scene
  113665. */
  113666. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113667. /**
  113668. * Append a scene
  113669. * @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)
  113670. * @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)
  113671. * @param scene is the instance of BABYLON.Scene to append to
  113672. * @param onSuccess a callback with the scene when import succeeds
  113673. * @param onProgress a callback with a progress event for each file being loaded
  113674. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113675. * @param pluginExtension the extension used to determine the plugin
  113676. * @returns The loaded plugin
  113677. */
  113678. 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>;
  113679. /**
  113680. * Append a scene
  113681. * @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)
  113682. * @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)
  113683. * @param scene is the instance of BABYLON.Scene to append to
  113684. * @param onProgress a callback with a progress event for each file being loaded
  113685. * @param pluginExtension the extension used to determine the plugin
  113686. * @returns The given scene
  113687. */
  113688. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113689. /**
  113690. * Load a scene into an asset container
  113691. * @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)
  113692. * @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)
  113693. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113694. * @param onSuccess a callback with the scene when import succeeds
  113695. * @param onProgress a callback with a progress event for each file being loaded
  113696. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113697. * @param pluginExtension the extension used to determine the plugin
  113698. * @returns The loaded plugin
  113699. */
  113700. 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>;
  113701. /**
  113702. * Load a scene into an asset container
  113703. * @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)
  113704. * @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)
  113705. * @param scene is the instance of Scene to append to
  113706. * @param onProgress a callback with a progress event for each file being loaded
  113707. * @param pluginExtension the extension used to determine the plugin
  113708. * @returns The loaded asset container
  113709. */
  113710. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  113711. /**
  113712. * Import animations from a file into a scene
  113713. * @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)
  113714. * @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)
  113715. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113716. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113717. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113718. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113719. * @param onSuccess a callback with the scene when import succeeds
  113720. * @param onProgress a callback with a progress event for each file being loaded
  113721. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113722. */
  113723. 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;
  113724. /**
  113725. * Import animations from a file into a scene
  113726. * @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)
  113727. * @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)
  113728. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113729. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113730. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113731. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113732. * @param onSuccess a callback with the scene when import succeeds
  113733. * @param onProgress a callback with a progress event for each file being loaded
  113734. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113735. * @returns the updated scene with imported animations
  113736. */
  113737. 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>;
  113738. }
  113739. }
  113740. declare module BABYLON {
  113741. /**
  113742. * Generic Controller
  113743. */
  113744. export class GenericController extends WebVRController {
  113745. /**
  113746. * Base Url for the controller model.
  113747. */
  113748. static readonly MODEL_BASE_URL: string;
  113749. /**
  113750. * File name for the controller model.
  113751. */
  113752. static readonly MODEL_FILENAME: string;
  113753. /**
  113754. * Creates a new GenericController from a gamepad
  113755. * @param vrGamepad the gamepad that the controller should be created from
  113756. */
  113757. constructor(vrGamepad: any);
  113758. /**
  113759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113760. * @param scene scene in which to add meshes
  113761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113762. */
  113763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113764. /**
  113765. * Called once for each button that changed state since the last frame
  113766. * @param buttonIdx Which button index changed
  113767. * @param state New state of the button
  113768. * @param changes Which properties on the state changed since last frame
  113769. */
  113770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113771. }
  113772. }
  113773. declare module BABYLON {
  113774. /**
  113775. * Defines the WindowsMotionController object that the state of the windows motion controller
  113776. */
  113777. export class WindowsMotionController extends WebVRController {
  113778. /**
  113779. * The base url used to load the left and right controller models
  113780. */
  113781. static MODEL_BASE_URL: string;
  113782. /**
  113783. * The name of the left controller model file
  113784. */
  113785. static MODEL_LEFT_FILENAME: string;
  113786. /**
  113787. * The name of the right controller model file
  113788. */
  113789. static MODEL_RIGHT_FILENAME: string;
  113790. /**
  113791. * The controller name prefix for this controller type
  113792. */
  113793. static readonly GAMEPAD_ID_PREFIX: string;
  113794. /**
  113795. * The controller id pattern for this controller type
  113796. */
  113797. private static readonly GAMEPAD_ID_PATTERN;
  113798. private _loadedMeshInfo;
  113799. protected readonly _mapping: {
  113800. buttons: string[];
  113801. buttonMeshNames: {
  113802. 'trigger': string;
  113803. 'menu': string;
  113804. 'grip': string;
  113805. 'thumbstick': string;
  113806. 'trackpad': string;
  113807. };
  113808. buttonObservableNames: {
  113809. 'trigger': string;
  113810. 'menu': string;
  113811. 'grip': string;
  113812. 'thumbstick': string;
  113813. 'trackpad': string;
  113814. };
  113815. axisMeshNames: string[];
  113816. pointingPoseMeshName: string;
  113817. };
  113818. /**
  113819. * Fired when the trackpad on this controller is clicked
  113820. */
  113821. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113822. /**
  113823. * Fired when the trackpad on this controller is modified
  113824. */
  113825. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113826. /**
  113827. * The current x and y values of this controller's trackpad
  113828. */
  113829. trackpad: StickValues;
  113830. /**
  113831. * Creates a new WindowsMotionController from a gamepad
  113832. * @param vrGamepad the gamepad that the controller should be created from
  113833. */
  113834. constructor(vrGamepad: any);
  113835. /**
  113836. * Fired when the trigger on this controller is modified
  113837. */
  113838. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113839. /**
  113840. * Fired when the menu button on this controller is modified
  113841. */
  113842. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113843. /**
  113844. * Fired when the grip button on this controller is modified
  113845. */
  113846. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113847. /**
  113848. * Fired when the thumbstick button on this controller is modified
  113849. */
  113850. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113851. /**
  113852. * Fired when the touchpad button on this controller is modified
  113853. */
  113854. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113855. /**
  113856. * Fired when the touchpad values on this controller are modified
  113857. */
  113858. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  113859. protected _updateTrackpad(): void;
  113860. /**
  113861. * Called once per frame by the engine.
  113862. */
  113863. update(): void;
  113864. /**
  113865. * Called once for each button that changed state since the last frame
  113866. * @param buttonIdx Which button index changed
  113867. * @param state New state of the button
  113868. * @param changes Which properties on the state changed since last frame
  113869. */
  113870. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113871. /**
  113872. * Moves the buttons on the controller mesh based on their current state
  113873. * @param buttonName the name of the button to move
  113874. * @param buttonValue the value of the button which determines the buttons new position
  113875. */
  113876. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  113877. /**
  113878. * Moves the axis on the controller mesh based on its current state
  113879. * @param axis the index of the axis
  113880. * @param axisValue the value of the axis which determines the meshes new position
  113881. * @hidden
  113882. */
  113883. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  113884. /**
  113885. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113886. * @param scene scene in which to add meshes
  113887. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113888. */
  113889. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  113890. /**
  113891. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  113892. * can be transformed by button presses and axes values, based on this._mapping.
  113893. *
  113894. * @param scene scene in which the meshes exist
  113895. * @param meshes list of meshes that make up the controller model to process
  113896. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  113897. */
  113898. private processModel;
  113899. private createMeshInfo;
  113900. /**
  113901. * Gets the ray of the controller in the direction the controller is pointing
  113902. * @param length the length the resulting ray should be
  113903. * @returns a ray in the direction the controller is pointing
  113904. */
  113905. getForwardRay(length?: number): Ray;
  113906. /**
  113907. * Disposes of the controller
  113908. */
  113909. dispose(): void;
  113910. }
  113911. /**
  113912. * This class represents a new windows motion controller in XR.
  113913. */
  113914. export class XRWindowsMotionController extends WindowsMotionController {
  113915. /**
  113916. * Changing the original WIndowsMotionController mapping to fir the new mapping
  113917. */
  113918. protected readonly _mapping: {
  113919. buttons: string[];
  113920. buttonMeshNames: {
  113921. 'trigger': string;
  113922. 'menu': string;
  113923. 'grip': string;
  113924. 'thumbstick': string;
  113925. 'trackpad': string;
  113926. };
  113927. buttonObservableNames: {
  113928. 'trigger': string;
  113929. 'menu': string;
  113930. 'grip': string;
  113931. 'thumbstick': string;
  113932. 'trackpad': string;
  113933. };
  113934. axisMeshNames: string[];
  113935. pointingPoseMeshName: string;
  113936. };
  113937. /**
  113938. * Construct a new XR-Based windows motion controller
  113939. *
  113940. * @param gamepadInfo the gamepad object from the browser
  113941. */
  113942. constructor(gamepadInfo: any);
  113943. /**
  113944. * holds the thumbstick values (X,Y)
  113945. */
  113946. thumbstickValues: StickValues;
  113947. /**
  113948. * Fired when the thumbstick on this controller is clicked
  113949. */
  113950. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  113951. /**
  113952. * Fired when the thumbstick on this controller is modified
  113953. */
  113954. onThumbstickValuesChangedObservable: Observable<StickValues>;
  113955. /**
  113956. * Fired when the touchpad button on this controller is modified
  113957. */
  113958. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113959. /**
  113960. * Fired when the touchpad values on this controller are modified
  113961. */
  113962. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113963. /**
  113964. * Fired when the thumbstick button on this controller is modified
  113965. * here to prevent breaking changes
  113966. */
  113967. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113968. /**
  113969. * updating the thumbstick(!) and not the trackpad.
  113970. * This is named this way due to the difference between WebVR and XR and to avoid
  113971. * changing the parent class.
  113972. */
  113973. protected _updateTrackpad(): void;
  113974. /**
  113975. * Disposes the class with joy
  113976. */
  113977. dispose(): void;
  113978. }
  113979. }
  113980. declare module BABYLON {
  113981. /**
  113982. * Oculus Touch Controller
  113983. */
  113984. export class OculusTouchController extends WebVRController {
  113985. /**
  113986. * Base Url for the controller model.
  113987. */
  113988. static MODEL_BASE_URL: string;
  113989. /**
  113990. * File name for the left controller model.
  113991. */
  113992. static MODEL_LEFT_FILENAME: string;
  113993. /**
  113994. * File name for the right controller model.
  113995. */
  113996. static MODEL_RIGHT_FILENAME: string;
  113997. /**
  113998. * Base Url for the Quest controller model.
  113999. */
  114000. static QUEST_MODEL_BASE_URL: string;
  114001. /**
  114002. * @hidden
  114003. * If the controllers are running on a device that needs the updated Quest controller models
  114004. */
  114005. static _IsQuest: boolean;
  114006. /**
  114007. * Fired when the secondary trigger on this controller is modified
  114008. */
  114009. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  114010. /**
  114011. * Fired when the thumb rest on this controller is modified
  114012. */
  114013. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  114014. /**
  114015. * Creates a new OculusTouchController from a gamepad
  114016. * @param vrGamepad the gamepad that the controller should be created from
  114017. */
  114018. constructor(vrGamepad: any);
  114019. /**
  114020. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114021. * @param scene scene in which to add meshes
  114022. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114023. */
  114024. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114025. /**
  114026. * Fired when the A button on this controller is modified
  114027. */
  114028. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114029. /**
  114030. * Fired when the B button on this controller is modified
  114031. */
  114032. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114033. /**
  114034. * Fired when the X button on this controller is modified
  114035. */
  114036. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114037. /**
  114038. * Fired when the Y button on this controller is modified
  114039. */
  114040. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114041. /**
  114042. * Called once for each button that changed state since the last frame
  114043. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  114044. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  114045. * 2) secondary trigger (same)
  114046. * 3) A (right) X (left), touch, pressed = value
  114047. * 4) B / Y
  114048. * 5) thumb rest
  114049. * @param buttonIdx Which button index changed
  114050. * @param state New state of the button
  114051. * @param changes Which properties on the state changed since last frame
  114052. */
  114053. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114054. }
  114055. }
  114056. declare module BABYLON {
  114057. /**
  114058. * Vive Controller
  114059. */
  114060. export class ViveController extends WebVRController {
  114061. /**
  114062. * Base Url for the controller model.
  114063. */
  114064. static MODEL_BASE_URL: string;
  114065. /**
  114066. * File name for the controller model.
  114067. */
  114068. static MODEL_FILENAME: string;
  114069. /**
  114070. * Creates a new ViveController from a gamepad
  114071. * @param vrGamepad the gamepad that the controller should be created from
  114072. */
  114073. constructor(vrGamepad: any);
  114074. /**
  114075. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114076. * @param scene scene in which to add meshes
  114077. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114078. */
  114079. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114080. /**
  114081. * Fired when the left button on this controller is modified
  114082. */
  114083. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114084. /**
  114085. * Fired when the right button on this controller is modified
  114086. */
  114087. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114088. /**
  114089. * Fired when the menu button on this controller is modified
  114090. */
  114091. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114092. /**
  114093. * Called once for each button that changed state since the last frame
  114094. * Vive mapping:
  114095. * 0: touchpad
  114096. * 1: trigger
  114097. * 2: left AND right buttons
  114098. * 3: menu button
  114099. * @param buttonIdx Which button index changed
  114100. * @param state New state of the button
  114101. * @param changes Which properties on the state changed since last frame
  114102. */
  114103. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114104. }
  114105. }
  114106. declare module BABYLON {
  114107. /**
  114108. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  114109. */
  114110. export class WebXRControllerModelLoader {
  114111. /**
  114112. * an observable that triggers when a new model (the mesh itself) was initialized.
  114113. * To know when the mesh was loaded use the controller's own modelLoaded() method
  114114. */
  114115. onControllerModelLoaded: Observable<WebXRController>;
  114116. /**
  114117. * Creates the WebXRControllerModelLoader
  114118. * @param input xr input that creates the controllers
  114119. */
  114120. constructor(input: WebXRInput);
  114121. }
  114122. }
  114123. declare module BABYLON {
  114124. /**
  114125. * Handles pointer input automatically for the pointer of XR controllers
  114126. */
  114127. export class WebXRControllerPointerSelection {
  114128. private static _idCounter;
  114129. private _tmpRay;
  114130. /**
  114131. * Creates a WebXRControllerPointerSelection
  114132. * @param input input manager to setup pointer selection
  114133. */
  114134. constructor(input: WebXRInput);
  114135. private _convertNormalToDirectionOfRay;
  114136. private _updatePointerDistance;
  114137. }
  114138. }
  114139. declare module BABYLON {
  114140. /**
  114141. * Enables teleportation
  114142. */
  114143. export class WebXRControllerTeleportation {
  114144. private _teleportationFillColor;
  114145. private _teleportationBorderColor;
  114146. private _tmpRay;
  114147. private _tmpVector;
  114148. /**
  114149. * when set to true (default) teleportation will wait for thumbstick changes.
  114150. * When set to false teleportation will be disabled.
  114151. *
  114152. * If set to false while teleporting results can be unexpected.
  114153. */
  114154. enabled: boolean;
  114155. /**
  114156. * Creates a WebXRControllerTeleportation
  114157. * @param input input manager to add teleportation to
  114158. * @param floorMeshes floormeshes which can be teleported to
  114159. */
  114160. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  114161. }
  114162. }
  114163. declare module BABYLON {
  114164. /**
  114165. * Button which can be used to enter a different mode of XR
  114166. */
  114167. export class WebXREnterExitUIButton {
  114168. /** button element */
  114169. element: HTMLElement;
  114170. /** XR initialization options for the button */
  114171. sessionMode: XRSessionMode;
  114172. /** Reference space type */
  114173. referenceSpaceType: XRReferenceSpaceType;
  114174. /**
  114175. * Creates a WebXREnterExitUIButton
  114176. * @param element button element
  114177. * @param sessionMode XR initialization session mode
  114178. * @param referenceSpaceType the type of reference space to be used
  114179. */
  114180. constructor(
  114181. /** button element */
  114182. element: HTMLElement,
  114183. /** XR initialization options for the button */
  114184. sessionMode: XRSessionMode,
  114185. /** Reference space type */
  114186. referenceSpaceType: XRReferenceSpaceType);
  114187. /**
  114188. * Overwritable function which can be used to update the button's visuals when the state changes
  114189. * @param activeButton the current active button in the UI
  114190. */
  114191. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  114192. }
  114193. /**
  114194. * Options to create the webXR UI
  114195. */
  114196. export class WebXREnterExitUIOptions {
  114197. /**
  114198. * Context to enter xr with
  114199. */
  114200. renderTarget?: Nullable<WebXRRenderTarget>;
  114201. /**
  114202. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  114203. */
  114204. customButtons?: Array<WebXREnterExitUIButton>;
  114205. /**
  114206. * A session mode to use when creating the default button.
  114207. * Default is immersive-vr
  114208. */
  114209. sessionMode?: XRSessionMode;
  114210. /**
  114211. * A reference space type to use when creating the default button.
  114212. * Default is local-floor
  114213. */
  114214. referenceSpaceType?: XRReferenceSpaceType;
  114215. }
  114216. /**
  114217. * UI to allow the user to enter/exit XR mode
  114218. */
  114219. export class WebXREnterExitUI implements IDisposable {
  114220. private scene;
  114221. /** version of the options passed to this UI */
  114222. options: WebXREnterExitUIOptions;
  114223. private _overlay;
  114224. private _buttons;
  114225. private _activeButton;
  114226. /**
  114227. * Fired every time the active button is changed.
  114228. *
  114229. * When xr is entered via a button that launches xr that button will be the callback parameter
  114230. *
  114231. * When exiting xr the callback parameter will be null)
  114232. */
  114233. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  114234. /**
  114235. * Creates UI to allow the user to enter/exit XR mode
  114236. * @param scene the scene to add the ui to
  114237. * @param helper the xr experience helper to enter/exit xr with
  114238. * @param options options to configure the UI
  114239. * @returns the created ui
  114240. */
  114241. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  114242. /**
  114243. *
  114244. * @param scene babylon scene object to use
  114245. * @param options (read-only) version of the options passed to this UI
  114246. */
  114247. private constructor();
  114248. private _updateButtons;
  114249. /**
  114250. * Disposes of the object
  114251. */
  114252. dispose(): void;
  114253. }
  114254. }
  114255. declare module BABYLON {
  114256. /**
  114257. * Options for the default xr helper
  114258. */
  114259. export class WebXRDefaultExperienceOptions {
  114260. /**
  114261. * Floor meshes that should be used for teleporting
  114262. */
  114263. floorMeshes: Array<AbstractMesh>;
  114264. /**
  114265. * Enable or disable default UI to enter XR
  114266. */
  114267. disableDefaultUI?: boolean;
  114268. /**
  114269. * optional configuration for the output canvas
  114270. */
  114271. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  114272. /**
  114273. * optional UI options. This can be used among other to change session mode and reference space type
  114274. */
  114275. uiOptions?: WebXREnterExitUIOptions;
  114276. }
  114277. /**
  114278. * Default experience which provides a similar setup to the previous webVRExperience
  114279. */
  114280. export class WebXRDefaultExperience {
  114281. /**
  114282. * Base experience
  114283. */
  114284. baseExperience: WebXRExperienceHelper;
  114285. /**
  114286. * Input experience extension
  114287. */
  114288. input: WebXRInput;
  114289. /**
  114290. * Loads the controller models
  114291. */
  114292. controllerModelLoader: WebXRControllerModelLoader;
  114293. /**
  114294. * Enables laser pointer and selection
  114295. */
  114296. pointerSelection: WebXRControllerPointerSelection;
  114297. /**
  114298. * Enables teleportation
  114299. */
  114300. teleportation: WebXRControllerTeleportation;
  114301. /**
  114302. * Enables ui for entering/exiting xr
  114303. */
  114304. enterExitUI: WebXREnterExitUI;
  114305. /**
  114306. * Default target xr should render to
  114307. */
  114308. renderTarget: WebXRRenderTarget;
  114309. /**
  114310. * Creates the default xr experience
  114311. * @param scene scene
  114312. * @param options options for basic configuration
  114313. * @returns resulting WebXRDefaultExperience
  114314. */
  114315. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114316. private constructor();
  114317. /**
  114318. * DIsposes of the experience helper
  114319. */
  114320. dispose(): void;
  114321. }
  114322. }
  114323. declare module BABYLON {
  114324. /**
  114325. * Options to modify the vr teleportation behavior.
  114326. */
  114327. export interface VRTeleportationOptions {
  114328. /**
  114329. * The name of the mesh which should be used as the teleportation floor. (default: null)
  114330. */
  114331. floorMeshName?: string;
  114332. /**
  114333. * A list of meshes to be used as the teleportation floor. (default: empty)
  114334. */
  114335. floorMeshes?: Mesh[];
  114336. /**
  114337. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  114338. */
  114339. teleportationMode?: number;
  114340. /**
  114341. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  114342. */
  114343. teleportationTime?: number;
  114344. /**
  114345. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  114346. */
  114347. teleportationSpeed?: number;
  114348. /**
  114349. * The easing function used in the animation or null for Linear. (default CircleEase)
  114350. */
  114351. easingFunction?: EasingFunction;
  114352. }
  114353. /**
  114354. * Options to modify the vr experience helper's behavior.
  114355. */
  114356. export interface VRExperienceHelperOptions extends WebVROptions {
  114357. /**
  114358. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  114359. */
  114360. createDeviceOrientationCamera?: boolean;
  114361. /**
  114362. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  114363. */
  114364. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  114365. /**
  114366. * Uses the main button on the controller to toggle the laser casted. (default: true)
  114367. */
  114368. laserToggle?: boolean;
  114369. /**
  114370. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  114371. */
  114372. floorMeshes?: Mesh[];
  114373. /**
  114374. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  114375. */
  114376. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  114377. /**
  114378. * Defines if WebXR should be used instead of WebVR (if available)
  114379. */
  114380. useXR?: boolean;
  114381. }
  114382. /**
  114383. * Event containing information after VR has been entered
  114384. */
  114385. export class OnAfterEnteringVRObservableEvent {
  114386. /**
  114387. * If entering vr was successful
  114388. */
  114389. success: boolean;
  114390. }
  114391. /**
  114392. * Helps to quickly add VR support to an existing scene.
  114393. * See http://doc.babylonjs.com/how_to/webvr_helper
  114394. */
  114395. export class VRExperienceHelper {
  114396. /** Options to modify the vr experience helper's behavior. */
  114397. webVROptions: VRExperienceHelperOptions;
  114398. private _scene;
  114399. private _position;
  114400. private _btnVR;
  114401. private _btnVRDisplayed;
  114402. private _webVRsupported;
  114403. private _webVRready;
  114404. private _webVRrequesting;
  114405. private _webVRpresenting;
  114406. private _hasEnteredVR;
  114407. private _fullscreenVRpresenting;
  114408. private _inputElement;
  114409. private _webVRCamera;
  114410. private _vrDeviceOrientationCamera;
  114411. private _deviceOrientationCamera;
  114412. private _existingCamera;
  114413. private _onKeyDown;
  114414. private _onVrDisplayPresentChange;
  114415. private _onVRDisplayChanged;
  114416. private _onVRRequestPresentStart;
  114417. private _onVRRequestPresentComplete;
  114418. /**
  114419. * 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)
  114420. */
  114421. enableGazeEvenWhenNoPointerLock: boolean;
  114422. /**
  114423. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  114424. */
  114425. exitVROnDoubleTap: boolean;
  114426. /**
  114427. * Observable raised right before entering VR.
  114428. */
  114429. onEnteringVRObservable: Observable<VRExperienceHelper>;
  114430. /**
  114431. * Observable raised when entering VR has completed.
  114432. */
  114433. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  114434. /**
  114435. * Observable raised when exiting VR.
  114436. */
  114437. onExitingVRObservable: Observable<VRExperienceHelper>;
  114438. /**
  114439. * Observable raised when controller mesh is loaded.
  114440. */
  114441. onControllerMeshLoadedObservable: Observable<WebVRController>;
  114442. /** Return this.onEnteringVRObservable
  114443. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  114444. */
  114445. get onEnteringVR(): Observable<VRExperienceHelper>;
  114446. /** Return this.onExitingVRObservable
  114447. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  114448. */
  114449. get onExitingVR(): Observable<VRExperienceHelper>;
  114450. /** Return this.onControllerMeshLoadedObservable
  114451. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  114452. */
  114453. get onControllerMeshLoaded(): Observable<WebVRController>;
  114454. private _rayLength;
  114455. private _useCustomVRButton;
  114456. private _teleportationRequested;
  114457. private _teleportActive;
  114458. private _floorMeshName;
  114459. private _floorMeshesCollection;
  114460. private _teleportationMode;
  114461. private _teleportationTime;
  114462. private _teleportationSpeed;
  114463. private _teleportationEasing;
  114464. private _rotationAllowed;
  114465. private _teleportBackwardsVector;
  114466. private _teleportationTarget;
  114467. private _isDefaultTeleportationTarget;
  114468. private _postProcessMove;
  114469. private _teleportationFillColor;
  114470. private _teleportationBorderColor;
  114471. private _rotationAngle;
  114472. private _haloCenter;
  114473. private _cameraGazer;
  114474. private _padSensibilityUp;
  114475. private _padSensibilityDown;
  114476. private _leftController;
  114477. private _rightController;
  114478. /**
  114479. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  114480. */
  114481. onNewMeshSelected: Observable<AbstractMesh>;
  114482. /**
  114483. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  114484. * This observable will provide the mesh and the controller used to select the mesh
  114485. */
  114486. onMeshSelectedWithController: Observable<{
  114487. mesh: AbstractMesh;
  114488. controller: WebVRController;
  114489. }>;
  114490. /**
  114491. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  114492. */
  114493. onNewMeshPicked: Observable<PickingInfo>;
  114494. private _circleEase;
  114495. /**
  114496. * Observable raised before camera teleportation
  114497. */
  114498. onBeforeCameraTeleport: Observable<Vector3>;
  114499. /**
  114500. * Observable raised after camera teleportation
  114501. */
  114502. onAfterCameraTeleport: Observable<Vector3>;
  114503. /**
  114504. * Observable raised when current selected mesh gets unselected
  114505. */
  114506. onSelectedMeshUnselected: Observable<AbstractMesh>;
  114507. private _raySelectionPredicate;
  114508. /**
  114509. * To be optionaly changed by user to define custom ray selection
  114510. */
  114511. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  114512. /**
  114513. * To be optionaly changed by user to define custom selection logic (after ray selection)
  114514. */
  114515. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114516. /**
  114517. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  114518. */
  114519. teleportationEnabled: boolean;
  114520. private _defaultHeight;
  114521. private _teleportationInitialized;
  114522. private _interactionsEnabled;
  114523. private _interactionsRequested;
  114524. private _displayGaze;
  114525. private _displayLaserPointer;
  114526. /**
  114527. * The mesh used to display where the user is going to teleport.
  114528. */
  114529. get teleportationTarget(): Mesh;
  114530. /**
  114531. * Sets the mesh to be used to display where the user is going to teleport.
  114532. */
  114533. set teleportationTarget(value: Mesh);
  114534. /**
  114535. * 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
  114536. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  114537. * See http://doc.babylonjs.com/resources/baking_transformations
  114538. */
  114539. get gazeTrackerMesh(): Mesh;
  114540. set gazeTrackerMesh(value: Mesh);
  114541. /**
  114542. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  114543. */
  114544. updateGazeTrackerScale: boolean;
  114545. /**
  114546. * If the gaze trackers color should be updated when selecting meshes
  114547. */
  114548. updateGazeTrackerColor: boolean;
  114549. /**
  114550. * If the controller laser color should be updated when selecting meshes
  114551. */
  114552. updateControllerLaserColor: boolean;
  114553. /**
  114554. * The gaze tracking mesh corresponding to the left controller
  114555. */
  114556. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  114557. /**
  114558. * The gaze tracking mesh corresponding to the right controller
  114559. */
  114560. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  114561. /**
  114562. * If the ray of the gaze should be displayed.
  114563. */
  114564. get displayGaze(): boolean;
  114565. /**
  114566. * Sets if the ray of the gaze should be displayed.
  114567. */
  114568. set displayGaze(value: boolean);
  114569. /**
  114570. * If the ray of the LaserPointer should be displayed.
  114571. */
  114572. get displayLaserPointer(): boolean;
  114573. /**
  114574. * Sets if the ray of the LaserPointer should be displayed.
  114575. */
  114576. set displayLaserPointer(value: boolean);
  114577. /**
  114578. * The deviceOrientationCamera used as the camera when not in VR.
  114579. */
  114580. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  114581. /**
  114582. * Based on the current WebVR support, returns the current VR camera used.
  114583. */
  114584. get currentVRCamera(): Nullable<Camera>;
  114585. /**
  114586. * The webVRCamera which is used when in VR.
  114587. */
  114588. get webVRCamera(): WebVRFreeCamera;
  114589. /**
  114590. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  114591. */
  114592. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  114593. /**
  114594. * The html button that is used to trigger entering into VR.
  114595. */
  114596. get vrButton(): Nullable<HTMLButtonElement>;
  114597. private get _teleportationRequestInitiated();
  114598. /**
  114599. * Defines wether or not Pointer lock should be requested when switching to
  114600. * full screen.
  114601. */
  114602. requestPointerLockOnFullScreen: boolean;
  114603. /**
  114604. * If asking to force XR, this will be populated with the default xr experience
  114605. */
  114606. xr: WebXRDefaultExperience;
  114607. /**
  114608. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  114609. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  114610. */
  114611. xrTestDone: boolean;
  114612. /**
  114613. * Instantiates a VRExperienceHelper.
  114614. * Helps to quickly add VR support to an existing scene.
  114615. * @param scene The scene the VRExperienceHelper belongs to.
  114616. * @param webVROptions Options to modify the vr experience helper's behavior.
  114617. */
  114618. constructor(scene: Scene,
  114619. /** Options to modify the vr experience helper's behavior. */
  114620. webVROptions?: VRExperienceHelperOptions);
  114621. private completeVRInit;
  114622. private _onDefaultMeshLoaded;
  114623. private _onResize;
  114624. private _onFullscreenChange;
  114625. /**
  114626. * Gets a value indicating if we are currently in VR mode.
  114627. */
  114628. get isInVRMode(): boolean;
  114629. private onVrDisplayPresentChange;
  114630. private onVRDisplayChanged;
  114631. private moveButtonToBottomRight;
  114632. private displayVRButton;
  114633. private updateButtonVisibility;
  114634. private _cachedAngularSensibility;
  114635. /**
  114636. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  114637. * Otherwise, will use the fullscreen API.
  114638. */
  114639. enterVR(): void;
  114640. /**
  114641. * Attempt to exit VR, or fullscreen.
  114642. */
  114643. exitVR(): void;
  114644. /**
  114645. * The position of the vr experience helper.
  114646. */
  114647. get position(): Vector3;
  114648. /**
  114649. * Sets the position of the vr experience helper.
  114650. */
  114651. set position(value: Vector3);
  114652. /**
  114653. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  114654. */
  114655. enableInteractions(): void;
  114656. private get _noControllerIsActive();
  114657. private beforeRender;
  114658. private _isTeleportationFloor;
  114659. /**
  114660. * Adds a floor mesh to be used for teleportation.
  114661. * @param floorMesh the mesh to be used for teleportation.
  114662. */
  114663. addFloorMesh(floorMesh: Mesh): void;
  114664. /**
  114665. * Removes a floor mesh from being used for teleportation.
  114666. * @param floorMesh the mesh to be removed.
  114667. */
  114668. removeFloorMesh(floorMesh: Mesh): void;
  114669. /**
  114670. * Enables interactions and teleportation using the VR controllers and gaze.
  114671. * @param vrTeleportationOptions options to modify teleportation behavior.
  114672. */
  114673. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  114674. private _onNewGamepadConnected;
  114675. private _tryEnableInteractionOnController;
  114676. private _onNewGamepadDisconnected;
  114677. private _enableInteractionOnController;
  114678. private _checkTeleportWithRay;
  114679. private _checkRotate;
  114680. private _checkTeleportBackwards;
  114681. private _enableTeleportationOnController;
  114682. private _createTeleportationCircles;
  114683. private _displayTeleportationTarget;
  114684. private _hideTeleportationTarget;
  114685. private _rotateCamera;
  114686. private _moveTeleportationSelectorTo;
  114687. private _workingVector;
  114688. private _workingQuaternion;
  114689. private _workingMatrix;
  114690. /**
  114691. * Time Constant Teleportation Mode
  114692. */
  114693. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  114694. /**
  114695. * Speed Constant Teleportation Mode
  114696. */
  114697. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  114698. /**
  114699. * Teleports the users feet to the desired location
  114700. * @param location The location where the user's feet should be placed
  114701. */
  114702. teleportCamera(location: Vector3): void;
  114703. private _convertNormalToDirectionOfRay;
  114704. private _castRayAndSelectObject;
  114705. private _notifySelectedMeshUnselected;
  114706. /**
  114707. * Sets the color of the laser ray from the vr controllers.
  114708. * @param color new color for the ray.
  114709. */
  114710. changeLaserColor(color: Color3): void;
  114711. /**
  114712. * Sets the color of the ray from the vr headsets gaze.
  114713. * @param color new color for the ray.
  114714. */
  114715. changeGazeColor(color: Color3): void;
  114716. /**
  114717. * Exits VR and disposes of the vr experience helper
  114718. */
  114719. dispose(): void;
  114720. /**
  114721. * Gets the name of the VRExperienceHelper class
  114722. * @returns "VRExperienceHelper"
  114723. */
  114724. getClassName(): string;
  114725. }
  114726. }
  114727. declare module BABYLON {
  114728. /**
  114729. * Options used for hit testing
  114730. */
  114731. export interface IWebXRHitTestOptions {
  114732. /**
  114733. * Only test when user interacted with the scene. Default - hit test every frame
  114734. */
  114735. testOnPointerDownOnly?: boolean;
  114736. /**
  114737. * The node to use to transform the local results to world coordinates
  114738. */
  114739. worldParentNode?: TransformNode;
  114740. }
  114741. /**
  114742. * Interface defining the babylon result of raycasting/hit-test
  114743. */
  114744. export interface IWebXRHitResult {
  114745. /**
  114746. * The native hit test result
  114747. */
  114748. xrHitResult: XRHitResult;
  114749. /**
  114750. * Transformation matrix that can be applied to a node that will put it in the hit point location
  114751. */
  114752. transformationMatrix: Matrix;
  114753. }
  114754. /**
  114755. * The currently-working hit-test module.
  114756. * Hit test (or raycasting) is used to interact with the real world.
  114757. * For further information read here - https://github.com/immersive-web/hit-test
  114758. */
  114759. export class WebXRHitTestLegacy implements IWebXRFeature {
  114760. private _xrSessionManager;
  114761. /**
  114762. * options to use when constructing this feature
  114763. */
  114764. readonly options: IWebXRHitTestOptions;
  114765. /**
  114766. * The module's name
  114767. */
  114768. static readonly Name: string;
  114769. /**
  114770. * The (Babylon) version of this module.
  114771. * This is an integer representing the implementation version.
  114772. * This number does not correspond to the webxr specs version
  114773. */
  114774. static readonly Version: number;
  114775. /**
  114776. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  114777. * @param event the (select) event to use to select with
  114778. * @param referenceSpace the reference space to use for this hit test
  114779. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114780. */
  114781. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  114782. /**
  114783. * execute a hit test with an XR Ray
  114784. *
  114785. * @param xrSession a native xrSession that will execute this hit test
  114786. * @param xrRay the ray (position and direction) to use for raycasting
  114787. * @param referenceSpace native XR reference space to use for the hit-test
  114788. * @param filter filter function that will filter the results
  114789. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114790. */
  114791. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  114792. /**
  114793. * Triggered when new babylon (transformed) hit test results are available
  114794. */
  114795. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  114796. /**
  114797. * Creates a new instance of the (legacy version) hit test feature
  114798. * @param _xrSessionManager an instance of WebXRSessionManager
  114799. * @param options options to use when constructing this feature
  114800. */
  114801. constructor(_xrSessionManager: WebXRSessionManager,
  114802. /**
  114803. * options to use when constructing this feature
  114804. */
  114805. options?: IWebXRHitTestOptions);
  114806. private _onSelectEnabled;
  114807. private _xrFrameObserver;
  114808. private _attached;
  114809. /**
  114810. * Populated with the last native XR Hit Results
  114811. */
  114812. lastNativeXRHitResults: XRHitResult[];
  114813. /**
  114814. * attach this feature
  114815. * Will usually be called by the features manager
  114816. *
  114817. * @returns true if successful.
  114818. */
  114819. attach(): boolean;
  114820. /**
  114821. * detach this feature.
  114822. * Will usually be called by the features manager
  114823. *
  114824. * @returns true if successful.
  114825. */
  114826. detach(): boolean;
  114827. private _onHitTestResults;
  114828. private _onSelect;
  114829. /**
  114830. * Dispose this feature and all of the resources attached
  114831. */
  114832. dispose(): void;
  114833. }
  114834. }
  114835. declare module BABYLON {
  114836. /**
  114837. * Options used in the plane detector module
  114838. */
  114839. export interface IWebXRPlaneDetectorOptions {
  114840. /**
  114841. * The node to use to transform the local results to world coordinates
  114842. */
  114843. worldParentNode?: TransformNode;
  114844. }
  114845. /**
  114846. * A babylon interface for a webxr plane.
  114847. * A Plane is actually a polygon, built from N points in space
  114848. */
  114849. export interface IWebXRPlane {
  114850. /**
  114851. * a babylon-assigned ID for this polygon
  114852. */
  114853. id: number;
  114854. /**
  114855. * the native xr-plane object
  114856. */
  114857. xrPlane: XRPlane;
  114858. /**
  114859. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  114860. */
  114861. polygonDefinition: Array<Vector3>;
  114862. /**
  114863. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  114864. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  114865. */
  114866. transformationMatrix: Matrix;
  114867. }
  114868. /**
  114869. * The plane detector is used to detect planes in the real world when in AR
  114870. * For more information see https://github.com/immersive-web/real-world-geometry/
  114871. */
  114872. export class WebXRPlaneDetector implements IWebXRFeature {
  114873. private _xrSessionManager;
  114874. private _options;
  114875. /**
  114876. * The module's name
  114877. */
  114878. static readonly Name: string;
  114879. /**
  114880. * The (Babylon) version of this module.
  114881. * This is an integer representing the implementation version.
  114882. * This number does not correspond to the webxr specs version
  114883. */
  114884. static readonly Version: number;
  114885. /**
  114886. * Observers registered here will be executed when a new plane was added to the session
  114887. */
  114888. onPlaneAddedObservable: Observable<IWebXRPlane>;
  114889. /**
  114890. * Observers registered here will be executed when a plane is no longer detected in the session
  114891. */
  114892. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  114893. /**
  114894. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  114895. * This can execute N times every frame
  114896. */
  114897. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  114898. private _enabled;
  114899. private _attached;
  114900. private _detectedPlanes;
  114901. private _lastFrameDetected;
  114902. private _observerTracked;
  114903. /**
  114904. * construct a new Plane Detector
  114905. * @param _xrSessionManager an instance of xr Session manager
  114906. * @param _options configuration to use when constructing this feature
  114907. */
  114908. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  114909. /**
  114910. * attach this feature
  114911. * Will usually be called by the features manager
  114912. *
  114913. * @returns true if successful.
  114914. */
  114915. attach(): boolean;
  114916. /**
  114917. * detach this feature.
  114918. * Will usually be called by the features manager
  114919. *
  114920. * @returns true if successful.
  114921. */
  114922. detach(): boolean;
  114923. /**
  114924. * Dispose this feature and all of the resources attached
  114925. */
  114926. dispose(): void;
  114927. private _updatePlaneWithXRPlane;
  114928. /**
  114929. * avoiding using Array.find for global support.
  114930. * @param xrPlane the plane to find in the array
  114931. */
  114932. private findIndexInPlaneArray;
  114933. }
  114934. }
  114935. declare module BABYLON {
  114936. /**
  114937. * Configuration options of the anchor system
  114938. */
  114939. export interface IWebXRAnchorSystemOptions {
  114940. /**
  114941. * a node that will be used to convert local to world coordinates
  114942. */
  114943. worldParentNode?: TransformNode;
  114944. /**
  114945. * should the anchor system use plane detection.
  114946. * If set to true, the plane-detection feature should be set using setPlaneDetector
  114947. */
  114948. usePlaneDetection?: boolean;
  114949. /**
  114950. * Should a new anchor be added every time a select event is triggered
  114951. */
  114952. addAnchorOnSelect?: boolean;
  114953. }
  114954. /**
  114955. * A babylon container for an XR Anchor
  114956. */
  114957. export interface IWebXRAnchor {
  114958. /**
  114959. * A babylon-assigned ID for this anchor
  114960. */
  114961. id: number;
  114962. /**
  114963. * The native anchor object
  114964. */
  114965. xrAnchor: XRAnchor;
  114966. /**
  114967. * Transformation matrix to apply to an object attached to this anchor
  114968. */
  114969. transformationMatrix: Matrix;
  114970. }
  114971. /**
  114972. * An implementation of the anchor system of WebXR.
  114973. * Note that the current documented implementation is not available in any browser. Future implementations
  114974. * will use the frame to create an anchor and not the session or a detected plane
  114975. * For further information see https://github.com/immersive-web/anchors/
  114976. */
  114977. export class WebXRAnchorSystem implements IWebXRFeature {
  114978. private _xrSessionManager;
  114979. private _options;
  114980. /**
  114981. * The module's name
  114982. */
  114983. static readonly Name: string;
  114984. /**
  114985. * The (Babylon) version of this module.
  114986. * This is an integer representing the implementation version.
  114987. * This number does not correspond to the webxr specs version
  114988. */
  114989. static readonly Version: number;
  114990. /**
  114991. * Observers registered here will be executed when a new anchor was added to the session
  114992. */
  114993. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  114994. /**
  114995. * Observers registered here will be executed when an existing anchor updates
  114996. * This can execute N times every frame
  114997. */
  114998. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  114999. /**
  115000. * Observers registered here will be executed when an anchor was removed from the session
  115001. */
  115002. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  115003. private _planeDetector;
  115004. private _hitTestModule;
  115005. private _enabled;
  115006. private _attached;
  115007. private _trackedAnchors;
  115008. private _lastFrameDetected;
  115009. private _observerTracked;
  115010. /**
  115011. * constructs a new anchor system
  115012. * @param _xrSessionManager an instance of WebXRSessionManager
  115013. * @param _options configuration object for this feature
  115014. */
  115015. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  115016. /**
  115017. * set the plane detector to use in order to create anchors from frames
  115018. * @param planeDetector the plane-detector module to use
  115019. * @param enable enable plane-anchors. default is true
  115020. */
  115021. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  115022. /**
  115023. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  115024. * @param hitTestModule the hit-test module to use.
  115025. */
  115026. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  115027. /**
  115028. * attach this feature
  115029. * Will usually be called by the features manager
  115030. *
  115031. * @returns true if successful.
  115032. */
  115033. attach(): boolean;
  115034. /**
  115035. * detach this feature.
  115036. * Will usually be called by the features manager
  115037. *
  115038. * @returns true if successful.
  115039. */
  115040. detach(): boolean;
  115041. /**
  115042. * Dispose this feature and all of the resources attached
  115043. */
  115044. dispose(): void;
  115045. private _onSelect;
  115046. /**
  115047. * Add anchor at a specific XR point.
  115048. *
  115049. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  115050. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  115051. * @returns a promise the fulfills when the anchor was created
  115052. */
  115053. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  115054. private _updateAnchorWithXRFrame;
  115055. /**
  115056. * avoiding using Array.find for global support.
  115057. * @param xrAnchor the plane to find in the array
  115058. */
  115059. private _findIndexInAnchorArray;
  115060. }
  115061. }
  115062. declare module BABYLON {
  115063. /**
  115064. * Options interface for the background remover plugin
  115065. */
  115066. export interface IWebXRBackgroundRemoverOptions {
  115067. /**
  115068. * don't disable the environment helper
  115069. */
  115070. ignoreEnvironmentHelper?: boolean;
  115071. /**
  115072. * flags to configure the removal of the environment helper.
  115073. * If not set, the entire background will be removed. If set, flags should be set as well.
  115074. */
  115075. environmentHelperRemovalFlags?: {
  115076. /**
  115077. * Should the skybox be removed (default false)
  115078. */
  115079. skyBox?: boolean;
  115080. /**
  115081. * Should the ground be removed (default false)
  115082. */
  115083. ground?: boolean;
  115084. };
  115085. /**
  115086. * Further background meshes to disable when entering AR
  115087. */
  115088. backgroundMeshes?: AbstractMesh[];
  115089. }
  115090. /**
  115091. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  115092. */
  115093. export class WebXRBackgroundRemover implements IWebXRFeature {
  115094. private _xrSessionManager;
  115095. /**
  115096. * read-only options to be used in this module
  115097. */
  115098. readonly options: IWebXRBackgroundRemoverOptions;
  115099. /**
  115100. * The module's name
  115101. */
  115102. static readonly Name: string;
  115103. /**
  115104. * The (Babylon) version of this module.
  115105. * This is an integer representing the implementation version.
  115106. * This number does not correspond to the webxr specs version
  115107. */
  115108. static readonly Version: number;
  115109. /**
  115110. * registered observers will be triggered when the background state changes
  115111. */
  115112. onBackgroundStateChangedObservable: Observable<boolean>;
  115113. /**
  115114. * constructs a new background remover module
  115115. * @param _xrSessionManager the session manager for this module
  115116. * @param options read-only options to be used in this module
  115117. */
  115118. constructor(_xrSessionManager: WebXRSessionManager,
  115119. /**
  115120. * read-only options to be used in this module
  115121. */
  115122. options?: IWebXRBackgroundRemoverOptions);
  115123. /**
  115124. * attach this feature
  115125. * Will usually be called by the features manager
  115126. *
  115127. * @returns true if successful.
  115128. */
  115129. attach(): boolean;
  115130. /**
  115131. * detach this feature.
  115132. * Will usually be called by the features manager
  115133. *
  115134. * @returns true if successful.
  115135. */
  115136. detach(): boolean;
  115137. private _setBackgroundState;
  115138. /**
  115139. * Dispose this feature and all of the resources attached
  115140. */
  115141. dispose(): void;
  115142. }
  115143. }
  115144. declare module BABYLON {
  115145. /**
  115146. * Contains an array of blocks representing the octree
  115147. */
  115148. export interface IOctreeContainer<T> {
  115149. /**
  115150. * Blocks within the octree
  115151. */
  115152. blocks: Array<OctreeBlock<T>>;
  115153. }
  115154. /**
  115155. * Class used to store a cell in an octree
  115156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115157. */
  115158. export class OctreeBlock<T> {
  115159. /**
  115160. * Gets the content of the current block
  115161. */
  115162. entries: T[];
  115163. /**
  115164. * Gets the list of block children
  115165. */
  115166. blocks: Array<OctreeBlock<T>>;
  115167. private _depth;
  115168. private _maxDepth;
  115169. private _capacity;
  115170. private _minPoint;
  115171. private _maxPoint;
  115172. private _boundingVectors;
  115173. private _creationFunc;
  115174. /**
  115175. * Creates a new block
  115176. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  115177. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  115178. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115179. * @param depth defines the current depth of this block in the octree
  115180. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  115181. * @param creationFunc defines a callback to call when an element is added to the block
  115182. */
  115183. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  115184. /**
  115185. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115186. */
  115187. get capacity(): number;
  115188. /**
  115189. * Gets the minimum vector (in world space) of the block's bounding box
  115190. */
  115191. get minPoint(): Vector3;
  115192. /**
  115193. * Gets the maximum vector (in world space) of the block's bounding box
  115194. */
  115195. get maxPoint(): Vector3;
  115196. /**
  115197. * Add a new element to this block
  115198. * @param entry defines the element to add
  115199. */
  115200. addEntry(entry: T): void;
  115201. /**
  115202. * Remove an element from this block
  115203. * @param entry defines the element to remove
  115204. */
  115205. removeEntry(entry: T): void;
  115206. /**
  115207. * Add an array of elements to this block
  115208. * @param entries defines the array of elements to add
  115209. */
  115210. addEntries(entries: T[]): void;
  115211. /**
  115212. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  115213. * @param frustumPlanes defines the frustum planes to test
  115214. * @param selection defines the array to store current content if selection is positive
  115215. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115216. */
  115217. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115218. /**
  115219. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  115220. * @param sphereCenter defines the bounding sphere center
  115221. * @param sphereRadius defines the bounding sphere radius
  115222. * @param selection defines the array to store current content if selection is positive
  115223. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115224. */
  115225. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115226. /**
  115227. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  115228. * @param ray defines the ray to test with
  115229. * @param selection defines the array to store current content if selection is positive
  115230. */
  115231. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  115232. /**
  115233. * Subdivide the content into child blocks (this block will then be empty)
  115234. */
  115235. createInnerBlocks(): void;
  115236. /**
  115237. * @hidden
  115238. */
  115239. 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;
  115240. }
  115241. }
  115242. declare module BABYLON {
  115243. /**
  115244. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  115245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115246. */
  115247. export class Octree<T> {
  115248. /** 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.) */
  115249. maxDepth: number;
  115250. /**
  115251. * Blocks within the octree containing objects
  115252. */
  115253. blocks: Array<OctreeBlock<T>>;
  115254. /**
  115255. * Content stored in the octree
  115256. */
  115257. dynamicContent: T[];
  115258. private _maxBlockCapacity;
  115259. private _selectionContent;
  115260. private _creationFunc;
  115261. /**
  115262. * Creates a octree
  115263. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115264. * @param creationFunc function to be used to instatiate the octree
  115265. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  115266. * @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.)
  115267. */
  115268. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  115269. /** 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.) */
  115270. maxDepth?: number);
  115271. /**
  115272. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  115273. * @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);
  115274. * @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);
  115275. * @param entries meshes to be added to the octree blocks
  115276. */
  115277. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  115278. /**
  115279. * Adds a mesh to the octree
  115280. * @param entry Mesh to add to the octree
  115281. */
  115282. addMesh(entry: T): void;
  115283. /**
  115284. * Remove an element from the octree
  115285. * @param entry defines the element to remove
  115286. */
  115287. removeMesh(entry: T): void;
  115288. /**
  115289. * Selects an array of meshes within the frustum
  115290. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  115291. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  115292. * @returns array of meshes within the frustum
  115293. */
  115294. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  115295. /**
  115296. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  115297. * @param sphereCenter defines the bounding sphere center
  115298. * @param sphereRadius defines the bounding sphere radius
  115299. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115300. * @returns an array of objects that intersect the sphere
  115301. */
  115302. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  115303. /**
  115304. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  115305. * @param ray defines the ray to test with
  115306. * @returns array of intersected objects
  115307. */
  115308. intersectsRay(ray: Ray): SmartArray<T>;
  115309. /**
  115310. * Adds a mesh into the octree block if it intersects the block
  115311. */
  115312. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  115313. /**
  115314. * Adds a submesh into the octree block if it intersects the block
  115315. */
  115316. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  115317. }
  115318. }
  115319. declare module BABYLON {
  115320. interface Scene {
  115321. /**
  115322. * @hidden
  115323. * Backing Filed
  115324. */
  115325. _selectionOctree: Octree<AbstractMesh>;
  115326. /**
  115327. * Gets the octree used to boost mesh selection (picking)
  115328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115329. */
  115330. selectionOctree: Octree<AbstractMesh>;
  115331. /**
  115332. * Creates or updates the octree used to boost selection (picking)
  115333. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115334. * @param maxCapacity defines the maximum capacity per leaf
  115335. * @param maxDepth defines the maximum depth of the octree
  115336. * @returns an octree of AbstractMesh
  115337. */
  115338. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  115339. }
  115340. interface AbstractMesh {
  115341. /**
  115342. * @hidden
  115343. * Backing Field
  115344. */
  115345. _submeshesOctree: Octree<SubMesh>;
  115346. /**
  115347. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  115348. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  115349. * @param maxCapacity defines the maximum size of each block (64 by default)
  115350. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  115351. * @returns the new octree
  115352. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  115353. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115354. */
  115355. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  115356. }
  115357. /**
  115358. * Defines the octree scene component responsible to manage any octrees
  115359. * in a given scene.
  115360. */
  115361. export class OctreeSceneComponent {
  115362. /**
  115363. * The component name help to identify the component in the list of scene components.
  115364. */
  115365. readonly name: string;
  115366. /**
  115367. * The scene the component belongs to.
  115368. */
  115369. scene: Scene;
  115370. /**
  115371. * Indicates if the meshes have been checked to make sure they are isEnabled()
  115372. */
  115373. readonly checksIsEnabled: boolean;
  115374. /**
  115375. * Creates a new instance of the component for the given scene
  115376. * @param scene Defines the scene to register the component in
  115377. */
  115378. constructor(scene: Scene);
  115379. /**
  115380. * Registers the component in a given scene
  115381. */
  115382. register(): void;
  115383. /**
  115384. * Return the list of active meshes
  115385. * @returns the list of active meshes
  115386. */
  115387. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115388. /**
  115389. * Return the list of active sub meshes
  115390. * @param mesh The mesh to get the candidates sub meshes from
  115391. * @returns the list of active sub meshes
  115392. */
  115393. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115394. private _tempRay;
  115395. /**
  115396. * Return the list of sub meshes intersecting with a given local ray
  115397. * @param mesh defines the mesh to find the submesh for
  115398. * @param localRay defines the ray in local space
  115399. * @returns the list of intersecting sub meshes
  115400. */
  115401. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  115402. /**
  115403. * Return the list of sub meshes colliding with a collider
  115404. * @param mesh defines the mesh to find the submesh for
  115405. * @param collider defines the collider to evaluate the collision against
  115406. * @returns the list of colliding sub meshes
  115407. */
  115408. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  115409. /**
  115410. * Rebuilds the elements related to this component in case of
  115411. * context lost for instance.
  115412. */
  115413. rebuild(): void;
  115414. /**
  115415. * Disposes the component and the associated ressources.
  115416. */
  115417. dispose(): void;
  115418. }
  115419. }
  115420. declare module BABYLON {
  115421. /**
  115422. * Renders a layer on top of an existing scene
  115423. */
  115424. export class UtilityLayerRenderer implements IDisposable {
  115425. /** the original scene that will be rendered on top of */
  115426. originalScene: Scene;
  115427. private _pointerCaptures;
  115428. private _lastPointerEvents;
  115429. private static _DefaultUtilityLayer;
  115430. private static _DefaultKeepDepthUtilityLayer;
  115431. private _sharedGizmoLight;
  115432. private _renderCamera;
  115433. /**
  115434. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  115435. * @returns the camera that is used when rendering the utility layer
  115436. */
  115437. getRenderCamera(): Nullable<Camera>;
  115438. /**
  115439. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  115440. * @param cam the camera that should be used when rendering the utility layer
  115441. */
  115442. setRenderCamera(cam: Nullable<Camera>): void;
  115443. /**
  115444. * @hidden
  115445. * Light which used by gizmos to get light shading
  115446. */
  115447. _getSharedGizmoLight(): HemisphericLight;
  115448. /**
  115449. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  115450. */
  115451. pickUtilitySceneFirst: boolean;
  115452. /**
  115453. * 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)
  115454. */
  115455. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  115456. /**
  115457. * 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)
  115458. */
  115459. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  115460. /**
  115461. * The scene that is rendered on top of the original scene
  115462. */
  115463. utilityLayerScene: Scene;
  115464. /**
  115465. * If the utility layer should automatically be rendered on top of existing scene
  115466. */
  115467. shouldRender: boolean;
  115468. /**
  115469. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  115470. */
  115471. onlyCheckPointerDownEvents: boolean;
  115472. /**
  115473. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  115474. */
  115475. processAllEvents: boolean;
  115476. /**
  115477. * Observable raised when the pointer move from the utility layer scene to the main scene
  115478. */
  115479. onPointerOutObservable: Observable<number>;
  115480. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  115481. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  115482. private _afterRenderObserver;
  115483. private _sceneDisposeObserver;
  115484. private _originalPointerObserver;
  115485. /**
  115486. * Instantiates a UtilityLayerRenderer
  115487. * @param originalScene the original scene that will be rendered on top of
  115488. * @param handleEvents boolean indicating if the utility layer should handle events
  115489. */
  115490. constructor(
  115491. /** the original scene that will be rendered on top of */
  115492. originalScene: Scene, handleEvents?: boolean);
  115493. private _notifyObservers;
  115494. /**
  115495. * Renders the utility layers scene on top of the original scene
  115496. */
  115497. render(): void;
  115498. /**
  115499. * Disposes of the renderer
  115500. */
  115501. dispose(): void;
  115502. private _updateCamera;
  115503. }
  115504. }
  115505. declare module BABYLON {
  115506. /**
  115507. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  115508. */
  115509. export class Gizmo implements IDisposable {
  115510. /** The utility layer the gizmo will be added to */
  115511. gizmoLayer: UtilityLayerRenderer;
  115512. /**
  115513. * The root mesh of the gizmo
  115514. */
  115515. _rootMesh: Mesh;
  115516. private _attachedMesh;
  115517. /**
  115518. * Ratio for the scale of the gizmo (Default: 1)
  115519. */
  115520. scaleRatio: number;
  115521. /**
  115522. * If a custom mesh has been set (Default: false)
  115523. */
  115524. protected _customMeshSet: boolean;
  115525. /**
  115526. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  115527. * * When set, interactions will be enabled
  115528. */
  115529. get attachedMesh(): Nullable<AbstractMesh>;
  115530. set attachedMesh(value: Nullable<AbstractMesh>);
  115531. /**
  115532. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115533. * @param mesh The mesh to replace the default mesh of the gizmo
  115534. */
  115535. setCustomMesh(mesh: Mesh): void;
  115536. /**
  115537. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  115538. */
  115539. updateGizmoRotationToMatchAttachedMesh: boolean;
  115540. /**
  115541. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  115542. */
  115543. updateGizmoPositionToMatchAttachedMesh: boolean;
  115544. /**
  115545. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  115546. */
  115547. updateScale: boolean;
  115548. protected _interactionsEnabled: boolean;
  115549. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115550. private _beforeRenderObserver;
  115551. private _tempVector;
  115552. /**
  115553. * Creates a gizmo
  115554. * @param gizmoLayer The utility layer the gizmo will be added to
  115555. */
  115556. constructor(
  115557. /** The utility layer the gizmo will be added to */
  115558. gizmoLayer?: UtilityLayerRenderer);
  115559. /**
  115560. * Updates the gizmo to match the attached mesh's position/rotation
  115561. */
  115562. protected _update(): void;
  115563. /**
  115564. * Disposes of the gizmo
  115565. */
  115566. dispose(): void;
  115567. }
  115568. }
  115569. declare module BABYLON {
  115570. /**
  115571. * Single plane drag gizmo
  115572. */
  115573. export class PlaneDragGizmo extends Gizmo {
  115574. /**
  115575. * Drag behavior responsible for the gizmos dragging interactions
  115576. */
  115577. dragBehavior: PointerDragBehavior;
  115578. private _pointerObserver;
  115579. /**
  115580. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115581. */
  115582. snapDistance: number;
  115583. /**
  115584. * Event that fires each time the gizmo snaps to a new location.
  115585. * * snapDistance is the the change in distance
  115586. */
  115587. onSnapObservable: Observable<{
  115588. snapDistance: number;
  115589. }>;
  115590. private _plane;
  115591. private _coloredMaterial;
  115592. private _hoverMaterial;
  115593. private _isEnabled;
  115594. private _parent;
  115595. /** @hidden */
  115596. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  115597. /** @hidden */
  115598. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115599. /**
  115600. * Creates a PlaneDragGizmo
  115601. * @param gizmoLayer The utility layer the gizmo will be added to
  115602. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  115603. * @param color The color of the gizmo
  115604. */
  115605. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115606. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115607. /**
  115608. * If the gizmo is enabled
  115609. */
  115610. set isEnabled(value: boolean);
  115611. get isEnabled(): boolean;
  115612. /**
  115613. * Disposes of the gizmo
  115614. */
  115615. dispose(): void;
  115616. }
  115617. }
  115618. declare module BABYLON {
  115619. /**
  115620. * Gizmo that enables dragging a mesh along 3 axis
  115621. */
  115622. export class PositionGizmo extends Gizmo {
  115623. /**
  115624. * Internal gizmo used for interactions on the x axis
  115625. */
  115626. xGizmo: AxisDragGizmo;
  115627. /**
  115628. * Internal gizmo used for interactions on the y axis
  115629. */
  115630. yGizmo: AxisDragGizmo;
  115631. /**
  115632. * Internal gizmo used for interactions on the z axis
  115633. */
  115634. zGizmo: AxisDragGizmo;
  115635. /**
  115636. * Internal gizmo used for interactions on the yz plane
  115637. */
  115638. xPlaneGizmo: PlaneDragGizmo;
  115639. /**
  115640. * Internal gizmo used for interactions on the xz plane
  115641. */
  115642. yPlaneGizmo: PlaneDragGizmo;
  115643. /**
  115644. * Internal gizmo used for interactions on the xy plane
  115645. */
  115646. zPlaneGizmo: PlaneDragGizmo;
  115647. /**
  115648. * private variables
  115649. */
  115650. private _meshAttached;
  115651. private _updateGizmoRotationToMatchAttachedMesh;
  115652. private _snapDistance;
  115653. private _scaleRatio;
  115654. /** Fires an event when any of it's sub gizmos are dragged */
  115655. onDragStartObservable: Observable<unknown>;
  115656. /** Fires an event when any of it's sub gizmos are released from dragging */
  115657. onDragEndObservable: Observable<unknown>;
  115658. /**
  115659. * If set to true, planar drag is enabled
  115660. */
  115661. private _planarGizmoEnabled;
  115662. get attachedMesh(): Nullable<AbstractMesh>;
  115663. set attachedMesh(mesh: Nullable<AbstractMesh>);
  115664. /**
  115665. * Creates a PositionGizmo
  115666. * @param gizmoLayer The utility layer the gizmo will be added to
  115667. */
  115668. constructor(gizmoLayer?: UtilityLayerRenderer);
  115669. /**
  115670. * If the planar drag gizmo is enabled
  115671. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  115672. */
  115673. set planarGizmoEnabled(value: boolean);
  115674. get planarGizmoEnabled(): boolean;
  115675. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  115676. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  115677. /**
  115678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115679. */
  115680. set snapDistance(value: number);
  115681. get snapDistance(): number;
  115682. /**
  115683. * Ratio for the scale of the gizmo (Default: 1)
  115684. */
  115685. set scaleRatio(value: number);
  115686. get scaleRatio(): number;
  115687. /**
  115688. * Disposes of the gizmo
  115689. */
  115690. dispose(): void;
  115691. /**
  115692. * CustomMeshes are not supported by this gizmo
  115693. * @param mesh The mesh to replace the default mesh of the gizmo
  115694. */
  115695. setCustomMesh(mesh: Mesh): void;
  115696. }
  115697. }
  115698. declare module BABYLON {
  115699. /**
  115700. * Single axis drag gizmo
  115701. */
  115702. export class AxisDragGizmo extends Gizmo {
  115703. /**
  115704. * Drag behavior responsible for the gizmos dragging interactions
  115705. */
  115706. dragBehavior: PointerDragBehavior;
  115707. private _pointerObserver;
  115708. /**
  115709. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115710. */
  115711. snapDistance: number;
  115712. /**
  115713. * Event that fires each time the gizmo snaps to a new location.
  115714. * * snapDistance is the the change in distance
  115715. */
  115716. onSnapObservable: Observable<{
  115717. snapDistance: number;
  115718. }>;
  115719. private _isEnabled;
  115720. private _parent;
  115721. private _arrow;
  115722. private _coloredMaterial;
  115723. private _hoverMaterial;
  115724. /** @hidden */
  115725. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  115726. /** @hidden */
  115727. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115728. /**
  115729. * Creates an AxisDragGizmo
  115730. * @param gizmoLayer The utility layer the gizmo will be added to
  115731. * @param dragAxis The axis which the gizmo will be able to drag on
  115732. * @param color The color of the gizmo
  115733. */
  115734. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115735. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115736. /**
  115737. * If the gizmo is enabled
  115738. */
  115739. set isEnabled(value: boolean);
  115740. get isEnabled(): boolean;
  115741. /**
  115742. * Disposes of the gizmo
  115743. */
  115744. dispose(): void;
  115745. }
  115746. }
  115747. declare module BABYLON.Debug {
  115748. /**
  115749. * The Axes viewer will show 3 axes in a specific point in space
  115750. */
  115751. export class AxesViewer {
  115752. private _xAxis;
  115753. private _yAxis;
  115754. private _zAxis;
  115755. private _scaleLinesFactor;
  115756. private _instanced;
  115757. /**
  115758. * Gets the hosting scene
  115759. */
  115760. scene: Scene;
  115761. /**
  115762. * Gets or sets a number used to scale line length
  115763. */
  115764. scaleLines: number;
  115765. /** Gets the node hierarchy used to render x-axis */
  115766. get xAxis(): TransformNode;
  115767. /** Gets the node hierarchy used to render y-axis */
  115768. get yAxis(): TransformNode;
  115769. /** Gets the node hierarchy used to render z-axis */
  115770. get zAxis(): TransformNode;
  115771. /**
  115772. * Creates a new AxesViewer
  115773. * @param scene defines the hosting scene
  115774. * @param scaleLines defines a number used to scale line length (1 by default)
  115775. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  115776. * @param xAxis defines the node hierarchy used to render the x-axis
  115777. * @param yAxis defines the node hierarchy used to render the y-axis
  115778. * @param zAxis defines the node hierarchy used to render the z-axis
  115779. */
  115780. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  115781. /**
  115782. * Force the viewer to update
  115783. * @param position defines the position of the viewer
  115784. * @param xaxis defines the x axis of the viewer
  115785. * @param yaxis defines the y axis of the viewer
  115786. * @param zaxis defines the z axis of the viewer
  115787. */
  115788. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  115789. /**
  115790. * Creates an instance of this axes viewer.
  115791. * @returns a new axes viewer with instanced meshes
  115792. */
  115793. createInstance(): AxesViewer;
  115794. /** Releases resources */
  115795. dispose(): void;
  115796. private static _SetRenderingGroupId;
  115797. }
  115798. }
  115799. declare module BABYLON.Debug {
  115800. /**
  115801. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  115802. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  115803. */
  115804. export class BoneAxesViewer extends AxesViewer {
  115805. /**
  115806. * Gets or sets the target mesh where to display the axes viewer
  115807. */
  115808. mesh: Nullable<Mesh>;
  115809. /**
  115810. * Gets or sets the target bone where to display the axes viewer
  115811. */
  115812. bone: Nullable<Bone>;
  115813. /** Gets current position */
  115814. pos: Vector3;
  115815. /** Gets direction of X axis */
  115816. xaxis: Vector3;
  115817. /** Gets direction of Y axis */
  115818. yaxis: Vector3;
  115819. /** Gets direction of Z axis */
  115820. zaxis: Vector3;
  115821. /**
  115822. * Creates a new BoneAxesViewer
  115823. * @param scene defines the hosting scene
  115824. * @param bone defines the target bone
  115825. * @param mesh defines the target mesh
  115826. * @param scaleLines defines a scaling factor for line length (1 by default)
  115827. */
  115828. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  115829. /**
  115830. * Force the viewer to update
  115831. */
  115832. update(): void;
  115833. /** Releases resources */
  115834. dispose(): void;
  115835. }
  115836. }
  115837. declare module BABYLON {
  115838. /**
  115839. * Interface used to define scene explorer extensibility option
  115840. */
  115841. export interface IExplorerExtensibilityOption {
  115842. /**
  115843. * Define the option label
  115844. */
  115845. label: string;
  115846. /**
  115847. * Defines the action to execute on click
  115848. */
  115849. action: (entity: any) => void;
  115850. }
  115851. /**
  115852. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  115853. */
  115854. export interface IExplorerExtensibilityGroup {
  115855. /**
  115856. * Defines a predicate to test if a given type mut be extended
  115857. */
  115858. predicate: (entity: any) => boolean;
  115859. /**
  115860. * Gets the list of options added to a type
  115861. */
  115862. entries: IExplorerExtensibilityOption[];
  115863. }
  115864. /**
  115865. * Interface used to define the options to use to create the Inspector
  115866. */
  115867. export interface IInspectorOptions {
  115868. /**
  115869. * Display in overlay mode (default: false)
  115870. */
  115871. overlay?: boolean;
  115872. /**
  115873. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  115874. */
  115875. globalRoot?: HTMLElement;
  115876. /**
  115877. * Display the Scene explorer
  115878. */
  115879. showExplorer?: boolean;
  115880. /**
  115881. * Display the property inspector
  115882. */
  115883. showInspector?: boolean;
  115884. /**
  115885. * Display in embed mode (both panes on the right)
  115886. */
  115887. embedMode?: boolean;
  115888. /**
  115889. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  115890. */
  115891. handleResize?: boolean;
  115892. /**
  115893. * Allow the panes to popup (default: true)
  115894. */
  115895. enablePopup?: boolean;
  115896. /**
  115897. * Allow the panes to be closed by users (default: true)
  115898. */
  115899. enableClose?: boolean;
  115900. /**
  115901. * Optional list of extensibility entries
  115902. */
  115903. explorerExtensibility?: IExplorerExtensibilityGroup[];
  115904. /**
  115905. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  115906. */
  115907. inspectorURL?: string;
  115908. /**
  115909. * Optional initial tab (default to DebugLayerTab.Properties)
  115910. */
  115911. initialTab?: DebugLayerTab;
  115912. }
  115913. interface Scene {
  115914. /**
  115915. * @hidden
  115916. * Backing field
  115917. */
  115918. _debugLayer: DebugLayer;
  115919. /**
  115920. * Gets the debug layer (aka Inspector) associated with the scene
  115921. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115922. */
  115923. debugLayer: DebugLayer;
  115924. }
  115925. /**
  115926. * Enum of inspector action tab
  115927. */
  115928. export enum DebugLayerTab {
  115929. /**
  115930. * Properties tag (default)
  115931. */
  115932. Properties = 0,
  115933. /**
  115934. * Debug tab
  115935. */
  115936. Debug = 1,
  115937. /**
  115938. * Statistics tab
  115939. */
  115940. Statistics = 2,
  115941. /**
  115942. * Tools tab
  115943. */
  115944. Tools = 3,
  115945. /**
  115946. * Settings tab
  115947. */
  115948. Settings = 4
  115949. }
  115950. /**
  115951. * The debug layer (aka Inspector) is the go to tool in order to better understand
  115952. * what is happening in your scene
  115953. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115954. */
  115955. export class DebugLayer {
  115956. /**
  115957. * Define the url to get the inspector script from.
  115958. * By default it uses the babylonjs CDN.
  115959. * @ignoreNaming
  115960. */
  115961. static InspectorURL: string;
  115962. private _scene;
  115963. private BJSINSPECTOR;
  115964. private _onPropertyChangedObservable?;
  115965. /**
  115966. * Observable triggered when a property is changed through the inspector.
  115967. */
  115968. get onPropertyChangedObservable(): any;
  115969. /**
  115970. * Instantiates a new debug layer.
  115971. * The debug layer (aka Inspector) is the go to tool in order to better understand
  115972. * what is happening in your scene
  115973. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115974. * @param scene Defines the scene to inspect
  115975. */
  115976. constructor(scene: Scene);
  115977. /** Creates the inspector window. */
  115978. private _createInspector;
  115979. /**
  115980. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  115981. * @param entity defines the entity to select
  115982. * @param lineContainerTitle defines the specific block to highlight
  115983. */
  115984. select(entity: any, lineContainerTitle?: string): void;
  115985. /** Get the inspector from bundle or global */
  115986. private _getGlobalInspector;
  115987. /**
  115988. * Get if the inspector is visible or not.
  115989. * @returns true if visible otherwise, false
  115990. */
  115991. isVisible(): boolean;
  115992. /**
  115993. * Hide the inspector and close its window.
  115994. */
  115995. hide(): void;
  115996. /**
  115997. * Launch the debugLayer.
  115998. * @param config Define the configuration of the inspector
  115999. * @return a promise fulfilled when the debug layer is visible
  116000. */
  116001. show(config?: IInspectorOptions): Promise<DebugLayer>;
  116002. }
  116003. }
  116004. declare module BABYLON {
  116005. /**
  116006. * Class containing static functions to help procedurally build meshes
  116007. */
  116008. export class BoxBuilder {
  116009. /**
  116010. * Creates a box mesh
  116011. * * The parameter `size` sets the size (float) of each box side (default 1)
  116012. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  116013. * * 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)
  116014. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116018. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116019. * @param name defines the name of the mesh
  116020. * @param options defines the options used to create the mesh
  116021. * @param scene defines the hosting scene
  116022. * @returns the box mesh
  116023. */
  116024. static CreateBox(name: string, options: {
  116025. size?: number;
  116026. width?: number;
  116027. height?: number;
  116028. depth?: number;
  116029. faceUV?: Vector4[];
  116030. faceColors?: Color4[];
  116031. sideOrientation?: number;
  116032. frontUVs?: Vector4;
  116033. backUVs?: Vector4;
  116034. wrap?: boolean;
  116035. topBaseAt?: number;
  116036. bottomBaseAt?: number;
  116037. updatable?: boolean;
  116038. }, scene?: Nullable<Scene>): Mesh;
  116039. }
  116040. }
  116041. declare module BABYLON {
  116042. /**
  116043. * Class containing static functions to help procedurally build meshes
  116044. */
  116045. export class SphereBuilder {
  116046. /**
  116047. * Creates a sphere mesh
  116048. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116049. * * 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`)
  116050. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116051. * * 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
  116052. * * 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)
  116053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116056. * @param name defines the name of the mesh
  116057. * @param options defines the options used to create the mesh
  116058. * @param scene defines the hosting scene
  116059. * @returns the sphere mesh
  116060. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116061. */
  116062. static CreateSphere(name: string, options: {
  116063. segments?: number;
  116064. diameter?: number;
  116065. diameterX?: number;
  116066. diameterY?: number;
  116067. diameterZ?: number;
  116068. arc?: number;
  116069. slice?: number;
  116070. sideOrientation?: number;
  116071. frontUVs?: Vector4;
  116072. backUVs?: Vector4;
  116073. updatable?: boolean;
  116074. }, scene?: Nullable<Scene>): Mesh;
  116075. }
  116076. }
  116077. declare module BABYLON.Debug {
  116078. /**
  116079. * Used to show the physics impostor around the specific mesh
  116080. */
  116081. export class PhysicsViewer {
  116082. /** @hidden */
  116083. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  116084. /** @hidden */
  116085. protected _meshes: Array<Nullable<AbstractMesh>>;
  116086. /** @hidden */
  116087. protected _scene: Nullable<Scene>;
  116088. /** @hidden */
  116089. protected _numMeshes: number;
  116090. /** @hidden */
  116091. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  116092. private _renderFunction;
  116093. private _utilityLayer;
  116094. private _debugBoxMesh;
  116095. private _debugSphereMesh;
  116096. private _debugCylinderMesh;
  116097. private _debugMaterial;
  116098. private _debugMeshMeshes;
  116099. /**
  116100. * Creates a new PhysicsViewer
  116101. * @param scene defines the hosting scene
  116102. */
  116103. constructor(scene: Scene);
  116104. /** @hidden */
  116105. protected _updateDebugMeshes(): void;
  116106. /**
  116107. * Renders a specified physic impostor
  116108. * @param impostor defines the impostor to render
  116109. * @param targetMesh defines the mesh represented by the impostor
  116110. * @returns the new debug mesh used to render the impostor
  116111. */
  116112. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  116113. /**
  116114. * Hides a specified physic impostor
  116115. * @param impostor defines the impostor to hide
  116116. */
  116117. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  116118. private _getDebugMaterial;
  116119. private _getDebugBoxMesh;
  116120. private _getDebugSphereMesh;
  116121. private _getDebugCylinderMesh;
  116122. private _getDebugMeshMesh;
  116123. private _getDebugMesh;
  116124. /** Releases all resources */
  116125. dispose(): void;
  116126. }
  116127. }
  116128. declare module BABYLON {
  116129. /**
  116130. * Class containing static functions to help procedurally build meshes
  116131. */
  116132. export class LinesBuilder {
  116133. /**
  116134. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116135. * * 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
  116136. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116137. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116138. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116139. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116140. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116141. * * 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
  116142. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116145. * @param name defines the name of the new line system
  116146. * @param options defines the options used to create the line system
  116147. * @param scene defines the hosting scene
  116148. * @returns a new line system mesh
  116149. */
  116150. static CreateLineSystem(name: string, options: {
  116151. lines: Vector3[][];
  116152. updatable?: boolean;
  116153. instance?: Nullable<LinesMesh>;
  116154. colors?: Nullable<Color4[][]>;
  116155. useVertexAlpha?: boolean;
  116156. }, scene: Nullable<Scene>): LinesMesh;
  116157. /**
  116158. * Creates a line mesh
  116159. * 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
  116160. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116161. * * The parameter `points` is an array successive Vector3
  116162. * * 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
  116163. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116164. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116165. * * When updating an instance, remember that only point positions can change, not the number of points
  116166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116168. * @param name defines the name of the new line system
  116169. * @param options defines the options used to create the line system
  116170. * @param scene defines the hosting scene
  116171. * @returns a new line mesh
  116172. */
  116173. static CreateLines(name: string, options: {
  116174. points: Vector3[];
  116175. updatable?: boolean;
  116176. instance?: Nullable<LinesMesh>;
  116177. colors?: Color4[];
  116178. useVertexAlpha?: boolean;
  116179. }, scene?: Nullable<Scene>): LinesMesh;
  116180. /**
  116181. * Creates a dashed line mesh
  116182. * * 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
  116183. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116184. * * The parameter `points` is an array successive Vector3
  116185. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116186. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116187. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116188. * * 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
  116189. * * When updating an instance, remember that only point positions can change, not the number of points
  116190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116191. * @param name defines the name of the mesh
  116192. * @param options defines the options used to create the mesh
  116193. * @param scene defines the hosting scene
  116194. * @returns the dashed line mesh
  116195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116196. */
  116197. static CreateDashedLines(name: string, options: {
  116198. points: Vector3[];
  116199. dashSize?: number;
  116200. gapSize?: number;
  116201. dashNb?: number;
  116202. updatable?: boolean;
  116203. instance?: LinesMesh;
  116204. }, scene?: Nullable<Scene>): LinesMesh;
  116205. }
  116206. }
  116207. declare module BABYLON {
  116208. /**
  116209. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116210. * in order to better appreciate the issue one might have.
  116211. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116212. */
  116213. export class RayHelper {
  116214. /**
  116215. * Defines the ray we are currently tryin to visualize.
  116216. */
  116217. ray: Nullable<Ray>;
  116218. private _renderPoints;
  116219. private _renderLine;
  116220. private _renderFunction;
  116221. private _scene;
  116222. private _updateToMeshFunction;
  116223. private _attachedToMesh;
  116224. private _meshSpaceDirection;
  116225. private _meshSpaceOrigin;
  116226. /**
  116227. * Helper function to create a colored helper in a scene in one line.
  116228. * @param ray Defines the ray we are currently tryin to visualize
  116229. * @param scene Defines the scene the ray is used in
  116230. * @param color Defines the color we want to see the ray in
  116231. * @returns The newly created ray helper.
  116232. */
  116233. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  116234. /**
  116235. * Instantiate a new ray helper.
  116236. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116237. * in order to better appreciate the issue one might have.
  116238. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116239. * @param ray Defines the ray we are currently tryin to visualize
  116240. */
  116241. constructor(ray: Ray);
  116242. /**
  116243. * Shows the ray we are willing to debug.
  116244. * @param scene Defines the scene the ray needs to be rendered in
  116245. * @param color Defines the color the ray needs to be rendered in
  116246. */
  116247. show(scene: Scene, color?: Color3): void;
  116248. /**
  116249. * Hides the ray we are debugging.
  116250. */
  116251. hide(): void;
  116252. private _render;
  116253. /**
  116254. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  116255. * @param mesh Defines the mesh we want the helper attached to
  116256. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  116257. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  116258. * @param length Defines the length of the ray
  116259. */
  116260. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  116261. /**
  116262. * Detach the ray helper from the mesh it has previously been attached to.
  116263. */
  116264. detachFromMesh(): void;
  116265. private _updateToMesh;
  116266. /**
  116267. * Dispose the helper and release its associated resources.
  116268. */
  116269. dispose(): void;
  116270. }
  116271. }
  116272. declare module BABYLON.Debug {
  116273. /**
  116274. * Class used to render a debug view of a given skeleton
  116275. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  116276. */
  116277. export class SkeletonViewer {
  116278. /** defines the skeleton to render */
  116279. skeleton: Skeleton;
  116280. /** defines the mesh attached to the skeleton */
  116281. mesh: AbstractMesh;
  116282. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116283. autoUpdateBonesMatrices: boolean;
  116284. /** defines the rendering group id to use with the viewer */
  116285. renderingGroupId: number;
  116286. /** Gets or sets the color used to render the skeleton */
  116287. color: Color3;
  116288. private _scene;
  116289. private _debugLines;
  116290. private _debugMesh;
  116291. private _isEnabled;
  116292. private _renderFunction;
  116293. private _utilityLayer;
  116294. /**
  116295. * Returns the mesh used to render the bones
  116296. */
  116297. get debugMesh(): Nullable<LinesMesh>;
  116298. /**
  116299. * Creates a new SkeletonViewer
  116300. * @param skeleton defines the skeleton to render
  116301. * @param mesh defines the mesh attached to the skeleton
  116302. * @param scene defines the hosting scene
  116303. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  116304. * @param renderingGroupId defines the rendering group id to use with the viewer
  116305. */
  116306. constructor(
  116307. /** defines the skeleton to render */
  116308. skeleton: Skeleton,
  116309. /** defines the mesh attached to the skeleton */
  116310. mesh: AbstractMesh, scene: Scene,
  116311. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116312. autoUpdateBonesMatrices?: boolean,
  116313. /** defines the rendering group id to use with the viewer */
  116314. renderingGroupId?: number);
  116315. /** Gets or sets a boolean indicating if the viewer is enabled */
  116316. set isEnabled(value: boolean);
  116317. get isEnabled(): boolean;
  116318. private _getBonePosition;
  116319. private _getLinesForBonesWithLength;
  116320. private _getLinesForBonesNoLength;
  116321. /** Update the viewer to sync with current skeleton state */
  116322. update(): void;
  116323. /** Release associated resources */
  116324. dispose(): void;
  116325. }
  116326. }
  116327. declare module BABYLON {
  116328. /**
  116329. * Options to create the null engine
  116330. */
  116331. export class NullEngineOptions {
  116332. /**
  116333. * Render width (Default: 512)
  116334. */
  116335. renderWidth: number;
  116336. /**
  116337. * Render height (Default: 256)
  116338. */
  116339. renderHeight: number;
  116340. /**
  116341. * Texture size (Default: 512)
  116342. */
  116343. textureSize: number;
  116344. /**
  116345. * If delta time between frames should be constant
  116346. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116347. */
  116348. deterministicLockstep: boolean;
  116349. /**
  116350. * Maximum about of steps between frames (Default: 4)
  116351. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116352. */
  116353. lockstepMaxSteps: number;
  116354. }
  116355. /**
  116356. * The null engine class provides support for headless version of babylon.js.
  116357. * This can be used in server side scenario or for testing purposes
  116358. */
  116359. export class NullEngine extends Engine {
  116360. private _options;
  116361. /**
  116362. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116363. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116364. * @returns true if engine is in deterministic lock step mode
  116365. */
  116366. isDeterministicLockStep(): boolean;
  116367. /**
  116368. * Gets the max steps when engine is running in deterministic lock step
  116369. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116370. * @returns the max steps
  116371. */
  116372. getLockstepMaxSteps(): number;
  116373. /**
  116374. * Gets the current hardware scaling level.
  116375. * By default the hardware scaling level is computed from the window device ratio.
  116376. * 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.
  116377. * @returns a number indicating the current hardware scaling level
  116378. */
  116379. getHardwareScalingLevel(): number;
  116380. constructor(options?: NullEngineOptions);
  116381. /**
  116382. * Creates a vertex buffer
  116383. * @param vertices the data for the vertex buffer
  116384. * @returns the new WebGL static buffer
  116385. */
  116386. createVertexBuffer(vertices: FloatArray): DataBuffer;
  116387. /**
  116388. * Creates a new index buffer
  116389. * @param indices defines the content of the index buffer
  116390. * @param updatable defines if the index buffer must be updatable
  116391. * @returns a new webGL buffer
  116392. */
  116393. createIndexBuffer(indices: IndicesArray): DataBuffer;
  116394. /**
  116395. * Clear the current render buffer or the current render target (if any is set up)
  116396. * @param color defines the color to use
  116397. * @param backBuffer defines if the back buffer must be cleared
  116398. * @param depth defines if the depth buffer must be cleared
  116399. * @param stencil defines if the stencil buffer must be cleared
  116400. */
  116401. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116402. /**
  116403. * Gets the current render width
  116404. * @param useScreen defines if screen size must be used (or the current render target if any)
  116405. * @returns a number defining the current render width
  116406. */
  116407. getRenderWidth(useScreen?: boolean): number;
  116408. /**
  116409. * Gets the current render height
  116410. * @param useScreen defines if screen size must be used (or the current render target if any)
  116411. * @returns a number defining the current render height
  116412. */
  116413. getRenderHeight(useScreen?: boolean): number;
  116414. /**
  116415. * Set the WebGL's viewport
  116416. * @param viewport defines the viewport element to be used
  116417. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116418. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116419. */
  116420. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116421. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  116422. /**
  116423. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116424. * @param pipelineContext defines the pipeline context to use
  116425. * @param uniformsNames defines the list of uniform names
  116426. * @returns an array of webGL uniform locations
  116427. */
  116428. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116429. /**
  116430. * Gets the lsit of active attributes for a given webGL program
  116431. * @param pipelineContext defines the pipeline context to use
  116432. * @param attributesNames defines the list of attribute names to get
  116433. * @returns an array of indices indicating the offset of each attribute
  116434. */
  116435. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116436. /**
  116437. * Binds an effect to the webGL context
  116438. * @param effect defines the effect to bind
  116439. */
  116440. bindSamplers(effect: Effect): void;
  116441. /**
  116442. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116443. * @param effect defines the effect to activate
  116444. */
  116445. enableEffect(effect: Effect): void;
  116446. /**
  116447. * Set various states to the webGL context
  116448. * @param culling defines backface culling state
  116449. * @param zOffset defines the value to apply to zOffset (0 by default)
  116450. * @param force defines if states must be applied even if cache is up to date
  116451. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116452. */
  116453. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116454. /**
  116455. * Set the value of an uniform to an array of int32
  116456. * @param uniform defines the webGL uniform location where to store the value
  116457. * @param array defines the array of int32 to store
  116458. */
  116459. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  116460. /**
  116461. * Set the value of an uniform to an array of int32 (stored as vec2)
  116462. * @param uniform defines the webGL uniform location where to store the value
  116463. * @param array defines the array of int32 to store
  116464. */
  116465. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  116466. /**
  116467. * Set the value of an uniform to an array of int32 (stored as vec3)
  116468. * @param uniform defines the webGL uniform location where to store the value
  116469. * @param array defines the array of int32 to store
  116470. */
  116471. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  116472. /**
  116473. * Set the value of an uniform to an array of int32 (stored as vec4)
  116474. * @param uniform defines the webGL uniform location where to store the value
  116475. * @param array defines the array of int32 to store
  116476. */
  116477. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  116478. /**
  116479. * Set the value of an uniform to an array of float32
  116480. * @param uniform defines the webGL uniform location where to store the value
  116481. * @param array defines the array of float32 to store
  116482. */
  116483. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  116484. /**
  116485. * Set the value of an uniform to an array of float32 (stored as vec2)
  116486. * @param uniform defines the webGL uniform location where to store the value
  116487. * @param array defines the array of float32 to store
  116488. */
  116489. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  116490. /**
  116491. * Set the value of an uniform to an array of float32 (stored as vec3)
  116492. * @param uniform defines the webGL uniform location where to store the value
  116493. * @param array defines the array of float32 to store
  116494. */
  116495. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  116496. /**
  116497. * Set the value of an uniform to an array of float32 (stored as vec4)
  116498. * @param uniform defines the webGL uniform location where to store the value
  116499. * @param array defines the array of float32 to store
  116500. */
  116501. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  116502. /**
  116503. * Set the value of an uniform to an array of number
  116504. * @param uniform defines the webGL uniform location where to store the value
  116505. * @param array defines the array of number to store
  116506. */
  116507. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  116508. /**
  116509. * Set the value of an uniform to an array of number (stored as vec2)
  116510. * @param uniform defines the webGL uniform location where to store the value
  116511. * @param array defines the array of number to store
  116512. */
  116513. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  116514. /**
  116515. * Set the value of an uniform to an array of number (stored as vec3)
  116516. * @param uniform defines the webGL uniform location where to store the value
  116517. * @param array defines the array of number to store
  116518. */
  116519. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  116520. /**
  116521. * Set the value of an uniform to an array of number (stored as vec4)
  116522. * @param uniform defines the webGL uniform location where to store the value
  116523. * @param array defines the array of number to store
  116524. */
  116525. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  116526. /**
  116527. * Set the value of an uniform to an array of float32 (stored as matrices)
  116528. * @param uniform defines the webGL uniform location where to store the value
  116529. * @param matrices defines the array of float32 to store
  116530. */
  116531. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  116532. /**
  116533. * Set the value of an uniform to a matrix (3x3)
  116534. * @param uniform defines the webGL uniform location where to store the value
  116535. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116536. */
  116537. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116538. /**
  116539. * Set the value of an uniform to a matrix (2x2)
  116540. * @param uniform defines the webGL uniform location where to store the value
  116541. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116542. */
  116543. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116544. /**
  116545. * Set the value of an uniform to a number (float)
  116546. * @param uniform defines the webGL uniform location where to store the value
  116547. * @param value defines the float number to store
  116548. */
  116549. setFloat(uniform: WebGLUniformLocation, value: number): void;
  116550. /**
  116551. * Set the value of an uniform to a vec2
  116552. * @param uniform defines the webGL uniform location where to store the value
  116553. * @param x defines the 1st component of the value
  116554. * @param y defines the 2nd component of the value
  116555. */
  116556. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  116557. /**
  116558. * Set the value of an uniform to a vec3
  116559. * @param uniform defines the webGL uniform location where to store the value
  116560. * @param x defines the 1st component of the value
  116561. * @param y defines the 2nd component of the value
  116562. * @param z defines the 3rd component of the value
  116563. */
  116564. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  116565. /**
  116566. * Set the value of an uniform to a boolean
  116567. * @param uniform defines the webGL uniform location where to store the value
  116568. * @param bool defines the boolean to store
  116569. */
  116570. setBool(uniform: WebGLUniformLocation, bool: number): void;
  116571. /**
  116572. * Set the value of an uniform to a vec4
  116573. * @param uniform defines the webGL uniform location where to store the value
  116574. * @param x defines the 1st component of the value
  116575. * @param y defines the 2nd component of the value
  116576. * @param z defines the 3rd component of the value
  116577. * @param w defines the 4th component of the value
  116578. */
  116579. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  116580. /**
  116581. * Sets the current alpha mode
  116582. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116583. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116584. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116585. */
  116586. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116587. /**
  116588. * Bind webGl buffers directly to the webGL context
  116589. * @param vertexBuffers defines the vertex buffer to bind
  116590. * @param indexBuffer defines the index buffer to bind
  116591. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116592. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116593. * @param effect defines the effect associated with the vertex buffer
  116594. */
  116595. bindBuffers(vertexBuffers: {
  116596. [key: string]: VertexBuffer;
  116597. }, indexBuffer: DataBuffer, effect: Effect): void;
  116598. /**
  116599. * Force the entire cache to be cleared
  116600. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116601. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116602. */
  116603. wipeCaches(bruteForce?: boolean): void;
  116604. /**
  116605. * Send a draw order
  116606. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116607. * @param indexStart defines the starting index
  116608. * @param indexCount defines the number of index to draw
  116609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116610. */
  116611. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116612. /**
  116613. * Draw a list of indexed primitives
  116614. * @param fillMode defines the primitive to use
  116615. * @param indexStart defines the starting index
  116616. * @param indexCount defines the number of index to draw
  116617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116618. */
  116619. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116620. /**
  116621. * Draw a list of unindexed primitives
  116622. * @param fillMode defines the primitive to use
  116623. * @param verticesStart defines the index of first vertex to draw
  116624. * @param verticesCount defines the count of vertices to draw
  116625. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116626. */
  116627. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116628. /** @hidden */
  116629. _createTexture(): WebGLTexture;
  116630. /** @hidden */
  116631. _releaseTexture(texture: InternalTexture): void;
  116632. /**
  116633. * Usually called from Texture.ts.
  116634. * Passed information to create a WebGLTexture
  116635. * @param urlArg defines a value which contains one of the following:
  116636. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116637. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116638. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116640. * @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)
  116641. * @param scene needed for loading to the correct scene
  116642. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116643. * @param onLoad optional callback to be called upon successful completion
  116644. * @param onError optional callback to be called upon failure
  116645. * @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
  116646. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116647. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116648. * @param forcedExtension defines the extension to use to pick the right loader
  116649. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  116650. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116651. */
  116652. 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;
  116653. /**
  116654. * Creates a new render target texture
  116655. * @param size defines the size of the texture
  116656. * @param options defines the options used to create the texture
  116657. * @returns a new render target texture stored in an InternalTexture
  116658. */
  116659. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  116660. /**
  116661. * Update the sampling mode of a given texture
  116662. * @param samplingMode defines the required sampling mode
  116663. * @param texture defines the texture to update
  116664. */
  116665. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  116666. /**
  116667. * Binds the frame buffer to the specified texture.
  116668. * @param texture The texture to render to or null for the default canvas
  116669. * @param faceIndex The face of the texture to render to in case of cube texture
  116670. * @param requiredWidth The width of the target to render to
  116671. * @param requiredHeight The height of the target to render to
  116672. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116673. * @param depthStencilTexture The depth stencil texture to use to render
  116674. * @param lodLevel defines le lod level to bind to the frame buffer
  116675. */
  116676. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  116677. /**
  116678. * Unbind the current render target texture from the webGL context
  116679. * @param texture defines the render target texture to unbind
  116680. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116681. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116682. */
  116683. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116684. /**
  116685. * Creates a dynamic vertex buffer
  116686. * @param vertices the data for the dynamic vertex buffer
  116687. * @returns the new WebGL dynamic buffer
  116688. */
  116689. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  116690. /**
  116691. * Update the content of a dynamic texture
  116692. * @param texture defines the texture to update
  116693. * @param canvas defines the canvas containing the source
  116694. * @param invertY defines if data must be stored with Y axis inverted
  116695. * @param premulAlpha defines if alpha is stored as premultiplied
  116696. * @param format defines the format of the data
  116697. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  116698. */
  116699. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  116700. /**
  116701. * Gets a boolean indicating if all created effects are ready
  116702. * @returns true if all effects are ready
  116703. */
  116704. areAllEffectsReady(): boolean;
  116705. /**
  116706. * @hidden
  116707. * Get the current error code of the webGL context
  116708. * @returns the error code
  116709. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116710. */
  116711. getError(): number;
  116712. /** @hidden */
  116713. _getUnpackAlignement(): number;
  116714. /** @hidden */
  116715. _unpackFlipY(value: boolean): void;
  116716. /**
  116717. * Update a dynamic index buffer
  116718. * @param indexBuffer defines the target index buffer
  116719. * @param indices defines the data to update
  116720. * @param offset defines the offset in the target index buffer where update should start
  116721. */
  116722. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  116723. /**
  116724. * Updates a dynamic vertex buffer.
  116725. * @param vertexBuffer the vertex buffer to update
  116726. * @param vertices the data used to update the vertex buffer
  116727. * @param byteOffset the byte offset of the data (optional)
  116728. * @param byteLength the byte length of the data (optional)
  116729. */
  116730. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  116731. /** @hidden */
  116732. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  116733. /** @hidden */
  116734. _bindTexture(channel: number, texture: InternalTexture): void;
  116735. protected _deleteBuffer(buffer: WebGLBuffer): void;
  116736. /**
  116737. * 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
  116738. */
  116739. releaseEffects(): void;
  116740. displayLoadingUI(): void;
  116741. hideLoadingUI(): void;
  116742. /** @hidden */
  116743. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116744. /** @hidden */
  116745. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116746. /** @hidden */
  116747. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116748. /** @hidden */
  116749. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  116750. }
  116751. }
  116752. declare module BABYLON {
  116753. /** @hidden */
  116754. export class _OcclusionDataStorage {
  116755. /** @hidden */
  116756. occlusionInternalRetryCounter: number;
  116757. /** @hidden */
  116758. isOcclusionQueryInProgress: boolean;
  116759. /** @hidden */
  116760. isOccluded: boolean;
  116761. /** @hidden */
  116762. occlusionRetryCount: number;
  116763. /** @hidden */
  116764. occlusionType: number;
  116765. /** @hidden */
  116766. occlusionQueryAlgorithmType: number;
  116767. }
  116768. interface Engine {
  116769. /**
  116770. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  116771. * @return the new query
  116772. */
  116773. createQuery(): WebGLQuery;
  116774. /**
  116775. * Delete and release a webGL query
  116776. * @param query defines the query to delete
  116777. * @return the current engine
  116778. */
  116779. deleteQuery(query: WebGLQuery): Engine;
  116780. /**
  116781. * Check if a given query has resolved and got its value
  116782. * @param query defines the query to check
  116783. * @returns true if the query got its value
  116784. */
  116785. isQueryResultAvailable(query: WebGLQuery): boolean;
  116786. /**
  116787. * Gets the value of a given query
  116788. * @param query defines the query to check
  116789. * @returns the value of the query
  116790. */
  116791. getQueryResult(query: WebGLQuery): number;
  116792. /**
  116793. * Initiates an occlusion query
  116794. * @param algorithmType defines the algorithm to use
  116795. * @param query defines the query to use
  116796. * @returns the current engine
  116797. * @see http://doc.babylonjs.com/features/occlusionquery
  116798. */
  116799. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  116800. /**
  116801. * Ends an occlusion query
  116802. * @see http://doc.babylonjs.com/features/occlusionquery
  116803. * @param algorithmType defines the algorithm to use
  116804. * @returns the current engine
  116805. */
  116806. endOcclusionQuery(algorithmType: number): Engine;
  116807. /**
  116808. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  116809. * Please note that only one query can be issued at a time
  116810. * @returns a time token used to track the time span
  116811. */
  116812. startTimeQuery(): Nullable<_TimeToken>;
  116813. /**
  116814. * Ends a time query
  116815. * @param token defines the token used to measure the time span
  116816. * @returns the time spent (in ns)
  116817. */
  116818. endTimeQuery(token: _TimeToken): int;
  116819. /** @hidden */
  116820. _currentNonTimestampToken: Nullable<_TimeToken>;
  116821. /** @hidden */
  116822. _createTimeQuery(): WebGLQuery;
  116823. /** @hidden */
  116824. _deleteTimeQuery(query: WebGLQuery): void;
  116825. /** @hidden */
  116826. _getGlAlgorithmType(algorithmType: number): number;
  116827. /** @hidden */
  116828. _getTimeQueryResult(query: WebGLQuery): any;
  116829. /** @hidden */
  116830. _getTimeQueryAvailability(query: WebGLQuery): any;
  116831. }
  116832. interface AbstractMesh {
  116833. /**
  116834. * Backing filed
  116835. * @hidden
  116836. */
  116837. __occlusionDataStorage: _OcclusionDataStorage;
  116838. /**
  116839. * Access property
  116840. * @hidden
  116841. */
  116842. _occlusionDataStorage: _OcclusionDataStorage;
  116843. /**
  116844. * 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.
  116845. * The default value is -1 which means don't break the query and wait till the result
  116846. * @see http://doc.babylonjs.com/features/occlusionquery
  116847. */
  116848. occlusionRetryCount: number;
  116849. /**
  116850. * 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:
  116851. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  116852. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  116853. * * 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.
  116854. * @see http://doc.babylonjs.com/features/occlusionquery
  116855. */
  116856. occlusionType: number;
  116857. /**
  116858. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  116859. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  116860. * * 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.
  116861. * @see http://doc.babylonjs.com/features/occlusionquery
  116862. */
  116863. occlusionQueryAlgorithmType: number;
  116864. /**
  116865. * 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
  116866. * @see http://doc.babylonjs.com/features/occlusionquery
  116867. */
  116868. isOccluded: boolean;
  116869. /**
  116870. * Flag to check the progress status of the query
  116871. * @see http://doc.babylonjs.com/features/occlusionquery
  116872. */
  116873. isOcclusionQueryInProgress: boolean;
  116874. }
  116875. }
  116876. declare module BABYLON {
  116877. /** @hidden */
  116878. export var _forceTransformFeedbackToBundle: boolean;
  116879. interface Engine {
  116880. /**
  116881. * Creates a webGL transform feedback object
  116882. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  116883. * @returns the webGL transform feedback object
  116884. */
  116885. createTransformFeedback(): WebGLTransformFeedback;
  116886. /**
  116887. * Delete a webGL transform feedback object
  116888. * @param value defines the webGL transform feedback object to delete
  116889. */
  116890. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  116891. /**
  116892. * Bind a webGL transform feedback object to the webgl context
  116893. * @param value defines the webGL transform feedback object to bind
  116894. */
  116895. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  116896. /**
  116897. * Begins a transform feedback operation
  116898. * @param usePoints defines if points or triangles must be used
  116899. */
  116900. beginTransformFeedback(usePoints: boolean): void;
  116901. /**
  116902. * Ends a transform feedback operation
  116903. */
  116904. endTransformFeedback(): void;
  116905. /**
  116906. * Specify the varyings to use with transform feedback
  116907. * @param program defines the associated webGL program
  116908. * @param value defines the list of strings representing the varying names
  116909. */
  116910. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  116911. /**
  116912. * Bind a webGL buffer for a transform feedback operation
  116913. * @param value defines the webGL buffer to bind
  116914. */
  116915. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  116916. }
  116917. }
  116918. declare module BABYLON {
  116919. /**
  116920. * Creation options of the multi render target texture.
  116921. */
  116922. export interface IMultiRenderTargetOptions {
  116923. /**
  116924. * Define if the texture needs to create mip maps after render.
  116925. */
  116926. generateMipMaps?: boolean;
  116927. /**
  116928. * Define the types of all the draw buffers we want to create
  116929. */
  116930. types?: number[];
  116931. /**
  116932. * Define the sampling modes of all the draw buffers we want to create
  116933. */
  116934. samplingModes?: number[];
  116935. /**
  116936. * Define if a depth buffer is required
  116937. */
  116938. generateDepthBuffer?: boolean;
  116939. /**
  116940. * Define if a stencil buffer is required
  116941. */
  116942. generateStencilBuffer?: boolean;
  116943. /**
  116944. * Define if a depth texture is required instead of a depth buffer
  116945. */
  116946. generateDepthTexture?: boolean;
  116947. /**
  116948. * Define the number of desired draw buffers
  116949. */
  116950. textureCount?: number;
  116951. /**
  116952. * Define if aspect ratio should be adapted to the texture or stay the scene one
  116953. */
  116954. doNotChangeAspectRatio?: boolean;
  116955. /**
  116956. * Define the default type of the buffers we are creating
  116957. */
  116958. defaultType?: number;
  116959. }
  116960. /**
  116961. * A multi render target, like a render target provides the ability to render to a texture.
  116962. * Unlike the render target, it can render to several draw buffers in one draw.
  116963. * This is specially interesting in deferred rendering or for any effects requiring more than
  116964. * just one color from a single pass.
  116965. */
  116966. export class MultiRenderTarget extends RenderTargetTexture {
  116967. private _internalTextures;
  116968. private _textures;
  116969. private _multiRenderTargetOptions;
  116970. /**
  116971. * Get if draw buffers are currently supported by the used hardware and browser.
  116972. */
  116973. get isSupported(): boolean;
  116974. /**
  116975. * Get the list of textures generated by the multi render target.
  116976. */
  116977. get textures(): Texture[];
  116978. /**
  116979. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  116980. */
  116981. get depthTexture(): Texture;
  116982. /**
  116983. * Set the wrapping mode on U of all the textures we are rendering to.
  116984. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  116985. */
  116986. set wrapU(wrap: number);
  116987. /**
  116988. * Set the wrapping mode on V of all the textures we are rendering to.
  116989. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  116990. */
  116991. set wrapV(wrap: number);
  116992. /**
  116993. * Instantiate a new multi render target texture.
  116994. * A multi render target, like a render target provides the ability to render to a texture.
  116995. * Unlike the render target, it can render to several draw buffers in one draw.
  116996. * This is specially interesting in deferred rendering or for any effects requiring more than
  116997. * just one color from a single pass.
  116998. * @param name Define the name of the texture
  116999. * @param size Define the size of the buffers to render to
  117000. * @param count Define the number of target we are rendering into
  117001. * @param scene Define the scene the texture belongs to
  117002. * @param options Define the options used to create the multi render target
  117003. */
  117004. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  117005. /** @hidden */
  117006. _rebuild(): void;
  117007. private _createInternalTextures;
  117008. private _createTextures;
  117009. /**
  117010. * Define the number of samples used if MSAA is enabled.
  117011. */
  117012. get samples(): number;
  117013. set samples(value: number);
  117014. /**
  117015. * Resize all the textures in the multi render target.
  117016. * Be carrefull as it will recreate all the data in the new texture.
  117017. * @param size Define the new size
  117018. */
  117019. resize(size: any): void;
  117020. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  117021. /**
  117022. * Dispose the render targets and their associated resources
  117023. */
  117024. dispose(): void;
  117025. /**
  117026. * Release all the underlying texture used as draw buffers.
  117027. */
  117028. releaseInternalTextures(): void;
  117029. }
  117030. }
  117031. declare module BABYLON {
  117032. interface ThinEngine {
  117033. /**
  117034. * Unbind a list of render target textures from the webGL context
  117035. * This is used only when drawBuffer extension or webGL2 are active
  117036. * @param textures defines the render target textures to unbind
  117037. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117038. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117039. */
  117040. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  117041. /**
  117042. * Create a multi render target texture
  117043. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  117044. * @param size defines the size of the texture
  117045. * @param options defines the creation options
  117046. * @returns the cube texture as an InternalTexture
  117047. */
  117048. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  117049. /**
  117050. * Update the sample count for a given multiple render target texture
  117051. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117052. * @param textures defines the textures to update
  117053. * @param samples defines the sample count to set
  117054. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117055. */
  117056. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  117057. }
  117058. }
  117059. declare module BABYLON {
  117060. /**
  117061. * Class used to define an additional view for the engine
  117062. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117063. */
  117064. export class EngineView {
  117065. /** Defines the canvas where to render the view */
  117066. target: HTMLCanvasElement;
  117067. /** Defines an optional camera used to render the view (will use active camera else) */
  117068. camera?: Camera;
  117069. }
  117070. interface Engine {
  117071. /**
  117072. * Gets or sets the HTML element to use for attaching events
  117073. */
  117074. inputElement: Nullable<HTMLElement>;
  117075. /**
  117076. * Gets the current engine view
  117077. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117078. */
  117079. activeView: Nullable<EngineView>;
  117080. /** Gets or sets the list of views */
  117081. views: EngineView[];
  117082. /**
  117083. * Register a new child canvas
  117084. * @param canvas defines the canvas to register
  117085. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  117086. * @returns the associated view
  117087. */
  117088. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  117089. /**
  117090. * Remove a registered child canvas
  117091. * @param canvas defines the canvas to remove
  117092. * @returns the current engine
  117093. */
  117094. unRegisterView(canvas: HTMLCanvasElement): Engine;
  117095. }
  117096. }
  117097. declare module BABYLON {
  117098. /**
  117099. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  117100. */
  117101. export interface CubeMapInfo {
  117102. /**
  117103. * The pixel array for the front face.
  117104. * This is stored in format, left to right, up to down format.
  117105. */
  117106. front: Nullable<ArrayBufferView>;
  117107. /**
  117108. * The pixel array for the back face.
  117109. * This is stored in format, left to right, up to down format.
  117110. */
  117111. back: Nullable<ArrayBufferView>;
  117112. /**
  117113. * The pixel array for the left face.
  117114. * This is stored in format, left to right, up to down format.
  117115. */
  117116. left: Nullable<ArrayBufferView>;
  117117. /**
  117118. * The pixel array for the right face.
  117119. * This is stored in format, left to right, up to down format.
  117120. */
  117121. right: Nullable<ArrayBufferView>;
  117122. /**
  117123. * The pixel array for the up face.
  117124. * This is stored in format, left to right, up to down format.
  117125. */
  117126. up: Nullable<ArrayBufferView>;
  117127. /**
  117128. * The pixel array for the down face.
  117129. * This is stored in format, left to right, up to down format.
  117130. */
  117131. down: Nullable<ArrayBufferView>;
  117132. /**
  117133. * The size of the cubemap stored.
  117134. *
  117135. * Each faces will be size * size pixels.
  117136. */
  117137. size: number;
  117138. /**
  117139. * The format of the texture.
  117140. *
  117141. * RGBA, RGB.
  117142. */
  117143. format: number;
  117144. /**
  117145. * The type of the texture data.
  117146. *
  117147. * UNSIGNED_INT, FLOAT.
  117148. */
  117149. type: number;
  117150. /**
  117151. * Specifies whether the texture is in gamma space.
  117152. */
  117153. gammaSpace: boolean;
  117154. }
  117155. /**
  117156. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  117157. */
  117158. export class PanoramaToCubeMapTools {
  117159. private static FACE_FRONT;
  117160. private static FACE_BACK;
  117161. private static FACE_RIGHT;
  117162. private static FACE_LEFT;
  117163. private static FACE_DOWN;
  117164. private static FACE_UP;
  117165. /**
  117166. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  117167. *
  117168. * @param float32Array The source data.
  117169. * @param inputWidth The width of the input panorama.
  117170. * @param inputHeight The height of the input panorama.
  117171. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  117172. * @return The cubemap data
  117173. */
  117174. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  117175. private static CreateCubemapTexture;
  117176. private static CalcProjectionSpherical;
  117177. }
  117178. }
  117179. declare module BABYLON {
  117180. /**
  117181. * Helper class dealing with the extraction of spherical polynomial dataArray
  117182. * from a cube map.
  117183. */
  117184. export class CubeMapToSphericalPolynomialTools {
  117185. private static FileFaces;
  117186. /**
  117187. * Converts a texture to the according Spherical Polynomial data.
  117188. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117189. *
  117190. * @param texture The texture to extract the information from.
  117191. * @return The Spherical Polynomial data.
  117192. */
  117193. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  117194. /**
  117195. * Converts a cubemap to the according Spherical Polynomial data.
  117196. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117197. *
  117198. * @param cubeInfo The Cube map to extract the information from.
  117199. * @return The Spherical Polynomial data.
  117200. */
  117201. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  117202. }
  117203. }
  117204. declare module BABYLON {
  117205. interface BaseTexture {
  117206. /**
  117207. * Get the polynomial representation of the texture data.
  117208. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  117209. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  117210. */
  117211. sphericalPolynomial: Nullable<SphericalPolynomial>;
  117212. }
  117213. }
  117214. declare module BABYLON {
  117215. /** @hidden */
  117216. export var rgbdEncodePixelShader: {
  117217. name: string;
  117218. shader: string;
  117219. };
  117220. }
  117221. declare module BABYLON {
  117222. /** @hidden */
  117223. export var rgbdDecodePixelShader: {
  117224. name: string;
  117225. shader: string;
  117226. };
  117227. }
  117228. declare module BABYLON {
  117229. /**
  117230. * Raw texture data and descriptor sufficient for WebGL texture upload
  117231. */
  117232. export interface EnvironmentTextureInfo {
  117233. /**
  117234. * Version of the environment map
  117235. */
  117236. version: number;
  117237. /**
  117238. * Width of image
  117239. */
  117240. width: number;
  117241. /**
  117242. * Irradiance information stored in the file.
  117243. */
  117244. irradiance: any;
  117245. /**
  117246. * Specular information stored in the file.
  117247. */
  117248. specular: any;
  117249. }
  117250. /**
  117251. * Defines One Image in the file. It requires only the position in the file
  117252. * as well as the length.
  117253. */
  117254. interface BufferImageData {
  117255. /**
  117256. * Length of the image data.
  117257. */
  117258. length: number;
  117259. /**
  117260. * Position of the data from the null terminator delimiting the end of the JSON.
  117261. */
  117262. position: number;
  117263. }
  117264. /**
  117265. * Defines the specular data enclosed in the file.
  117266. * This corresponds to the version 1 of the data.
  117267. */
  117268. export interface EnvironmentTextureSpecularInfoV1 {
  117269. /**
  117270. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  117271. */
  117272. specularDataPosition?: number;
  117273. /**
  117274. * This contains all the images data needed to reconstruct the cubemap.
  117275. */
  117276. mipmaps: Array<BufferImageData>;
  117277. /**
  117278. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  117279. */
  117280. lodGenerationScale: number;
  117281. }
  117282. /**
  117283. * Sets of helpers addressing the serialization and deserialization of environment texture
  117284. * stored in a BabylonJS env file.
  117285. * Those files are usually stored as .env files.
  117286. */
  117287. export class EnvironmentTextureTools {
  117288. /**
  117289. * Magic number identifying the env file.
  117290. */
  117291. private static _MagicBytes;
  117292. /**
  117293. * Gets the environment info from an env file.
  117294. * @param data The array buffer containing the .env bytes.
  117295. * @returns the environment file info (the json header) if successfully parsed.
  117296. */
  117297. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  117298. /**
  117299. * Creates an environment texture from a loaded cube texture.
  117300. * @param texture defines the cube texture to convert in env file
  117301. * @return a promise containing the environment data if succesfull.
  117302. */
  117303. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  117304. /**
  117305. * Creates a JSON representation of the spherical data.
  117306. * @param texture defines the texture containing the polynomials
  117307. * @return the JSON representation of the spherical info
  117308. */
  117309. private static _CreateEnvTextureIrradiance;
  117310. /**
  117311. * Creates the ArrayBufferViews used for initializing environment texture image data.
  117312. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  117313. * @param info parameters that determine what views will be created for accessing the underlying buffer
  117314. * @return the views described by info providing access to the underlying buffer
  117315. */
  117316. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  117317. /**
  117318. * Uploads the texture info contained in the env file to the GPU.
  117319. * @param texture defines the internal texture to upload to
  117320. * @param arrayBuffer defines the buffer cotaining the data to load
  117321. * @param info defines the texture info retrieved through the GetEnvInfo method
  117322. * @returns a promise
  117323. */
  117324. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  117325. private static _OnImageReadyAsync;
  117326. /**
  117327. * Uploads the levels of image data to the GPU.
  117328. * @param texture defines the internal texture to upload to
  117329. * @param imageData defines the array buffer views of image data [mipmap][face]
  117330. * @returns a promise
  117331. */
  117332. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  117333. /**
  117334. * Uploads spherical polynomials information to the texture.
  117335. * @param texture defines the texture we are trying to upload the information to
  117336. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  117337. */
  117338. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  117339. /** @hidden */
  117340. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117341. }
  117342. }
  117343. declare module BABYLON {
  117344. /**
  117345. * Contains position and normal vectors for a vertex
  117346. */
  117347. export class PositionNormalVertex {
  117348. /** the position of the vertex (defaut: 0,0,0) */
  117349. position: Vector3;
  117350. /** the normal of the vertex (defaut: 0,1,0) */
  117351. normal: Vector3;
  117352. /**
  117353. * Creates a PositionNormalVertex
  117354. * @param position the position of the vertex (defaut: 0,0,0)
  117355. * @param normal the normal of the vertex (defaut: 0,1,0)
  117356. */
  117357. constructor(
  117358. /** the position of the vertex (defaut: 0,0,0) */
  117359. position?: Vector3,
  117360. /** the normal of the vertex (defaut: 0,1,0) */
  117361. normal?: Vector3);
  117362. /**
  117363. * Clones the PositionNormalVertex
  117364. * @returns the cloned PositionNormalVertex
  117365. */
  117366. clone(): PositionNormalVertex;
  117367. }
  117368. /**
  117369. * Contains position, normal and uv vectors for a vertex
  117370. */
  117371. export class PositionNormalTextureVertex {
  117372. /** the position of the vertex (defaut: 0,0,0) */
  117373. position: Vector3;
  117374. /** the normal of the vertex (defaut: 0,1,0) */
  117375. normal: Vector3;
  117376. /** the uv of the vertex (default: 0,0) */
  117377. uv: Vector2;
  117378. /**
  117379. * Creates a PositionNormalTextureVertex
  117380. * @param position the position of the vertex (defaut: 0,0,0)
  117381. * @param normal the normal of the vertex (defaut: 0,1,0)
  117382. * @param uv the uv of the vertex (default: 0,0)
  117383. */
  117384. constructor(
  117385. /** the position of the vertex (defaut: 0,0,0) */
  117386. position?: Vector3,
  117387. /** the normal of the vertex (defaut: 0,1,0) */
  117388. normal?: Vector3,
  117389. /** the uv of the vertex (default: 0,0) */
  117390. uv?: Vector2);
  117391. /**
  117392. * Clones the PositionNormalTextureVertex
  117393. * @returns the cloned PositionNormalTextureVertex
  117394. */
  117395. clone(): PositionNormalTextureVertex;
  117396. }
  117397. }
  117398. declare module BABYLON {
  117399. /** @hidden */
  117400. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  117401. private _genericAttributeLocation;
  117402. private _varyingLocationCount;
  117403. private _varyingLocationMap;
  117404. private _replacements;
  117405. private _textureCount;
  117406. private _uniforms;
  117407. lineProcessor(line: string): string;
  117408. attributeProcessor(attribute: string): string;
  117409. varyingProcessor(varying: string, isFragment: boolean): string;
  117410. uniformProcessor(uniform: string): string;
  117411. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  117412. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  117413. }
  117414. }
  117415. declare module BABYLON {
  117416. /**
  117417. * Container for accessors for natively-stored mesh data buffers.
  117418. */
  117419. class NativeDataBuffer extends DataBuffer {
  117420. /**
  117421. * Accessor value used to identify/retrieve a natively-stored index buffer.
  117422. */
  117423. nativeIndexBuffer?: any;
  117424. /**
  117425. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  117426. */
  117427. nativeVertexBuffer?: any;
  117428. }
  117429. /** @hidden */
  117430. class NativeTexture extends InternalTexture {
  117431. getInternalTexture(): InternalTexture;
  117432. getViewCount(): number;
  117433. }
  117434. /** @hidden */
  117435. export class NativeEngine extends Engine {
  117436. private readonly _native;
  117437. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  117438. private readonly INVALID_HANDLE;
  117439. getHardwareScalingLevel(): number;
  117440. constructor();
  117441. /**
  117442. * Can be used to override the current requestAnimationFrame requester.
  117443. * @hidden
  117444. */
  117445. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  117446. /**
  117447. * Override default engine behavior.
  117448. * @param color
  117449. * @param backBuffer
  117450. * @param depth
  117451. * @param stencil
  117452. */
  117453. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  117454. /**
  117455. * Gets host document
  117456. * @returns the host document object
  117457. */
  117458. getHostDocument(): Nullable<Document>;
  117459. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117460. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  117461. createVertexBuffer(data: DataArray): NativeDataBuffer;
  117462. recordVertexArrayObject(vertexBuffers: {
  117463. [key: string]: VertexBuffer;
  117464. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  117465. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117466. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117467. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117468. /**
  117469. * Draw a list of indexed primitives
  117470. * @param fillMode defines the primitive to use
  117471. * @param indexStart defines the starting index
  117472. * @param indexCount defines the number of index to draw
  117473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117474. */
  117475. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117476. /**
  117477. * Draw a list of unindexed primitives
  117478. * @param fillMode defines the primitive to use
  117479. * @param verticesStart defines the index of first vertex to draw
  117480. * @param verticesCount defines the count of vertices to draw
  117481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117482. */
  117483. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117484. createPipelineContext(): IPipelineContext;
  117485. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  117486. /** @hidden */
  117487. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  117488. /** @hidden */
  117489. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  117490. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117491. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117492. protected _setProgram(program: WebGLProgram): void;
  117493. _releaseEffect(effect: Effect): void;
  117494. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117495. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  117496. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  117497. bindSamplers(effect: Effect): void;
  117498. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  117499. getRenderWidth(useScreen?: boolean): number;
  117500. getRenderHeight(useScreen?: boolean): number;
  117501. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  117502. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117503. /**
  117504. * Set the z offset to apply to current rendering
  117505. * @param value defines the offset to apply
  117506. */
  117507. setZOffset(value: number): void;
  117508. /**
  117509. * Gets the current value of the zOffset
  117510. * @returns the current zOffset state
  117511. */
  117512. getZOffset(): number;
  117513. /**
  117514. * Enable or disable depth buffering
  117515. * @param enable defines the state to set
  117516. */
  117517. setDepthBuffer(enable: boolean): void;
  117518. /**
  117519. * Gets a boolean indicating if depth writing is enabled
  117520. * @returns the current depth writing state
  117521. */
  117522. getDepthWrite(): boolean;
  117523. /**
  117524. * Enable or disable depth writing
  117525. * @param enable defines the state to set
  117526. */
  117527. setDepthWrite(enable: boolean): void;
  117528. /**
  117529. * Enable or disable color writing
  117530. * @param enable defines the state to set
  117531. */
  117532. setColorWrite(enable: boolean): void;
  117533. /**
  117534. * Gets a boolean indicating if color writing is enabled
  117535. * @returns the current color writing state
  117536. */
  117537. getColorWrite(): boolean;
  117538. /**
  117539. * Sets alpha constants used by some alpha blending modes
  117540. * @param r defines the red component
  117541. * @param g defines the green component
  117542. * @param b defines the blue component
  117543. * @param a defines the alpha component
  117544. */
  117545. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  117546. /**
  117547. * Sets the current alpha mode
  117548. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  117549. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117551. */
  117552. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117553. /**
  117554. * Gets the current alpha mode
  117555. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117556. * @returns the current alpha mode
  117557. */
  117558. getAlphaMode(): number;
  117559. setInt(uniform: WebGLUniformLocation, int: number): void;
  117560. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117561. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117562. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117563. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117564. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117565. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117566. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117567. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117568. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117569. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117570. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117571. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117572. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117573. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117574. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117575. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117576. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117577. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117578. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117579. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  117580. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  117581. wipeCaches(bruteForce?: boolean): void;
  117582. _createTexture(): WebGLTexture;
  117583. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  117584. /**
  117585. * Usually called from BABYLON.Texture.ts.
  117586. * Passed information to create a WebGLTexture
  117587. * @param urlArg defines a value which contains one of the following:
  117588. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117589. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117590. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117591. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117592. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  117593. * @param scene needed for loading to the correct scene
  117594. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  117595. * @param onLoad optional callback to be called upon successful completion
  117596. * @param onError optional callback to be called upon failure
  117597. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  117598. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117599. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117600. * @param forcedExtension defines the extension to use to pick the right loader
  117601. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117602. */
  117603. 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;
  117604. /**
  117605. * Creates a cube texture
  117606. * @param rootUrl defines the url where the files to load is located
  117607. * @param scene defines the current scene
  117608. * @param files defines the list of files to load (1 per face)
  117609. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  117610. * @param onLoad defines an optional callback raised when the texture is loaded
  117611. * @param onError defines an optional callback raised if there is an issue to load the texture
  117612. * @param format defines the format of the data
  117613. * @param forcedExtension defines the extension to use to pick the right loader
  117614. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  117615. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117616. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117617. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  117618. * @returns the cube texture as an InternalTexture
  117619. */
  117620. 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;
  117621. private _getSamplingFilter;
  117622. private static _GetNativeTextureFormat;
  117623. createRenderTargetTexture(size: number | {
  117624. width: number;
  117625. height: number;
  117626. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  117627. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117628. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117629. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117630. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  117631. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  117632. /**
  117633. * Updates a dynamic vertex buffer.
  117634. * @param vertexBuffer the vertex buffer to update
  117635. * @param data the data used to update the vertex buffer
  117636. * @param byteOffset the byte offset of the data (optional)
  117637. * @param byteLength the byte length of the data (optional)
  117638. */
  117639. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  117640. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  117641. private _updateAnisotropicLevel;
  117642. private _getAddressMode;
  117643. /** @hidden */
  117644. _bindTexture(channel: number, texture: InternalTexture): void;
  117645. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  117646. releaseEffects(): void;
  117647. /** @hidden */
  117648. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117649. /** @hidden */
  117650. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117651. /** @hidden */
  117652. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117653. /** @hidden */
  117654. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117655. }
  117656. }
  117657. declare module BABYLON {
  117658. /**
  117659. * Gather the list of clipboard event types as constants.
  117660. */
  117661. export class ClipboardEventTypes {
  117662. /**
  117663. * The clipboard event is fired when a copy command is active (pressed).
  117664. */
  117665. static readonly COPY: number;
  117666. /**
  117667. * The clipboard event is fired when a cut command is active (pressed).
  117668. */
  117669. static readonly CUT: number;
  117670. /**
  117671. * The clipboard event is fired when a paste command is active (pressed).
  117672. */
  117673. static readonly PASTE: number;
  117674. }
  117675. /**
  117676. * This class is used to store clipboard related info for the onClipboardObservable event.
  117677. */
  117678. export class ClipboardInfo {
  117679. /**
  117680. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117681. */
  117682. type: number;
  117683. /**
  117684. * Defines the related dom event
  117685. */
  117686. event: ClipboardEvent;
  117687. /**
  117688. *Creates an instance of ClipboardInfo.
  117689. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  117690. * @param event Defines the related dom event
  117691. */
  117692. constructor(
  117693. /**
  117694. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117695. */
  117696. type: number,
  117697. /**
  117698. * Defines the related dom event
  117699. */
  117700. event: ClipboardEvent);
  117701. /**
  117702. * Get the clipboard event's type from the keycode.
  117703. * @param keyCode Defines the keyCode for the current keyboard event.
  117704. * @return {number}
  117705. */
  117706. static GetTypeFromCharacter(keyCode: number): number;
  117707. }
  117708. }
  117709. declare module BABYLON {
  117710. /**
  117711. * Google Daydream controller
  117712. */
  117713. export class DaydreamController extends WebVRController {
  117714. /**
  117715. * Base Url for the controller model.
  117716. */
  117717. static MODEL_BASE_URL: string;
  117718. /**
  117719. * File name for the controller model.
  117720. */
  117721. static MODEL_FILENAME: string;
  117722. /**
  117723. * Gamepad Id prefix used to identify Daydream Controller.
  117724. */
  117725. static readonly GAMEPAD_ID_PREFIX: string;
  117726. /**
  117727. * Creates a new DaydreamController from a gamepad
  117728. * @param vrGamepad the gamepad that the controller should be created from
  117729. */
  117730. constructor(vrGamepad: any);
  117731. /**
  117732. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117733. * @param scene scene in which to add meshes
  117734. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117735. */
  117736. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117737. /**
  117738. * Called once for each button that changed state since the last frame
  117739. * @param buttonIdx Which button index changed
  117740. * @param state New state of the button
  117741. * @param changes Which properties on the state changed since last frame
  117742. */
  117743. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117744. }
  117745. }
  117746. declare module BABYLON {
  117747. /**
  117748. * Gear VR Controller
  117749. */
  117750. export class GearVRController extends WebVRController {
  117751. /**
  117752. * Base Url for the controller model.
  117753. */
  117754. static MODEL_BASE_URL: string;
  117755. /**
  117756. * File name for the controller model.
  117757. */
  117758. static MODEL_FILENAME: string;
  117759. /**
  117760. * Gamepad Id prefix used to identify this controller.
  117761. */
  117762. static readonly GAMEPAD_ID_PREFIX: string;
  117763. private readonly _buttonIndexToObservableNameMap;
  117764. /**
  117765. * Creates a new GearVRController from a gamepad
  117766. * @param vrGamepad the gamepad that the controller should be created from
  117767. */
  117768. constructor(vrGamepad: any);
  117769. /**
  117770. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117771. * @param scene scene in which to add meshes
  117772. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117773. */
  117774. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117775. /**
  117776. * Called once for each button that changed state since the last frame
  117777. * @param buttonIdx Which button index changed
  117778. * @param state New state of the button
  117779. * @param changes Which properties on the state changed since last frame
  117780. */
  117781. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117782. }
  117783. }
  117784. declare module BABYLON {
  117785. /**
  117786. * Class containing static functions to help procedurally build meshes
  117787. */
  117788. export class PolyhedronBuilder {
  117789. /**
  117790. * Creates a polyhedron mesh
  117791. * * 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
  117792. * * The parameter `size` (positive float, default 1) sets the polygon size
  117793. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117794. * * 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`
  117795. * * 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
  117796. * * 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)`)
  117797. * * 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
  117798. * * 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
  117799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117802. * @param name defines the name of the mesh
  117803. * @param options defines the options used to create the mesh
  117804. * @param scene defines the hosting scene
  117805. * @returns the polyhedron mesh
  117806. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117807. */
  117808. static CreatePolyhedron(name: string, options: {
  117809. type?: number;
  117810. size?: number;
  117811. sizeX?: number;
  117812. sizeY?: number;
  117813. sizeZ?: number;
  117814. custom?: any;
  117815. faceUV?: Vector4[];
  117816. faceColors?: Color4[];
  117817. flat?: boolean;
  117818. updatable?: boolean;
  117819. sideOrientation?: number;
  117820. frontUVs?: Vector4;
  117821. backUVs?: Vector4;
  117822. }, scene?: Nullable<Scene>): Mesh;
  117823. }
  117824. }
  117825. declare module BABYLON {
  117826. /**
  117827. * Gizmo that enables scaling a mesh along 3 axis
  117828. */
  117829. export class ScaleGizmo extends Gizmo {
  117830. /**
  117831. * Internal gizmo used for interactions on the x axis
  117832. */
  117833. xGizmo: AxisScaleGizmo;
  117834. /**
  117835. * Internal gizmo used for interactions on the y axis
  117836. */
  117837. yGizmo: AxisScaleGizmo;
  117838. /**
  117839. * Internal gizmo used for interactions on the z axis
  117840. */
  117841. zGizmo: AxisScaleGizmo;
  117842. /**
  117843. * Internal gizmo used to scale all axis equally
  117844. */
  117845. uniformScaleGizmo: AxisScaleGizmo;
  117846. private _meshAttached;
  117847. private _updateGizmoRotationToMatchAttachedMesh;
  117848. private _snapDistance;
  117849. private _scaleRatio;
  117850. private _uniformScalingMesh;
  117851. private _octahedron;
  117852. private _sensitivity;
  117853. /** Fires an event when any of it's sub gizmos are dragged */
  117854. onDragStartObservable: Observable<unknown>;
  117855. /** Fires an event when any of it's sub gizmos are released from dragging */
  117856. onDragEndObservable: Observable<unknown>;
  117857. get attachedMesh(): Nullable<AbstractMesh>;
  117858. set attachedMesh(mesh: Nullable<AbstractMesh>);
  117859. /**
  117860. * Creates a ScaleGizmo
  117861. * @param gizmoLayer The utility layer the gizmo will be added to
  117862. */
  117863. constructor(gizmoLayer?: UtilityLayerRenderer);
  117864. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  117865. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  117866. /**
  117867. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117868. */
  117869. set snapDistance(value: number);
  117870. get snapDistance(): number;
  117871. /**
  117872. * Ratio for the scale of the gizmo (Default: 1)
  117873. */
  117874. set scaleRatio(value: number);
  117875. get scaleRatio(): number;
  117876. /**
  117877. * Sensitivity factor for dragging (Default: 1)
  117878. */
  117879. set sensitivity(value: number);
  117880. get sensitivity(): number;
  117881. /**
  117882. * Disposes of the gizmo
  117883. */
  117884. dispose(): void;
  117885. }
  117886. }
  117887. declare module BABYLON {
  117888. /**
  117889. * Single axis scale gizmo
  117890. */
  117891. export class AxisScaleGizmo extends Gizmo {
  117892. /**
  117893. * Drag behavior responsible for the gizmos dragging interactions
  117894. */
  117895. dragBehavior: PointerDragBehavior;
  117896. private _pointerObserver;
  117897. /**
  117898. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117899. */
  117900. snapDistance: number;
  117901. /**
  117902. * Event that fires each time the gizmo snaps to a new location.
  117903. * * snapDistance is the the change in distance
  117904. */
  117905. onSnapObservable: Observable<{
  117906. snapDistance: number;
  117907. }>;
  117908. /**
  117909. * If the scaling operation should be done on all axis (default: false)
  117910. */
  117911. uniformScaling: boolean;
  117912. /**
  117913. * Custom sensitivity value for the drag strength
  117914. */
  117915. sensitivity: number;
  117916. private _isEnabled;
  117917. private _parent;
  117918. private _arrow;
  117919. private _coloredMaterial;
  117920. private _hoverMaterial;
  117921. /**
  117922. * Creates an AxisScaleGizmo
  117923. * @param gizmoLayer The utility layer the gizmo will be added to
  117924. * @param dragAxis The axis which the gizmo will be able to scale on
  117925. * @param color The color of the gizmo
  117926. */
  117927. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  117928. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  117929. /**
  117930. * If the gizmo is enabled
  117931. */
  117932. set isEnabled(value: boolean);
  117933. get isEnabled(): boolean;
  117934. /**
  117935. * Disposes of the gizmo
  117936. */
  117937. dispose(): void;
  117938. /**
  117939. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  117940. * @param mesh The mesh to replace the default mesh of the gizmo
  117941. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  117942. */
  117943. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  117944. }
  117945. }
  117946. declare module BABYLON {
  117947. /**
  117948. * Bounding box gizmo
  117949. */
  117950. export class BoundingBoxGizmo extends Gizmo {
  117951. private _lineBoundingBox;
  117952. private _rotateSpheresParent;
  117953. private _scaleBoxesParent;
  117954. private _boundingDimensions;
  117955. private _renderObserver;
  117956. private _pointerObserver;
  117957. private _scaleDragSpeed;
  117958. private _tmpQuaternion;
  117959. private _tmpVector;
  117960. private _tmpRotationMatrix;
  117961. /**
  117962. * 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)
  117963. */
  117964. ignoreChildren: boolean;
  117965. /**
  117966. * 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)
  117967. */
  117968. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  117969. /**
  117970. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  117971. */
  117972. rotationSphereSize: number;
  117973. /**
  117974. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  117975. */
  117976. scaleBoxSize: number;
  117977. /**
  117978. * 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)
  117979. */
  117980. fixedDragMeshScreenSize: boolean;
  117981. /**
  117982. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  117983. */
  117984. fixedDragMeshScreenSizeDistanceFactor: number;
  117985. /**
  117986. * Fired when a rotation sphere or scale box is dragged
  117987. */
  117988. onDragStartObservable: Observable<{}>;
  117989. /**
  117990. * Fired when a scale box is dragged
  117991. */
  117992. onScaleBoxDragObservable: Observable<{}>;
  117993. /**
  117994. * Fired when a scale box drag is ended
  117995. */
  117996. onScaleBoxDragEndObservable: Observable<{}>;
  117997. /**
  117998. * Fired when a rotation sphere is dragged
  117999. */
  118000. onRotationSphereDragObservable: Observable<{}>;
  118001. /**
  118002. * Fired when a rotation sphere drag is ended
  118003. */
  118004. onRotationSphereDragEndObservable: Observable<{}>;
  118005. /**
  118006. * 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)
  118007. */
  118008. scalePivot: Nullable<Vector3>;
  118009. /**
  118010. * Mesh used as a pivot to rotate the attached mesh
  118011. */
  118012. private _anchorMesh;
  118013. private _existingMeshScale;
  118014. private _dragMesh;
  118015. private pointerDragBehavior;
  118016. private coloredMaterial;
  118017. private hoverColoredMaterial;
  118018. /**
  118019. * Sets the color of the bounding box gizmo
  118020. * @param color the color to set
  118021. */
  118022. setColor(color: Color3): void;
  118023. /**
  118024. * Creates an BoundingBoxGizmo
  118025. * @param gizmoLayer The utility layer the gizmo will be added to
  118026. * @param color The color of the gizmo
  118027. */
  118028. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  118029. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118030. private _selectNode;
  118031. /**
  118032. * Updates the bounding box information for the Gizmo
  118033. */
  118034. updateBoundingBox(): void;
  118035. private _updateRotationSpheres;
  118036. private _updateScaleBoxes;
  118037. /**
  118038. * Enables rotation on the specified axis and disables rotation on the others
  118039. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  118040. */
  118041. setEnabledRotationAxis(axis: string): void;
  118042. /**
  118043. * Enables/disables scaling
  118044. * @param enable if scaling should be enabled
  118045. */
  118046. setEnabledScaling(enable: boolean): void;
  118047. private _updateDummy;
  118048. /**
  118049. * Enables a pointer drag behavior on the bounding box of the gizmo
  118050. */
  118051. enableDragBehavior(): void;
  118052. /**
  118053. * Disposes of the gizmo
  118054. */
  118055. dispose(): void;
  118056. /**
  118057. * 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)
  118058. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  118059. * @returns the bounding box mesh with the passed in mesh as a child
  118060. */
  118061. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  118062. /**
  118063. * CustomMeshes are not supported by this gizmo
  118064. * @param mesh The mesh to replace the default mesh of the gizmo
  118065. */
  118066. setCustomMesh(mesh: Mesh): void;
  118067. }
  118068. }
  118069. declare module BABYLON {
  118070. /**
  118071. * Single plane rotation gizmo
  118072. */
  118073. export class PlaneRotationGizmo extends Gizmo {
  118074. /**
  118075. * Drag behavior responsible for the gizmos dragging interactions
  118076. */
  118077. dragBehavior: PointerDragBehavior;
  118078. private _pointerObserver;
  118079. /**
  118080. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  118081. */
  118082. snapDistance: number;
  118083. /**
  118084. * Event that fires each time the gizmo snaps to a new location.
  118085. * * snapDistance is the the change in distance
  118086. */
  118087. onSnapObservable: Observable<{
  118088. snapDistance: number;
  118089. }>;
  118090. private _isEnabled;
  118091. private _parent;
  118092. /**
  118093. * Creates a PlaneRotationGizmo
  118094. * @param gizmoLayer The utility layer the gizmo will be added to
  118095. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  118096. * @param color The color of the gizmo
  118097. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118098. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118099. */
  118100. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  118101. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118102. /**
  118103. * If the gizmo is enabled
  118104. */
  118105. set isEnabled(value: boolean);
  118106. get isEnabled(): boolean;
  118107. /**
  118108. * Disposes of the gizmo
  118109. */
  118110. dispose(): void;
  118111. }
  118112. }
  118113. declare module BABYLON {
  118114. /**
  118115. * Gizmo that enables rotating a mesh along 3 axis
  118116. */
  118117. export class RotationGizmo extends Gizmo {
  118118. /**
  118119. * Internal gizmo used for interactions on the x axis
  118120. */
  118121. xGizmo: PlaneRotationGizmo;
  118122. /**
  118123. * Internal gizmo used for interactions on the y axis
  118124. */
  118125. yGizmo: PlaneRotationGizmo;
  118126. /**
  118127. * Internal gizmo used for interactions on the z axis
  118128. */
  118129. zGizmo: PlaneRotationGizmo;
  118130. /** Fires an event when any of it's sub gizmos are dragged */
  118131. onDragStartObservable: Observable<unknown>;
  118132. /** Fires an event when any of it's sub gizmos are released from dragging */
  118133. onDragEndObservable: Observable<unknown>;
  118134. private _meshAttached;
  118135. get attachedMesh(): Nullable<AbstractMesh>;
  118136. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118137. /**
  118138. * Creates a RotationGizmo
  118139. * @param gizmoLayer The utility layer the gizmo will be added to
  118140. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118141. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118142. */
  118143. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  118144. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118145. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118146. /**
  118147. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118148. */
  118149. set snapDistance(value: number);
  118150. get snapDistance(): number;
  118151. /**
  118152. * Ratio for the scale of the gizmo (Default: 1)
  118153. */
  118154. set scaleRatio(value: number);
  118155. get scaleRatio(): number;
  118156. /**
  118157. * Disposes of the gizmo
  118158. */
  118159. dispose(): void;
  118160. /**
  118161. * CustomMeshes are not supported by this gizmo
  118162. * @param mesh The mesh to replace the default mesh of the gizmo
  118163. */
  118164. setCustomMesh(mesh: Mesh): void;
  118165. }
  118166. }
  118167. declare module BABYLON {
  118168. /**
  118169. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  118170. */
  118171. export class GizmoManager implements IDisposable {
  118172. private scene;
  118173. /**
  118174. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  118175. */
  118176. gizmos: {
  118177. positionGizmo: Nullable<PositionGizmo>;
  118178. rotationGizmo: Nullable<RotationGizmo>;
  118179. scaleGizmo: Nullable<ScaleGizmo>;
  118180. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  118181. };
  118182. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  118183. clearGizmoOnEmptyPointerEvent: boolean;
  118184. /** Fires an event when the manager is attached to a mesh */
  118185. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  118186. private _gizmosEnabled;
  118187. private _pointerObserver;
  118188. private _attachedMesh;
  118189. private _boundingBoxColor;
  118190. private _defaultUtilityLayer;
  118191. private _defaultKeepDepthUtilityLayer;
  118192. /**
  118193. * When bounding box gizmo is enabled, this can be used to track drag/end events
  118194. */
  118195. boundingBoxDragBehavior: SixDofDragBehavior;
  118196. /**
  118197. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  118198. */
  118199. attachableMeshes: Nullable<Array<AbstractMesh>>;
  118200. /**
  118201. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  118202. */
  118203. usePointerToAttachGizmos: boolean;
  118204. /**
  118205. * Utility layer that the bounding box gizmo belongs to
  118206. */
  118207. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  118208. /**
  118209. * Utility layer that all gizmos besides bounding box belong to
  118210. */
  118211. get utilityLayer(): UtilityLayerRenderer;
  118212. /**
  118213. * Instatiates a gizmo manager
  118214. * @param scene the scene to overlay the gizmos on top of
  118215. */
  118216. constructor(scene: Scene);
  118217. /**
  118218. * Attaches a set of gizmos to the specified mesh
  118219. * @param mesh The mesh the gizmo's should be attached to
  118220. */
  118221. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118222. /**
  118223. * If the position gizmo is enabled
  118224. */
  118225. set positionGizmoEnabled(value: boolean);
  118226. get positionGizmoEnabled(): boolean;
  118227. /**
  118228. * If the rotation gizmo is enabled
  118229. */
  118230. set rotationGizmoEnabled(value: boolean);
  118231. get rotationGizmoEnabled(): boolean;
  118232. /**
  118233. * If the scale gizmo is enabled
  118234. */
  118235. set scaleGizmoEnabled(value: boolean);
  118236. get scaleGizmoEnabled(): boolean;
  118237. /**
  118238. * If the boundingBox gizmo is enabled
  118239. */
  118240. set boundingBoxGizmoEnabled(value: boolean);
  118241. get boundingBoxGizmoEnabled(): boolean;
  118242. /**
  118243. * Disposes of the gizmo manager
  118244. */
  118245. dispose(): void;
  118246. }
  118247. }
  118248. declare module BABYLON {
  118249. /**
  118250. * A directional light is defined by a direction (what a surprise!).
  118251. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  118252. * 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.
  118253. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118254. */
  118255. export class DirectionalLight extends ShadowLight {
  118256. private _shadowFrustumSize;
  118257. /**
  118258. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  118259. */
  118260. get shadowFrustumSize(): number;
  118261. /**
  118262. * Specifies a fix frustum size for the shadow generation.
  118263. */
  118264. set shadowFrustumSize(value: number);
  118265. private _shadowOrthoScale;
  118266. /**
  118267. * Gets the shadow projection scale against the optimal computed one.
  118268. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118269. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118270. */
  118271. get shadowOrthoScale(): number;
  118272. /**
  118273. * Sets the shadow projection scale against the optimal computed one.
  118274. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118275. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118276. */
  118277. set shadowOrthoScale(value: number);
  118278. /**
  118279. * Automatically compute the projection matrix to best fit (including all the casters)
  118280. * on each frame.
  118281. */
  118282. autoUpdateExtends: boolean;
  118283. private _orthoLeft;
  118284. private _orthoRight;
  118285. private _orthoTop;
  118286. private _orthoBottom;
  118287. /**
  118288. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  118289. * The directional light is emitted from everywhere in the given direction.
  118290. * It can cast shadows.
  118291. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118292. * @param name The friendly name of the light
  118293. * @param direction The direction of the light
  118294. * @param scene The scene the light belongs to
  118295. */
  118296. constructor(name: string, direction: Vector3, scene: Scene);
  118297. /**
  118298. * Returns the string "DirectionalLight".
  118299. * @return The class name
  118300. */
  118301. getClassName(): string;
  118302. /**
  118303. * Returns the integer 1.
  118304. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118305. */
  118306. getTypeID(): number;
  118307. /**
  118308. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  118309. * Returns the DirectionalLight Shadow projection matrix.
  118310. */
  118311. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118312. /**
  118313. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  118314. * Returns the DirectionalLight Shadow projection matrix.
  118315. */
  118316. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  118317. /**
  118318. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  118319. * Returns the DirectionalLight Shadow projection matrix.
  118320. */
  118321. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118322. protected _buildUniformLayout(): void;
  118323. /**
  118324. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  118325. * @param effect The effect to update
  118326. * @param lightIndex The index of the light in the effect to update
  118327. * @returns The directional light
  118328. */
  118329. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  118330. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  118331. /**
  118332. * Gets the minZ used for shadow according to both the scene and the light.
  118333. *
  118334. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118335. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118336. * @param activeCamera The camera we are returning the min for
  118337. * @returns the depth min z
  118338. */
  118339. getDepthMinZ(activeCamera: Camera): number;
  118340. /**
  118341. * Gets the maxZ used for shadow according to both the scene and the light.
  118342. *
  118343. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118344. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118345. * @param activeCamera The camera we are returning the max for
  118346. * @returns the depth max z
  118347. */
  118348. getDepthMaxZ(activeCamera: Camera): number;
  118349. /**
  118350. * Prepares the list of defines specific to the light type.
  118351. * @param defines the list of defines
  118352. * @param lightIndex defines the index of the light for the effect
  118353. */
  118354. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118355. }
  118356. }
  118357. declare module BABYLON {
  118358. /**
  118359. * Class containing static functions to help procedurally build meshes
  118360. */
  118361. export class HemisphereBuilder {
  118362. /**
  118363. * Creates a hemisphere mesh
  118364. * @param name defines the name of the mesh
  118365. * @param options defines the options used to create the mesh
  118366. * @param scene defines the hosting scene
  118367. * @returns the hemisphere mesh
  118368. */
  118369. static CreateHemisphere(name: string, options: {
  118370. segments?: number;
  118371. diameter?: number;
  118372. sideOrientation?: number;
  118373. }, scene: any): Mesh;
  118374. }
  118375. }
  118376. declare module BABYLON {
  118377. /**
  118378. * A spot light is defined by a position, a direction, an angle, and an exponent.
  118379. * These values define a cone of light starting from the position, emitting toward the direction.
  118380. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  118381. * and the exponent defines the speed of the decay of the light with distance (reach).
  118382. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118383. */
  118384. export class SpotLight extends ShadowLight {
  118385. private _angle;
  118386. private _innerAngle;
  118387. private _cosHalfAngle;
  118388. private _lightAngleScale;
  118389. private _lightAngleOffset;
  118390. /**
  118391. * Gets the cone angle of the spot light in Radians.
  118392. */
  118393. get angle(): number;
  118394. /**
  118395. * Sets the cone angle of the spot light in Radians.
  118396. */
  118397. set angle(value: number);
  118398. /**
  118399. * Only used in gltf falloff mode, this defines the angle where
  118400. * the directional falloff will start before cutting at angle which could be seen
  118401. * as outer angle.
  118402. */
  118403. get innerAngle(): number;
  118404. /**
  118405. * Only used in gltf falloff mode, this defines the angle where
  118406. * the directional falloff will start before cutting at angle which could be seen
  118407. * as outer angle.
  118408. */
  118409. set innerAngle(value: number);
  118410. private _shadowAngleScale;
  118411. /**
  118412. * Allows scaling the angle of the light for shadow generation only.
  118413. */
  118414. get shadowAngleScale(): number;
  118415. /**
  118416. * Allows scaling the angle of the light for shadow generation only.
  118417. */
  118418. set shadowAngleScale(value: number);
  118419. /**
  118420. * The light decay speed with the distance from the emission spot.
  118421. */
  118422. exponent: number;
  118423. private _projectionTextureMatrix;
  118424. /**
  118425. * Allows reading the projecton texture
  118426. */
  118427. get projectionTextureMatrix(): Matrix;
  118428. protected _projectionTextureLightNear: number;
  118429. /**
  118430. * Gets the near clip of the Spotlight for texture projection.
  118431. */
  118432. get projectionTextureLightNear(): number;
  118433. /**
  118434. * Sets the near clip of the Spotlight for texture projection.
  118435. */
  118436. set projectionTextureLightNear(value: number);
  118437. protected _projectionTextureLightFar: number;
  118438. /**
  118439. * Gets the far clip of the Spotlight for texture projection.
  118440. */
  118441. get projectionTextureLightFar(): number;
  118442. /**
  118443. * Sets the far clip of the Spotlight for texture projection.
  118444. */
  118445. set projectionTextureLightFar(value: number);
  118446. protected _projectionTextureUpDirection: Vector3;
  118447. /**
  118448. * Gets the Up vector of the Spotlight for texture projection.
  118449. */
  118450. get projectionTextureUpDirection(): Vector3;
  118451. /**
  118452. * Sets the Up vector of the Spotlight for texture projection.
  118453. */
  118454. set projectionTextureUpDirection(value: Vector3);
  118455. private _projectionTexture;
  118456. /**
  118457. * Gets the projection texture of the light.
  118458. */
  118459. get projectionTexture(): Nullable<BaseTexture>;
  118460. /**
  118461. * Sets the projection texture of the light.
  118462. */
  118463. set projectionTexture(value: Nullable<BaseTexture>);
  118464. private _projectionTextureViewLightDirty;
  118465. private _projectionTextureProjectionLightDirty;
  118466. private _projectionTextureDirty;
  118467. private _projectionTextureViewTargetVector;
  118468. private _projectionTextureViewLightMatrix;
  118469. private _projectionTextureProjectionLightMatrix;
  118470. private _projectionTextureScalingMatrix;
  118471. /**
  118472. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  118473. * It can cast shadows.
  118474. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118475. * @param name The light friendly name
  118476. * @param position The position of the spot light in the scene
  118477. * @param direction The direction of the light in the scene
  118478. * @param angle The cone angle of the light in Radians
  118479. * @param exponent The light decay speed with the distance from the emission spot
  118480. * @param scene The scene the lights belongs to
  118481. */
  118482. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  118483. /**
  118484. * Returns the string "SpotLight".
  118485. * @returns the class name
  118486. */
  118487. getClassName(): string;
  118488. /**
  118489. * Returns the integer 2.
  118490. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118491. */
  118492. getTypeID(): number;
  118493. /**
  118494. * Overrides the direction setter to recompute the projection texture view light Matrix.
  118495. */
  118496. protected _setDirection(value: Vector3): void;
  118497. /**
  118498. * Overrides the position setter to recompute the projection texture view light Matrix.
  118499. */
  118500. protected _setPosition(value: Vector3): void;
  118501. /**
  118502. * 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.
  118503. * Returns the SpotLight.
  118504. */
  118505. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118506. protected _computeProjectionTextureViewLightMatrix(): void;
  118507. protected _computeProjectionTextureProjectionLightMatrix(): void;
  118508. /**
  118509. * Main function for light texture projection matrix computing.
  118510. */
  118511. protected _computeProjectionTextureMatrix(): void;
  118512. protected _buildUniformLayout(): void;
  118513. private _computeAngleValues;
  118514. /**
  118515. * Sets the passed Effect "effect" with the Light textures.
  118516. * @param effect The effect to update
  118517. * @param lightIndex The index of the light in the effect to update
  118518. * @returns The light
  118519. */
  118520. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  118521. /**
  118522. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  118523. * @param effect The effect to update
  118524. * @param lightIndex The index of the light in the effect to update
  118525. * @returns The spot light
  118526. */
  118527. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  118528. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118529. /**
  118530. * Disposes the light and the associated resources.
  118531. */
  118532. dispose(): void;
  118533. /**
  118534. * Prepares the list of defines specific to the light type.
  118535. * @param defines the list of defines
  118536. * @param lightIndex defines the index of the light for the effect
  118537. */
  118538. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118539. }
  118540. }
  118541. declare module BABYLON {
  118542. /**
  118543. * Gizmo that enables viewing a light
  118544. */
  118545. export class LightGizmo extends Gizmo {
  118546. private _lightMesh;
  118547. private _material;
  118548. private _cachedPosition;
  118549. private _cachedForward;
  118550. private _attachedMeshParent;
  118551. /**
  118552. * Creates a LightGizmo
  118553. * @param gizmoLayer The utility layer the gizmo will be added to
  118554. */
  118555. constructor(gizmoLayer?: UtilityLayerRenderer);
  118556. private _light;
  118557. /**
  118558. * The light that the gizmo is attached to
  118559. */
  118560. set light(light: Nullable<Light>);
  118561. get light(): Nullable<Light>;
  118562. /**
  118563. * Gets the material used to render the light gizmo
  118564. */
  118565. get material(): StandardMaterial;
  118566. /**
  118567. * @hidden
  118568. * Updates the gizmo to match the attached mesh's position/rotation
  118569. */
  118570. protected _update(): void;
  118571. private static _Scale;
  118572. /**
  118573. * Creates the lines for a light mesh
  118574. */
  118575. private static _CreateLightLines;
  118576. /**
  118577. * Disposes of the light gizmo
  118578. */
  118579. dispose(): void;
  118580. private static _CreateHemisphericLightMesh;
  118581. private static _CreatePointLightMesh;
  118582. private static _CreateSpotLightMesh;
  118583. private static _CreateDirectionalLightMesh;
  118584. }
  118585. }
  118586. declare module BABYLON {
  118587. /** @hidden */
  118588. export var backgroundFragmentDeclaration: {
  118589. name: string;
  118590. shader: string;
  118591. };
  118592. }
  118593. declare module BABYLON {
  118594. /** @hidden */
  118595. export var backgroundUboDeclaration: {
  118596. name: string;
  118597. shader: string;
  118598. };
  118599. }
  118600. declare module BABYLON {
  118601. /** @hidden */
  118602. export var backgroundPixelShader: {
  118603. name: string;
  118604. shader: string;
  118605. };
  118606. }
  118607. declare module BABYLON {
  118608. /** @hidden */
  118609. export var backgroundVertexDeclaration: {
  118610. name: string;
  118611. shader: string;
  118612. };
  118613. }
  118614. declare module BABYLON {
  118615. /** @hidden */
  118616. export var backgroundVertexShader: {
  118617. name: string;
  118618. shader: string;
  118619. };
  118620. }
  118621. declare module BABYLON {
  118622. /**
  118623. * Background material used to create an efficient environement around your scene.
  118624. */
  118625. export class BackgroundMaterial extends PushMaterial {
  118626. /**
  118627. * Standard reflectance value at parallel view angle.
  118628. */
  118629. static StandardReflectance0: number;
  118630. /**
  118631. * Standard reflectance value at grazing angle.
  118632. */
  118633. static StandardReflectance90: number;
  118634. protected _primaryColor: Color3;
  118635. /**
  118636. * Key light Color (multiply against the environement texture)
  118637. */
  118638. primaryColor: Color3;
  118639. protected __perceptualColor: Nullable<Color3>;
  118640. /**
  118641. * Experimental Internal Use Only.
  118642. *
  118643. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  118644. * This acts as a helper to set the primary color to a more "human friendly" value.
  118645. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  118646. * output color as close as possible from the chosen value.
  118647. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  118648. * part of lighting setup.)
  118649. */
  118650. get _perceptualColor(): Nullable<Color3>;
  118651. set _perceptualColor(value: Nullable<Color3>);
  118652. protected _primaryColorShadowLevel: float;
  118653. /**
  118654. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  118655. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  118656. */
  118657. get primaryColorShadowLevel(): float;
  118658. set primaryColorShadowLevel(value: float);
  118659. protected _primaryColorHighlightLevel: float;
  118660. /**
  118661. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  118662. * The primary color is used at the level chosen to define what the white area would look.
  118663. */
  118664. get primaryColorHighlightLevel(): float;
  118665. set primaryColorHighlightLevel(value: float);
  118666. protected _reflectionTexture: Nullable<BaseTexture>;
  118667. /**
  118668. * Reflection Texture used in the material.
  118669. * Should be author in a specific way for the best result (refer to the documentation).
  118670. */
  118671. reflectionTexture: Nullable<BaseTexture>;
  118672. protected _reflectionBlur: float;
  118673. /**
  118674. * Reflection Texture level of blur.
  118675. *
  118676. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  118677. * texture twice.
  118678. */
  118679. reflectionBlur: float;
  118680. protected _diffuseTexture: Nullable<BaseTexture>;
  118681. /**
  118682. * Diffuse Texture used in the material.
  118683. * Should be author in a specific way for the best result (refer to the documentation).
  118684. */
  118685. diffuseTexture: Nullable<BaseTexture>;
  118686. protected _shadowLights: Nullable<IShadowLight[]>;
  118687. /**
  118688. * Specify the list of lights casting shadow on the material.
  118689. * All scene shadow lights will be included if null.
  118690. */
  118691. shadowLights: Nullable<IShadowLight[]>;
  118692. protected _shadowLevel: float;
  118693. /**
  118694. * Helps adjusting the shadow to a softer level if required.
  118695. * 0 means black shadows and 1 means no shadows.
  118696. */
  118697. shadowLevel: float;
  118698. protected _sceneCenter: Vector3;
  118699. /**
  118700. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  118701. * It is usually zero but might be interesting to modify according to your setup.
  118702. */
  118703. sceneCenter: Vector3;
  118704. protected _opacityFresnel: boolean;
  118705. /**
  118706. * This helps specifying that the material is falling off to the sky box at grazing angle.
  118707. * This helps ensuring a nice transition when the camera goes under the ground.
  118708. */
  118709. opacityFresnel: boolean;
  118710. protected _reflectionFresnel: boolean;
  118711. /**
  118712. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  118713. * This helps adding a mirror texture on the ground.
  118714. */
  118715. reflectionFresnel: boolean;
  118716. protected _reflectionFalloffDistance: number;
  118717. /**
  118718. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  118719. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  118720. */
  118721. reflectionFalloffDistance: number;
  118722. protected _reflectionAmount: number;
  118723. /**
  118724. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  118725. */
  118726. reflectionAmount: number;
  118727. protected _reflectionReflectance0: number;
  118728. /**
  118729. * This specifies the weight of the reflection at grazing angle.
  118730. */
  118731. reflectionReflectance0: number;
  118732. protected _reflectionReflectance90: number;
  118733. /**
  118734. * This specifies the weight of the reflection at a perpendicular point of view.
  118735. */
  118736. reflectionReflectance90: number;
  118737. /**
  118738. * Sets the reflection reflectance fresnel values according to the default standard
  118739. * empirically know to work well :-)
  118740. */
  118741. set reflectionStandardFresnelWeight(value: number);
  118742. protected _useRGBColor: boolean;
  118743. /**
  118744. * Helps to directly use the maps channels instead of their level.
  118745. */
  118746. useRGBColor: boolean;
  118747. protected _enableNoise: boolean;
  118748. /**
  118749. * This helps reducing the banding effect that could occur on the background.
  118750. */
  118751. enableNoise: boolean;
  118752. /**
  118753. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118754. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  118755. * Recommended to be keep at 1.0 except for special cases.
  118756. */
  118757. get fovMultiplier(): number;
  118758. set fovMultiplier(value: number);
  118759. private _fovMultiplier;
  118760. /**
  118761. * Enable the FOV adjustment feature controlled by fovMultiplier.
  118762. */
  118763. useEquirectangularFOV: boolean;
  118764. private _maxSimultaneousLights;
  118765. /**
  118766. * Number of Simultaneous lights allowed on the material.
  118767. */
  118768. maxSimultaneousLights: int;
  118769. /**
  118770. * Default configuration related to image processing available in the Background Material.
  118771. */
  118772. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118773. /**
  118774. * Keep track of the image processing observer to allow dispose and replace.
  118775. */
  118776. private _imageProcessingObserver;
  118777. /**
  118778. * Attaches a new image processing configuration to the PBR Material.
  118779. * @param configuration (if null the scene configuration will be use)
  118780. */
  118781. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118782. /**
  118783. * Gets the image processing configuration used either in this material.
  118784. */
  118785. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  118786. /**
  118787. * Sets the Default image processing configuration used either in the this material.
  118788. *
  118789. * If sets to null, the scene one is in use.
  118790. */
  118791. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  118792. /**
  118793. * Gets wether the color curves effect is enabled.
  118794. */
  118795. get cameraColorCurvesEnabled(): boolean;
  118796. /**
  118797. * Sets wether the color curves effect is enabled.
  118798. */
  118799. set cameraColorCurvesEnabled(value: boolean);
  118800. /**
  118801. * Gets wether the color grading effect is enabled.
  118802. */
  118803. get cameraColorGradingEnabled(): boolean;
  118804. /**
  118805. * Gets wether the color grading effect is enabled.
  118806. */
  118807. set cameraColorGradingEnabled(value: boolean);
  118808. /**
  118809. * Gets wether tonemapping is enabled or not.
  118810. */
  118811. get cameraToneMappingEnabled(): boolean;
  118812. /**
  118813. * Sets wether tonemapping is enabled or not
  118814. */
  118815. set cameraToneMappingEnabled(value: boolean);
  118816. /**
  118817. * The camera exposure used on this material.
  118818. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118819. * This corresponds to a photographic exposure.
  118820. */
  118821. get cameraExposure(): float;
  118822. /**
  118823. * The camera exposure used on this material.
  118824. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118825. * This corresponds to a photographic exposure.
  118826. */
  118827. set cameraExposure(value: float);
  118828. /**
  118829. * Gets The camera contrast used on this material.
  118830. */
  118831. get cameraContrast(): float;
  118832. /**
  118833. * Sets The camera contrast used on this material.
  118834. */
  118835. set cameraContrast(value: float);
  118836. /**
  118837. * Gets the Color Grading 2D Lookup Texture.
  118838. */
  118839. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  118840. /**
  118841. * Sets the Color Grading 2D Lookup Texture.
  118842. */
  118843. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  118844. /**
  118845. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118846. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118847. * 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;
  118848. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118849. */
  118850. get cameraColorCurves(): Nullable<ColorCurves>;
  118851. /**
  118852. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118854. * 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;
  118855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118856. */
  118857. set cameraColorCurves(value: Nullable<ColorCurves>);
  118858. /**
  118859. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  118860. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  118861. */
  118862. switchToBGR: boolean;
  118863. private _renderTargets;
  118864. private _reflectionControls;
  118865. private _white;
  118866. private _primaryShadowColor;
  118867. private _primaryHighlightColor;
  118868. /**
  118869. * Instantiates a Background Material in the given scene
  118870. * @param name The friendly name of the material
  118871. * @param scene The scene to add the material to
  118872. */
  118873. constructor(name: string, scene: Scene);
  118874. /**
  118875. * Gets a boolean indicating that current material needs to register RTT
  118876. */
  118877. get hasRenderTargetTextures(): boolean;
  118878. /**
  118879. * The entire material has been created in order to prevent overdraw.
  118880. * @returns false
  118881. */
  118882. needAlphaTesting(): boolean;
  118883. /**
  118884. * The entire material has been created in order to prevent overdraw.
  118885. * @returns true if blending is enable
  118886. */
  118887. needAlphaBlending(): boolean;
  118888. /**
  118889. * Checks wether the material is ready to be rendered for a given mesh.
  118890. * @param mesh The mesh to render
  118891. * @param subMesh The submesh to check against
  118892. * @param useInstances Specify wether or not the material is used with instances
  118893. * @returns true if all the dependencies are ready (Textures, Effects...)
  118894. */
  118895. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118896. /**
  118897. * Compute the primary color according to the chosen perceptual color.
  118898. */
  118899. private _computePrimaryColorFromPerceptualColor;
  118900. /**
  118901. * Compute the highlights and shadow colors according to their chosen levels.
  118902. */
  118903. private _computePrimaryColors;
  118904. /**
  118905. * Build the uniform buffer used in the material.
  118906. */
  118907. buildUniformLayout(): void;
  118908. /**
  118909. * Unbind the material.
  118910. */
  118911. unbind(): void;
  118912. /**
  118913. * Bind only the world matrix to the material.
  118914. * @param world The world matrix to bind.
  118915. */
  118916. bindOnlyWorldMatrix(world: Matrix): void;
  118917. /**
  118918. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  118919. * @param world The world matrix to bind.
  118920. * @param subMesh The submesh to bind for.
  118921. */
  118922. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118923. /**
  118924. * Checks to see if a texture is used in the material.
  118925. * @param texture - Base texture to use.
  118926. * @returns - Boolean specifying if a texture is used in the material.
  118927. */
  118928. hasTexture(texture: BaseTexture): boolean;
  118929. /**
  118930. * Dispose the material.
  118931. * @param forceDisposeEffect Force disposal of the associated effect.
  118932. * @param forceDisposeTextures Force disposal of the associated textures.
  118933. */
  118934. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118935. /**
  118936. * Clones the material.
  118937. * @param name The cloned name.
  118938. * @returns The cloned material.
  118939. */
  118940. clone(name: string): BackgroundMaterial;
  118941. /**
  118942. * Serializes the current material to its JSON representation.
  118943. * @returns The JSON representation.
  118944. */
  118945. serialize(): any;
  118946. /**
  118947. * Gets the class name of the material
  118948. * @returns "BackgroundMaterial"
  118949. */
  118950. getClassName(): string;
  118951. /**
  118952. * Parse a JSON input to create back a background material.
  118953. * @param source The JSON data to parse
  118954. * @param scene The scene to create the parsed material in
  118955. * @param rootUrl The root url of the assets the material depends upon
  118956. * @returns the instantiated BackgroundMaterial.
  118957. */
  118958. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  118959. }
  118960. }
  118961. declare module BABYLON {
  118962. /**
  118963. * Represents the different options available during the creation of
  118964. * a Environment helper.
  118965. *
  118966. * This can control the default ground, skybox and image processing setup of your scene.
  118967. */
  118968. export interface IEnvironmentHelperOptions {
  118969. /**
  118970. * Specifies wether or not to create a ground.
  118971. * True by default.
  118972. */
  118973. createGround: boolean;
  118974. /**
  118975. * Specifies the ground size.
  118976. * 15 by default.
  118977. */
  118978. groundSize: number;
  118979. /**
  118980. * The texture used on the ground for the main color.
  118981. * Comes from the BabylonJS CDN by default.
  118982. *
  118983. * Remarks: Can be either a texture or a url.
  118984. */
  118985. groundTexture: string | BaseTexture;
  118986. /**
  118987. * The color mixed in the ground texture by default.
  118988. * BabylonJS clearColor by default.
  118989. */
  118990. groundColor: Color3;
  118991. /**
  118992. * Specifies the ground opacity.
  118993. * 1 by default.
  118994. */
  118995. groundOpacity: number;
  118996. /**
  118997. * Enables the ground to receive shadows.
  118998. * True by default.
  118999. */
  119000. enableGroundShadow: boolean;
  119001. /**
  119002. * Helps preventing the shadow to be fully black on the ground.
  119003. * 0.5 by default.
  119004. */
  119005. groundShadowLevel: number;
  119006. /**
  119007. * Creates a mirror texture attach to the ground.
  119008. * false by default.
  119009. */
  119010. enableGroundMirror: boolean;
  119011. /**
  119012. * Specifies the ground mirror size ratio.
  119013. * 0.3 by default as the default kernel is 64.
  119014. */
  119015. groundMirrorSizeRatio: number;
  119016. /**
  119017. * Specifies the ground mirror blur kernel size.
  119018. * 64 by default.
  119019. */
  119020. groundMirrorBlurKernel: number;
  119021. /**
  119022. * Specifies the ground mirror visibility amount.
  119023. * 1 by default
  119024. */
  119025. groundMirrorAmount: number;
  119026. /**
  119027. * Specifies the ground mirror reflectance weight.
  119028. * This uses the standard weight of the background material to setup the fresnel effect
  119029. * of the mirror.
  119030. * 1 by default.
  119031. */
  119032. groundMirrorFresnelWeight: number;
  119033. /**
  119034. * Specifies the ground mirror Falloff distance.
  119035. * This can helps reducing the size of the reflection.
  119036. * 0 by Default.
  119037. */
  119038. groundMirrorFallOffDistance: number;
  119039. /**
  119040. * Specifies the ground mirror texture type.
  119041. * Unsigned Int by Default.
  119042. */
  119043. groundMirrorTextureType: number;
  119044. /**
  119045. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  119046. * the shown objects.
  119047. */
  119048. groundYBias: number;
  119049. /**
  119050. * Specifies wether or not to create a skybox.
  119051. * True by default.
  119052. */
  119053. createSkybox: boolean;
  119054. /**
  119055. * Specifies the skybox size.
  119056. * 20 by default.
  119057. */
  119058. skyboxSize: number;
  119059. /**
  119060. * The texture used on the skybox for the main color.
  119061. * Comes from the BabylonJS CDN by default.
  119062. *
  119063. * Remarks: Can be either a texture or a url.
  119064. */
  119065. skyboxTexture: string | BaseTexture;
  119066. /**
  119067. * The color mixed in the skybox texture by default.
  119068. * BabylonJS clearColor by default.
  119069. */
  119070. skyboxColor: Color3;
  119071. /**
  119072. * The background rotation around the Y axis of the scene.
  119073. * This helps aligning the key lights of your scene with the background.
  119074. * 0 by default.
  119075. */
  119076. backgroundYRotation: number;
  119077. /**
  119078. * Compute automatically the size of the elements to best fit with the scene.
  119079. */
  119080. sizeAuto: boolean;
  119081. /**
  119082. * Default position of the rootMesh if autoSize is not true.
  119083. */
  119084. rootPosition: Vector3;
  119085. /**
  119086. * Sets up the image processing in the scene.
  119087. * true by default.
  119088. */
  119089. setupImageProcessing: boolean;
  119090. /**
  119091. * The texture used as your environment texture in the scene.
  119092. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  119093. *
  119094. * Remarks: Can be either a texture or a url.
  119095. */
  119096. environmentTexture: string | BaseTexture;
  119097. /**
  119098. * The value of the exposure to apply to the scene.
  119099. * 0.6 by default if setupImageProcessing is true.
  119100. */
  119101. cameraExposure: number;
  119102. /**
  119103. * The value of the contrast to apply to the scene.
  119104. * 1.6 by default if setupImageProcessing is true.
  119105. */
  119106. cameraContrast: number;
  119107. /**
  119108. * Specifies wether or not tonemapping should be enabled in the scene.
  119109. * true by default if setupImageProcessing is true.
  119110. */
  119111. toneMappingEnabled: boolean;
  119112. }
  119113. /**
  119114. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  119115. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  119116. * It also helps with the default setup of your imageProcessing configuration.
  119117. */
  119118. export class EnvironmentHelper {
  119119. /**
  119120. * Default ground texture URL.
  119121. */
  119122. private static _groundTextureCDNUrl;
  119123. /**
  119124. * Default skybox texture URL.
  119125. */
  119126. private static _skyboxTextureCDNUrl;
  119127. /**
  119128. * Default environment texture URL.
  119129. */
  119130. private static _environmentTextureCDNUrl;
  119131. /**
  119132. * Creates the default options for the helper.
  119133. */
  119134. private static _getDefaultOptions;
  119135. private _rootMesh;
  119136. /**
  119137. * Gets the root mesh created by the helper.
  119138. */
  119139. get rootMesh(): Mesh;
  119140. private _skybox;
  119141. /**
  119142. * Gets the skybox created by the helper.
  119143. */
  119144. get skybox(): Nullable<Mesh>;
  119145. private _skyboxTexture;
  119146. /**
  119147. * Gets the skybox texture created by the helper.
  119148. */
  119149. get skyboxTexture(): Nullable<BaseTexture>;
  119150. private _skyboxMaterial;
  119151. /**
  119152. * Gets the skybox material created by the helper.
  119153. */
  119154. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  119155. private _ground;
  119156. /**
  119157. * Gets the ground mesh created by the helper.
  119158. */
  119159. get ground(): Nullable<Mesh>;
  119160. private _groundTexture;
  119161. /**
  119162. * Gets the ground texture created by the helper.
  119163. */
  119164. get groundTexture(): Nullable<BaseTexture>;
  119165. private _groundMirror;
  119166. /**
  119167. * Gets the ground mirror created by the helper.
  119168. */
  119169. get groundMirror(): Nullable<MirrorTexture>;
  119170. /**
  119171. * Gets the ground mirror render list to helps pushing the meshes
  119172. * you wish in the ground reflection.
  119173. */
  119174. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  119175. private _groundMaterial;
  119176. /**
  119177. * Gets the ground material created by the helper.
  119178. */
  119179. get groundMaterial(): Nullable<BackgroundMaterial>;
  119180. /**
  119181. * Stores the creation options.
  119182. */
  119183. private readonly _scene;
  119184. private _options;
  119185. /**
  119186. * This observable will be notified with any error during the creation of the environment,
  119187. * mainly texture creation errors.
  119188. */
  119189. onErrorObservable: Observable<{
  119190. message?: string;
  119191. exception?: any;
  119192. }>;
  119193. /**
  119194. * constructor
  119195. * @param options Defines the options we want to customize the helper
  119196. * @param scene The scene to add the material to
  119197. */
  119198. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  119199. /**
  119200. * Updates the background according to the new options
  119201. * @param options
  119202. */
  119203. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  119204. /**
  119205. * Sets the primary color of all the available elements.
  119206. * @param color the main color to affect to the ground and the background
  119207. */
  119208. setMainColor(color: Color3): void;
  119209. /**
  119210. * Setup the image processing according to the specified options.
  119211. */
  119212. private _setupImageProcessing;
  119213. /**
  119214. * Setup the environment texture according to the specified options.
  119215. */
  119216. private _setupEnvironmentTexture;
  119217. /**
  119218. * Setup the background according to the specified options.
  119219. */
  119220. private _setupBackground;
  119221. /**
  119222. * Get the scene sizes according to the setup.
  119223. */
  119224. private _getSceneSize;
  119225. /**
  119226. * Setup the ground according to the specified options.
  119227. */
  119228. private _setupGround;
  119229. /**
  119230. * Setup the ground material according to the specified options.
  119231. */
  119232. private _setupGroundMaterial;
  119233. /**
  119234. * Setup the ground diffuse texture according to the specified options.
  119235. */
  119236. private _setupGroundDiffuseTexture;
  119237. /**
  119238. * Setup the ground mirror texture according to the specified options.
  119239. */
  119240. private _setupGroundMirrorTexture;
  119241. /**
  119242. * Setup the ground to receive the mirror texture.
  119243. */
  119244. private _setupMirrorInGroundMaterial;
  119245. /**
  119246. * Setup the skybox according to the specified options.
  119247. */
  119248. private _setupSkybox;
  119249. /**
  119250. * Setup the skybox material according to the specified options.
  119251. */
  119252. private _setupSkyboxMaterial;
  119253. /**
  119254. * Setup the skybox reflection texture according to the specified options.
  119255. */
  119256. private _setupSkyboxReflectionTexture;
  119257. private _errorHandler;
  119258. /**
  119259. * Dispose all the elements created by the Helper.
  119260. */
  119261. dispose(): void;
  119262. }
  119263. }
  119264. declare module BABYLON {
  119265. /**
  119266. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  119267. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  119268. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  119269. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119270. */
  119271. export class PhotoDome extends TransformNode {
  119272. /**
  119273. * Define the image as a Monoscopic panoramic 360 image.
  119274. */
  119275. static readonly MODE_MONOSCOPIC: number;
  119276. /**
  119277. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119278. */
  119279. static readonly MODE_TOPBOTTOM: number;
  119280. /**
  119281. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119282. */
  119283. static readonly MODE_SIDEBYSIDE: number;
  119284. private _useDirectMapping;
  119285. /**
  119286. * The texture being displayed on the sphere
  119287. */
  119288. protected _photoTexture: Texture;
  119289. /**
  119290. * Gets or sets the texture being displayed on the sphere
  119291. */
  119292. get photoTexture(): Texture;
  119293. set photoTexture(value: Texture);
  119294. /**
  119295. * Observable raised when an error occured while loading the 360 image
  119296. */
  119297. onLoadErrorObservable: Observable<string>;
  119298. /**
  119299. * The skybox material
  119300. */
  119301. protected _material: BackgroundMaterial;
  119302. /**
  119303. * The surface used for the skybox
  119304. */
  119305. protected _mesh: Mesh;
  119306. /**
  119307. * Gets the mesh used for the skybox.
  119308. */
  119309. get mesh(): Mesh;
  119310. /**
  119311. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119312. * Also see the options.resolution property.
  119313. */
  119314. get fovMultiplier(): number;
  119315. set fovMultiplier(value: number);
  119316. private _imageMode;
  119317. /**
  119318. * Gets or set the current video mode for the video. It can be:
  119319. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  119320. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119321. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119322. */
  119323. get imageMode(): number;
  119324. set imageMode(value: number);
  119325. /**
  119326. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  119327. * @param name Element's name, child elements will append suffixes for their own names.
  119328. * @param urlsOfPhoto defines the url of the photo to display
  119329. * @param options defines an object containing optional or exposed sub element properties
  119330. * @param onError defines a callback called when an error occured while loading the texture
  119331. */
  119332. constructor(name: string, urlOfPhoto: string, options: {
  119333. resolution?: number;
  119334. size?: number;
  119335. useDirectMapping?: boolean;
  119336. faceForward?: boolean;
  119337. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  119338. private _onBeforeCameraRenderObserver;
  119339. private _changeImageMode;
  119340. /**
  119341. * Releases resources associated with this node.
  119342. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119343. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119344. */
  119345. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119346. }
  119347. }
  119348. declare module BABYLON {
  119349. /**
  119350. * Class used to host RGBD texture specific utilities
  119351. */
  119352. export class RGBDTextureTools {
  119353. /**
  119354. * Expand the RGBD Texture from RGBD to Half Float if possible.
  119355. * @param texture the texture to expand.
  119356. */
  119357. static ExpandRGBDTexture(texture: Texture): void;
  119358. }
  119359. }
  119360. declare module BABYLON {
  119361. /**
  119362. * Class used to host texture specific utilities
  119363. */
  119364. export class BRDFTextureTools {
  119365. /**
  119366. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  119367. * @param scene defines the hosting scene
  119368. * @returns the environment BRDF texture
  119369. */
  119370. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  119371. private static _environmentBRDFBase64Texture;
  119372. }
  119373. }
  119374. declare module BABYLON {
  119375. /**
  119376. * @hidden
  119377. */
  119378. export interface IMaterialClearCoatDefines {
  119379. CLEARCOAT: boolean;
  119380. CLEARCOAT_DEFAULTIOR: boolean;
  119381. CLEARCOAT_TEXTURE: boolean;
  119382. CLEARCOAT_TEXTUREDIRECTUV: number;
  119383. CLEARCOAT_BUMP: boolean;
  119384. CLEARCOAT_BUMPDIRECTUV: number;
  119385. CLEARCOAT_TINT: boolean;
  119386. CLEARCOAT_TINT_TEXTURE: boolean;
  119387. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  119388. /** @hidden */
  119389. _areTexturesDirty: boolean;
  119390. }
  119391. /**
  119392. * Define the code related to the clear coat parameters of the pbr material.
  119393. */
  119394. export class PBRClearCoatConfiguration {
  119395. /**
  119396. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119397. * The default fits with a polyurethane material.
  119398. */
  119399. private static readonly _DefaultIndexOfRefraction;
  119400. private _isEnabled;
  119401. /**
  119402. * Defines if the clear coat is enabled in the material.
  119403. */
  119404. isEnabled: boolean;
  119405. /**
  119406. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  119407. */
  119408. intensity: number;
  119409. /**
  119410. * Defines the clear coat layer roughness.
  119411. */
  119412. roughness: number;
  119413. private _indexOfRefraction;
  119414. /**
  119415. * Defines the index of refraction of the clear coat.
  119416. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119417. * The default fits with a polyurethane material.
  119418. * Changing the default value is more performance intensive.
  119419. */
  119420. indexOfRefraction: number;
  119421. private _texture;
  119422. /**
  119423. * Stores the clear coat values in a texture.
  119424. */
  119425. texture: Nullable<BaseTexture>;
  119426. private _bumpTexture;
  119427. /**
  119428. * Define the clear coat specific bump texture.
  119429. */
  119430. bumpTexture: Nullable<BaseTexture>;
  119431. private _isTintEnabled;
  119432. /**
  119433. * Defines if the clear coat tint is enabled in the material.
  119434. */
  119435. isTintEnabled: boolean;
  119436. /**
  119437. * Defines the clear coat tint of the material.
  119438. * This is only use if tint is enabled
  119439. */
  119440. tintColor: Color3;
  119441. /**
  119442. * Defines the distance at which the tint color should be found in the
  119443. * clear coat media.
  119444. * This is only use if tint is enabled
  119445. */
  119446. tintColorAtDistance: number;
  119447. /**
  119448. * Defines the clear coat layer thickness.
  119449. * This is only use if tint is enabled
  119450. */
  119451. tintThickness: number;
  119452. private _tintTexture;
  119453. /**
  119454. * Stores the clear tint values in a texture.
  119455. * rgb is tint
  119456. * a is a thickness factor
  119457. */
  119458. tintTexture: Nullable<BaseTexture>;
  119459. /** @hidden */
  119460. private _internalMarkAllSubMeshesAsTexturesDirty;
  119461. /** @hidden */
  119462. _markAllSubMeshesAsTexturesDirty(): void;
  119463. /**
  119464. * Instantiate a new istance of clear coat configuration.
  119465. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119466. */
  119467. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119468. /**
  119469. * Gets wehter the submesh is ready to be used or not.
  119470. * @param defines the list of "defines" to update.
  119471. * @param scene defines the scene the material belongs to.
  119472. * @param engine defines the engine the material belongs to.
  119473. * @param disableBumpMap defines wether the material disables bump or not.
  119474. * @returns - boolean indicating that the submesh is ready or not.
  119475. */
  119476. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  119477. /**
  119478. * Checks to see if a texture is used in the material.
  119479. * @param defines the list of "defines" to update.
  119480. * @param scene defines the scene to the material belongs to.
  119481. */
  119482. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  119483. /**
  119484. * Binds the material data.
  119485. * @param uniformBuffer defines the Uniform buffer to fill in.
  119486. * @param scene defines the scene the material belongs to.
  119487. * @param engine defines the engine the material belongs to.
  119488. * @param disableBumpMap defines wether the material disables bump or not.
  119489. * @param isFrozen defines wether the material is frozen or not.
  119490. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  119491. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  119492. */
  119493. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  119494. /**
  119495. * Checks to see if a texture is used in the material.
  119496. * @param texture - Base texture to use.
  119497. * @returns - Boolean specifying if a texture is used in the material.
  119498. */
  119499. hasTexture(texture: BaseTexture): boolean;
  119500. /**
  119501. * Returns an array of the actively used textures.
  119502. * @param activeTextures Array of BaseTextures
  119503. */
  119504. getActiveTextures(activeTextures: BaseTexture[]): void;
  119505. /**
  119506. * Returns the animatable textures.
  119507. * @param animatables Array of animatable textures.
  119508. */
  119509. getAnimatables(animatables: IAnimatable[]): void;
  119510. /**
  119511. * Disposes the resources of the material.
  119512. * @param forceDisposeTextures - Forces the disposal of all textures.
  119513. */
  119514. dispose(forceDisposeTextures?: boolean): void;
  119515. /**
  119516. * Get the current class name of the texture useful for serialization or dynamic coding.
  119517. * @returns "PBRClearCoatConfiguration"
  119518. */
  119519. getClassName(): string;
  119520. /**
  119521. * Add fallbacks to the effect fallbacks list.
  119522. * @param defines defines the Base texture to use.
  119523. * @param fallbacks defines the current fallback list.
  119524. * @param currentRank defines the current fallback rank.
  119525. * @returns the new fallback rank.
  119526. */
  119527. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119528. /**
  119529. * Add the required uniforms to the current list.
  119530. * @param uniforms defines the current uniform list.
  119531. */
  119532. static AddUniforms(uniforms: string[]): void;
  119533. /**
  119534. * Add the required samplers to the current list.
  119535. * @param samplers defines the current sampler list.
  119536. */
  119537. static AddSamplers(samplers: string[]): void;
  119538. /**
  119539. * Add the required uniforms to the current buffer.
  119540. * @param uniformBuffer defines the current uniform buffer.
  119541. */
  119542. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119543. /**
  119544. * Makes a duplicate of the current configuration into another one.
  119545. * @param clearCoatConfiguration define the config where to copy the info
  119546. */
  119547. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  119548. /**
  119549. * Serializes this clear coat configuration.
  119550. * @returns - An object with the serialized config.
  119551. */
  119552. serialize(): any;
  119553. /**
  119554. * Parses a anisotropy Configuration from a serialized object.
  119555. * @param source - Serialized object.
  119556. * @param scene Defines the scene we are parsing for
  119557. * @param rootUrl Defines the rootUrl to load from
  119558. */
  119559. parse(source: any, scene: Scene, rootUrl: string): void;
  119560. }
  119561. }
  119562. declare module BABYLON {
  119563. /**
  119564. * @hidden
  119565. */
  119566. export interface IMaterialAnisotropicDefines {
  119567. ANISOTROPIC: boolean;
  119568. ANISOTROPIC_TEXTURE: boolean;
  119569. ANISOTROPIC_TEXTUREDIRECTUV: number;
  119570. MAINUV1: boolean;
  119571. _areTexturesDirty: boolean;
  119572. _needUVs: boolean;
  119573. }
  119574. /**
  119575. * Define the code related to the anisotropic parameters of the pbr material.
  119576. */
  119577. export class PBRAnisotropicConfiguration {
  119578. private _isEnabled;
  119579. /**
  119580. * Defines if the anisotropy is enabled in the material.
  119581. */
  119582. isEnabled: boolean;
  119583. /**
  119584. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  119585. */
  119586. intensity: number;
  119587. /**
  119588. * Defines if the effect is along the tangents, bitangents or in between.
  119589. * By default, the effect is "strectching" the highlights along the tangents.
  119590. */
  119591. direction: Vector2;
  119592. private _texture;
  119593. /**
  119594. * Stores the anisotropy values in a texture.
  119595. * rg is direction (like normal from -1 to 1)
  119596. * b is a intensity
  119597. */
  119598. texture: Nullable<BaseTexture>;
  119599. /** @hidden */
  119600. private _internalMarkAllSubMeshesAsTexturesDirty;
  119601. /** @hidden */
  119602. _markAllSubMeshesAsTexturesDirty(): void;
  119603. /**
  119604. * Instantiate a new istance of anisotropy configuration.
  119605. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119606. */
  119607. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119608. /**
  119609. * Specifies that the submesh is ready to be used.
  119610. * @param defines the list of "defines" to update.
  119611. * @param scene defines the scene the material belongs to.
  119612. * @returns - boolean indicating that the submesh is ready or not.
  119613. */
  119614. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  119615. /**
  119616. * Checks to see if a texture is used in the material.
  119617. * @param defines the list of "defines" to update.
  119618. * @param mesh the mesh we are preparing the defines for.
  119619. * @param scene defines the scene the material belongs to.
  119620. */
  119621. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  119622. /**
  119623. * Binds the material data.
  119624. * @param uniformBuffer defines the Uniform buffer to fill in.
  119625. * @param scene defines the scene the material belongs to.
  119626. * @param isFrozen defines wether the material is frozen or not.
  119627. */
  119628. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119629. /**
  119630. * Checks to see if a texture is used in the material.
  119631. * @param texture - Base texture to use.
  119632. * @returns - Boolean specifying if a texture is used in the material.
  119633. */
  119634. hasTexture(texture: BaseTexture): boolean;
  119635. /**
  119636. * Returns an array of the actively used textures.
  119637. * @param activeTextures Array of BaseTextures
  119638. */
  119639. getActiveTextures(activeTextures: BaseTexture[]): void;
  119640. /**
  119641. * Returns the animatable textures.
  119642. * @param animatables Array of animatable textures.
  119643. */
  119644. getAnimatables(animatables: IAnimatable[]): void;
  119645. /**
  119646. * Disposes the resources of the material.
  119647. * @param forceDisposeTextures - Forces the disposal of all textures.
  119648. */
  119649. dispose(forceDisposeTextures?: boolean): void;
  119650. /**
  119651. * Get the current class name of the texture useful for serialization or dynamic coding.
  119652. * @returns "PBRAnisotropicConfiguration"
  119653. */
  119654. getClassName(): string;
  119655. /**
  119656. * Add fallbacks to the effect fallbacks list.
  119657. * @param defines defines the Base texture to use.
  119658. * @param fallbacks defines the current fallback list.
  119659. * @param currentRank defines the current fallback rank.
  119660. * @returns the new fallback rank.
  119661. */
  119662. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119663. /**
  119664. * Add the required uniforms to the current list.
  119665. * @param uniforms defines the current uniform list.
  119666. */
  119667. static AddUniforms(uniforms: string[]): void;
  119668. /**
  119669. * Add the required uniforms to the current buffer.
  119670. * @param uniformBuffer defines the current uniform buffer.
  119671. */
  119672. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119673. /**
  119674. * Add the required samplers to the current list.
  119675. * @param samplers defines the current sampler list.
  119676. */
  119677. static AddSamplers(samplers: string[]): void;
  119678. /**
  119679. * Makes a duplicate of the current configuration into another one.
  119680. * @param anisotropicConfiguration define the config where to copy the info
  119681. */
  119682. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  119683. /**
  119684. * Serializes this anisotropy configuration.
  119685. * @returns - An object with the serialized config.
  119686. */
  119687. serialize(): any;
  119688. /**
  119689. * Parses a anisotropy Configuration from a serialized object.
  119690. * @param source - Serialized object.
  119691. * @param scene Defines the scene we are parsing for
  119692. * @param rootUrl Defines the rootUrl to load from
  119693. */
  119694. parse(source: any, scene: Scene, rootUrl: string): void;
  119695. }
  119696. }
  119697. declare module BABYLON {
  119698. /**
  119699. * @hidden
  119700. */
  119701. export interface IMaterialBRDFDefines {
  119702. BRDF_V_HEIGHT_CORRELATED: boolean;
  119703. MS_BRDF_ENERGY_CONSERVATION: boolean;
  119704. SPHERICAL_HARMONICS: boolean;
  119705. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  119706. /** @hidden */
  119707. _areMiscDirty: boolean;
  119708. }
  119709. /**
  119710. * Define the code related to the BRDF parameters of the pbr material.
  119711. */
  119712. export class PBRBRDFConfiguration {
  119713. /**
  119714. * Default value used for the energy conservation.
  119715. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119716. */
  119717. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  119718. /**
  119719. * Default value used for the Smith Visibility Height Correlated mode.
  119720. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119721. */
  119722. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  119723. /**
  119724. * Default value used for the IBL diffuse part.
  119725. * This can help switching back to the polynomials mode globally which is a tiny bit
  119726. * less GPU intensive at the drawback of a lower quality.
  119727. */
  119728. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  119729. /**
  119730. * Default value used for activating energy conservation for the specular workflow.
  119731. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119732. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119733. */
  119734. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  119735. private _useEnergyConservation;
  119736. /**
  119737. * Defines if the material uses energy conservation.
  119738. */
  119739. useEnergyConservation: boolean;
  119740. private _useSmithVisibilityHeightCorrelated;
  119741. /**
  119742. * LEGACY Mode set to false
  119743. * Defines if the material uses height smith correlated visibility term.
  119744. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  119745. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  119746. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  119747. * Not relying on height correlated will also disable energy conservation.
  119748. */
  119749. useSmithVisibilityHeightCorrelated: boolean;
  119750. private _useSphericalHarmonics;
  119751. /**
  119752. * LEGACY Mode set to false
  119753. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  119754. * diffuse part of the IBL.
  119755. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  119756. * to the ground truth.
  119757. */
  119758. useSphericalHarmonics: boolean;
  119759. private _useSpecularGlossinessInputEnergyConservation;
  119760. /**
  119761. * Defines if the material uses energy conservation, when the specular workflow is active.
  119762. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119763. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119764. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  119765. */
  119766. useSpecularGlossinessInputEnergyConservation: boolean;
  119767. /** @hidden */
  119768. private _internalMarkAllSubMeshesAsMiscDirty;
  119769. /** @hidden */
  119770. _markAllSubMeshesAsMiscDirty(): void;
  119771. /**
  119772. * Instantiate a new istance of clear coat configuration.
  119773. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  119774. */
  119775. constructor(markAllSubMeshesAsMiscDirty: () => void);
  119776. /**
  119777. * Checks to see if a texture is used in the material.
  119778. * @param defines the list of "defines" to update.
  119779. */
  119780. prepareDefines(defines: IMaterialBRDFDefines): void;
  119781. /**
  119782. * Get the current class name of the texture useful for serialization or dynamic coding.
  119783. * @returns "PBRClearCoatConfiguration"
  119784. */
  119785. getClassName(): string;
  119786. /**
  119787. * Makes a duplicate of the current configuration into another one.
  119788. * @param brdfConfiguration define the config where to copy the info
  119789. */
  119790. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  119791. /**
  119792. * Serializes this BRDF configuration.
  119793. * @returns - An object with the serialized config.
  119794. */
  119795. serialize(): any;
  119796. /**
  119797. * Parses a anisotropy Configuration from a serialized object.
  119798. * @param source - Serialized object.
  119799. * @param scene Defines the scene we are parsing for
  119800. * @param rootUrl Defines the rootUrl to load from
  119801. */
  119802. parse(source: any, scene: Scene, rootUrl: string): void;
  119803. }
  119804. }
  119805. declare module BABYLON {
  119806. /**
  119807. * @hidden
  119808. */
  119809. export interface IMaterialSheenDefines {
  119810. SHEEN: boolean;
  119811. SHEEN_TEXTURE: boolean;
  119812. SHEEN_TEXTUREDIRECTUV: number;
  119813. SHEEN_LINKWITHALBEDO: boolean;
  119814. /** @hidden */
  119815. _areTexturesDirty: boolean;
  119816. }
  119817. /**
  119818. * Define the code related to the Sheen parameters of the pbr material.
  119819. */
  119820. export class PBRSheenConfiguration {
  119821. private _isEnabled;
  119822. /**
  119823. * Defines if the material uses sheen.
  119824. */
  119825. isEnabled: boolean;
  119826. private _linkSheenWithAlbedo;
  119827. /**
  119828. * Defines if the sheen is linked to the sheen color.
  119829. */
  119830. linkSheenWithAlbedo: boolean;
  119831. /**
  119832. * Defines the sheen intensity.
  119833. */
  119834. intensity: number;
  119835. /**
  119836. * Defines the sheen color.
  119837. */
  119838. color: Color3;
  119839. private _texture;
  119840. /**
  119841. * Stores the sheen tint values in a texture.
  119842. * rgb is tint
  119843. * a is a intensity
  119844. */
  119845. texture: Nullable<BaseTexture>;
  119846. /** @hidden */
  119847. private _internalMarkAllSubMeshesAsTexturesDirty;
  119848. /** @hidden */
  119849. _markAllSubMeshesAsTexturesDirty(): void;
  119850. /**
  119851. * Instantiate a new istance of clear coat configuration.
  119852. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119853. */
  119854. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119855. /**
  119856. * Specifies that the submesh is ready to be used.
  119857. * @param defines the list of "defines" to update.
  119858. * @param scene defines the scene the material belongs to.
  119859. * @returns - boolean indicating that the submesh is ready or not.
  119860. */
  119861. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  119862. /**
  119863. * Checks to see if a texture is used in the material.
  119864. * @param defines the list of "defines" to update.
  119865. * @param scene defines the scene the material belongs to.
  119866. */
  119867. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  119868. /**
  119869. * Binds the material data.
  119870. * @param uniformBuffer defines the Uniform buffer to fill in.
  119871. * @param scene defines the scene the material belongs to.
  119872. * @param isFrozen defines wether the material is frozen or not.
  119873. */
  119874. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119875. /**
  119876. * Checks to see if a texture is used in the material.
  119877. * @param texture - Base texture to use.
  119878. * @returns - Boolean specifying if a texture is used in the material.
  119879. */
  119880. hasTexture(texture: BaseTexture): boolean;
  119881. /**
  119882. * Returns an array of the actively used textures.
  119883. * @param activeTextures Array of BaseTextures
  119884. */
  119885. getActiveTextures(activeTextures: BaseTexture[]): void;
  119886. /**
  119887. * Returns the animatable textures.
  119888. * @param animatables Array of animatable textures.
  119889. */
  119890. getAnimatables(animatables: IAnimatable[]): void;
  119891. /**
  119892. * Disposes the resources of the material.
  119893. * @param forceDisposeTextures - Forces the disposal of all textures.
  119894. */
  119895. dispose(forceDisposeTextures?: boolean): void;
  119896. /**
  119897. * Get the current class name of the texture useful for serialization or dynamic coding.
  119898. * @returns "PBRSheenConfiguration"
  119899. */
  119900. getClassName(): string;
  119901. /**
  119902. * Add fallbacks to the effect fallbacks list.
  119903. * @param defines defines the Base texture to use.
  119904. * @param fallbacks defines the current fallback list.
  119905. * @param currentRank defines the current fallback rank.
  119906. * @returns the new fallback rank.
  119907. */
  119908. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119909. /**
  119910. * Add the required uniforms to the current list.
  119911. * @param uniforms defines the current uniform list.
  119912. */
  119913. static AddUniforms(uniforms: string[]): void;
  119914. /**
  119915. * Add the required uniforms to the current buffer.
  119916. * @param uniformBuffer defines the current uniform buffer.
  119917. */
  119918. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119919. /**
  119920. * Add the required samplers to the current list.
  119921. * @param samplers defines the current sampler list.
  119922. */
  119923. static AddSamplers(samplers: string[]): void;
  119924. /**
  119925. * Makes a duplicate of the current configuration into another one.
  119926. * @param sheenConfiguration define the config where to copy the info
  119927. */
  119928. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  119929. /**
  119930. * Serializes this BRDF configuration.
  119931. * @returns - An object with the serialized config.
  119932. */
  119933. serialize(): any;
  119934. /**
  119935. * Parses a anisotropy Configuration from a serialized object.
  119936. * @param source - Serialized object.
  119937. * @param scene Defines the scene we are parsing for
  119938. * @param rootUrl Defines the rootUrl to load from
  119939. */
  119940. parse(source: any, scene: Scene, rootUrl: string): void;
  119941. }
  119942. }
  119943. declare module BABYLON {
  119944. /**
  119945. * @hidden
  119946. */
  119947. export interface IMaterialSubSurfaceDefines {
  119948. SUBSURFACE: boolean;
  119949. SS_REFRACTION: boolean;
  119950. SS_TRANSLUCENCY: boolean;
  119951. SS_SCATERRING: boolean;
  119952. SS_THICKNESSANDMASK_TEXTURE: boolean;
  119953. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  119954. SS_REFRACTIONMAP_3D: boolean;
  119955. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  119956. SS_LODINREFRACTIONALPHA: boolean;
  119957. SS_GAMMAREFRACTION: boolean;
  119958. SS_RGBDREFRACTION: boolean;
  119959. SS_LINEARSPECULARREFRACTION: boolean;
  119960. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  119961. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  119962. /** @hidden */
  119963. _areTexturesDirty: boolean;
  119964. }
  119965. /**
  119966. * Define the code related to the sub surface parameters of the pbr material.
  119967. */
  119968. export class PBRSubSurfaceConfiguration {
  119969. private _isRefractionEnabled;
  119970. /**
  119971. * Defines if the refraction is enabled in the material.
  119972. */
  119973. isRefractionEnabled: boolean;
  119974. private _isTranslucencyEnabled;
  119975. /**
  119976. * Defines if the translucency is enabled in the material.
  119977. */
  119978. isTranslucencyEnabled: boolean;
  119979. private _isScatteringEnabled;
  119980. /**
  119981. * Defines the refraction intensity of the material.
  119982. * The refraction when enabled replaces the Diffuse part of the material.
  119983. * The intensity helps transitionning between diffuse and refraction.
  119984. */
  119985. refractionIntensity: number;
  119986. /**
  119987. * Defines the translucency intensity of the material.
  119988. * When translucency has been enabled, this defines how much of the "translucency"
  119989. * is addded to the diffuse part of the material.
  119990. */
  119991. translucencyIntensity: number;
  119992. /**
  119993. * Defines the scattering intensity of the material.
  119994. * When scattering has been enabled, this defines how much of the "scattered light"
  119995. * is addded to the diffuse part of the material.
  119996. */
  119997. scatteringIntensity: number;
  119998. private _thicknessTexture;
  119999. /**
  120000. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  120001. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  120002. * 0 would mean minimumThickness
  120003. * 1 would mean maximumThickness
  120004. * The other channels might be use as a mask to vary the different effects intensity.
  120005. */
  120006. thicknessTexture: Nullable<BaseTexture>;
  120007. private _refractionTexture;
  120008. /**
  120009. * Defines the texture to use for refraction.
  120010. */
  120011. refractionTexture: Nullable<BaseTexture>;
  120012. private _indexOfRefraction;
  120013. /**
  120014. * Defines the index of refraction used in the material.
  120015. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  120016. */
  120017. indexOfRefraction: number;
  120018. private _invertRefractionY;
  120019. /**
  120020. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  120021. */
  120022. invertRefractionY: boolean;
  120023. private _linkRefractionWithTransparency;
  120024. /**
  120025. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  120026. * Materials half opaque for instance using refraction could benefit from this control.
  120027. */
  120028. linkRefractionWithTransparency: boolean;
  120029. /**
  120030. * Defines the minimum thickness stored in the thickness map.
  120031. * If no thickness map is defined, this value will be used to simulate thickness.
  120032. */
  120033. minimumThickness: number;
  120034. /**
  120035. * Defines the maximum thickness stored in the thickness map.
  120036. */
  120037. maximumThickness: number;
  120038. /**
  120039. * Defines the volume tint of the material.
  120040. * This is used for both translucency and scattering.
  120041. */
  120042. tintColor: Color3;
  120043. /**
  120044. * Defines the distance at which the tint color should be found in the media.
  120045. * This is used for refraction only.
  120046. */
  120047. tintColorAtDistance: number;
  120048. /**
  120049. * Defines how far each channel transmit through the media.
  120050. * It is defined as a color to simplify it selection.
  120051. */
  120052. diffusionDistance: Color3;
  120053. private _useMaskFromThicknessTexture;
  120054. /**
  120055. * Stores the intensity of the different subsurface effects in the thickness texture.
  120056. * * the green channel is the translucency intensity.
  120057. * * the blue channel is the scattering intensity.
  120058. * * the alpha channel is the refraction intensity.
  120059. */
  120060. useMaskFromThicknessTexture: boolean;
  120061. /** @hidden */
  120062. private _internalMarkAllSubMeshesAsTexturesDirty;
  120063. /** @hidden */
  120064. _markAllSubMeshesAsTexturesDirty(): void;
  120065. /**
  120066. * Instantiate a new istance of sub surface configuration.
  120067. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120068. */
  120069. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120070. /**
  120071. * Gets wehter the submesh is ready to be used or not.
  120072. * @param defines the list of "defines" to update.
  120073. * @param scene defines the scene the material belongs to.
  120074. * @returns - boolean indicating that the submesh is ready or not.
  120075. */
  120076. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  120077. /**
  120078. * Checks to see if a texture is used in the material.
  120079. * @param defines the list of "defines" to update.
  120080. * @param scene defines the scene to the material belongs to.
  120081. */
  120082. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  120083. /**
  120084. * Binds the material data.
  120085. * @param uniformBuffer defines the Uniform buffer to fill in.
  120086. * @param scene defines the scene the material belongs to.
  120087. * @param engine defines the engine the material belongs to.
  120088. * @param isFrozen defines wether the material is frozen or not.
  120089. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  120090. */
  120091. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  120092. /**
  120093. * Unbinds the material from the mesh.
  120094. * @param activeEffect defines the effect that should be unbound from.
  120095. * @returns true if unbound, otherwise false
  120096. */
  120097. unbind(activeEffect: Effect): boolean;
  120098. /**
  120099. * Returns the texture used for refraction or null if none is used.
  120100. * @param scene defines the scene the material belongs to.
  120101. * @returns - Refraction texture if present. If no refraction texture and refraction
  120102. * is linked with transparency, returns environment texture. Otherwise, returns null.
  120103. */
  120104. private _getRefractionTexture;
  120105. /**
  120106. * Returns true if alpha blending should be disabled.
  120107. */
  120108. get disableAlphaBlending(): boolean;
  120109. /**
  120110. * Fills the list of render target textures.
  120111. * @param renderTargets the list of render targets to update
  120112. */
  120113. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  120114. /**
  120115. * Checks to see if a texture is used in the material.
  120116. * @param texture - Base texture to use.
  120117. * @returns - Boolean specifying if a texture is used in the material.
  120118. */
  120119. hasTexture(texture: BaseTexture): boolean;
  120120. /**
  120121. * Gets a boolean indicating that current material needs to register RTT
  120122. * @returns true if this uses a render target otherwise false.
  120123. */
  120124. hasRenderTargetTextures(): boolean;
  120125. /**
  120126. * Returns an array of the actively used textures.
  120127. * @param activeTextures Array of BaseTextures
  120128. */
  120129. getActiveTextures(activeTextures: BaseTexture[]): void;
  120130. /**
  120131. * Returns the animatable textures.
  120132. * @param animatables Array of animatable textures.
  120133. */
  120134. getAnimatables(animatables: IAnimatable[]): void;
  120135. /**
  120136. * Disposes the resources of the material.
  120137. * @param forceDisposeTextures - Forces the disposal of all textures.
  120138. */
  120139. dispose(forceDisposeTextures?: boolean): void;
  120140. /**
  120141. * Get the current class name of the texture useful for serialization or dynamic coding.
  120142. * @returns "PBRSubSurfaceConfiguration"
  120143. */
  120144. getClassName(): string;
  120145. /**
  120146. * Add fallbacks to the effect fallbacks list.
  120147. * @param defines defines the Base texture to use.
  120148. * @param fallbacks defines the current fallback list.
  120149. * @param currentRank defines the current fallback rank.
  120150. * @returns the new fallback rank.
  120151. */
  120152. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120153. /**
  120154. * Add the required uniforms to the current list.
  120155. * @param uniforms defines the current uniform list.
  120156. */
  120157. static AddUniforms(uniforms: string[]): void;
  120158. /**
  120159. * Add the required samplers to the current list.
  120160. * @param samplers defines the current sampler list.
  120161. */
  120162. static AddSamplers(samplers: string[]): void;
  120163. /**
  120164. * Add the required uniforms to the current buffer.
  120165. * @param uniformBuffer defines the current uniform buffer.
  120166. */
  120167. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120168. /**
  120169. * Makes a duplicate of the current configuration into another one.
  120170. * @param configuration define the config where to copy the info
  120171. */
  120172. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  120173. /**
  120174. * Serializes this Sub Surface configuration.
  120175. * @returns - An object with the serialized config.
  120176. */
  120177. serialize(): any;
  120178. /**
  120179. * Parses a anisotropy Configuration from a serialized object.
  120180. * @param source - Serialized object.
  120181. * @param scene Defines the scene we are parsing for
  120182. * @param rootUrl Defines the rootUrl to load from
  120183. */
  120184. parse(source: any, scene: Scene, rootUrl: string): void;
  120185. }
  120186. }
  120187. declare module BABYLON {
  120188. /** @hidden */
  120189. export var pbrFragmentDeclaration: {
  120190. name: string;
  120191. shader: string;
  120192. };
  120193. }
  120194. declare module BABYLON {
  120195. /** @hidden */
  120196. export var pbrUboDeclaration: {
  120197. name: string;
  120198. shader: string;
  120199. };
  120200. }
  120201. declare module BABYLON {
  120202. /** @hidden */
  120203. export var pbrFragmentExtraDeclaration: {
  120204. name: string;
  120205. shader: string;
  120206. };
  120207. }
  120208. declare module BABYLON {
  120209. /** @hidden */
  120210. export var pbrFragmentSamplersDeclaration: {
  120211. name: string;
  120212. shader: string;
  120213. };
  120214. }
  120215. declare module BABYLON {
  120216. /** @hidden */
  120217. export var pbrHelperFunctions: {
  120218. name: string;
  120219. shader: string;
  120220. };
  120221. }
  120222. declare module BABYLON {
  120223. /** @hidden */
  120224. export var harmonicsFunctions: {
  120225. name: string;
  120226. shader: string;
  120227. };
  120228. }
  120229. declare module BABYLON {
  120230. /** @hidden */
  120231. export var pbrDirectLightingSetupFunctions: {
  120232. name: string;
  120233. shader: string;
  120234. };
  120235. }
  120236. declare module BABYLON {
  120237. /** @hidden */
  120238. export var pbrDirectLightingFalloffFunctions: {
  120239. name: string;
  120240. shader: string;
  120241. };
  120242. }
  120243. declare module BABYLON {
  120244. /** @hidden */
  120245. export var pbrBRDFFunctions: {
  120246. name: string;
  120247. shader: string;
  120248. };
  120249. }
  120250. declare module BABYLON {
  120251. /** @hidden */
  120252. export var pbrDirectLightingFunctions: {
  120253. name: string;
  120254. shader: string;
  120255. };
  120256. }
  120257. declare module BABYLON {
  120258. /** @hidden */
  120259. export var pbrIBLFunctions: {
  120260. name: string;
  120261. shader: string;
  120262. };
  120263. }
  120264. declare module BABYLON {
  120265. /** @hidden */
  120266. export var pbrDebug: {
  120267. name: string;
  120268. shader: string;
  120269. };
  120270. }
  120271. declare module BABYLON {
  120272. /** @hidden */
  120273. export var pbrPixelShader: {
  120274. name: string;
  120275. shader: string;
  120276. };
  120277. }
  120278. declare module BABYLON {
  120279. /** @hidden */
  120280. export var pbrVertexDeclaration: {
  120281. name: string;
  120282. shader: string;
  120283. };
  120284. }
  120285. declare module BABYLON {
  120286. /** @hidden */
  120287. export var pbrVertexShader: {
  120288. name: string;
  120289. shader: string;
  120290. };
  120291. }
  120292. declare module BABYLON {
  120293. /**
  120294. * Manages the defines for the PBR Material.
  120295. * @hidden
  120296. */
  120297. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  120298. PBR: boolean;
  120299. MAINUV1: boolean;
  120300. MAINUV2: boolean;
  120301. UV1: boolean;
  120302. UV2: boolean;
  120303. ALBEDO: boolean;
  120304. ALBEDODIRECTUV: number;
  120305. VERTEXCOLOR: boolean;
  120306. AMBIENT: boolean;
  120307. AMBIENTDIRECTUV: number;
  120308. AMBIENTINGRAYSCALE: boolean;
  120309. OPACITY: boolean;
  120310. VERTEXALPHA: boolean;
  120311. OPACITYDIRECTUV: number;
  120312. OPACITYRGB: boolean;
  120313. ALPHATEST: boolean;
  120314. DEPTHPREPASS: boolean;
  120315. ALPHABLEND: boolean;
  120316. ALPHAFROMALBEDO: boolean;
  120317. ALPHATESTVALUE: string;
  120318. SPECULAROVERALPHA: boolean;
  120319. RADIANCEOVERALPHA: boolean;
  120320. ALPHAFRESNEL: boolean;
  120321. LINEARALPHAFRESNEL: boolean;
  120322. PREMULTIPLYALPHA: boolean;
  120323. EMISSIVE: boolean;
  120324. EMISSIVEDIRECTUV: number;
  120325. REFLECTIVITY: boolean;
  120326. REFLECTIVITYDIRECTUV: number;
  120327. SPECULARTERM: boolean;
  120328. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  120329. MICROSURFACEAUTOMATIC: boolean;
  120330. LODBASEDMICROSFURACE: boolean;
  120331. MICROSURFACEMAP: boolean;
  120332. MICROSURFACEMAPDIRECTUV: number;
  120333. METALLICWORKFLOW: boolean;
  120334. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  120335. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  120336. METALLNESSSTOREINMETALMAPBLUE: boolean;
  120337. AOSTOREINMETALMAPRED: boolean;
  120338. METALLICF0FACTORFROMMETALLICMAP: boolean;
  120339. ENVIRONMENTBRDF: boolean;
  120340. ENVIRONMENTBRDF_RGBD: boolean;
  120341. NORMAL: boolean;
  120342. TANGENT: boolean;
  120343. BUMP: boolean;
  120344. BUMPDIRECTUV: number;
  120345. OBJECTSPACE_NORMALMAP: boolean;
  120346. PARALLAX: boolean;
  120347. PARALLAXOCCLUSION: boolean;
  120348. NORMALXYSCALE: boolean;
  120349. LIGHTMAP: boolean;
  120350. LIGHTMAPDIRECTUV: number;
  120351. USELIGHTMAPASSHADOWMAP: boolean;
  120352. GAMMALIGHTMAP: boolean;
  120353. RGBDLIGHTMAP: boolean;
  120354. REFLECTION: boolean;
  120355. REFLECTIONMAP_3D: boolean;
  120356. REFLECTIONMAP_SPHERICAL: boolean;
  120357. REFLECTIONMAP_PLANAR: boolean;
  120358. REFLECTIONMAP_CUBIC: boolean;
  120359. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  120360. REFLECTIONMAP_PROJECTION: boolean;
  120361. REFLECTIONMAP_SKYBOX: boolean;
  120362. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  120363. REFLECTIONMAP_EXPLICIT: boolean;
  120364. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  120365. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  120366. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  120367. INVERTCUBICMAP: boolean;
  120368. USESPHERICALFROMREFLECTIONMAP: boolean;
  120369. USEIRRADIANCEMAP: boolean;
  120370. SPHERICAL_HARMONICS: boolean;
  120371. USESPHERICALINVERTEX: boolean;
  120372. REFLECTIONMAP_OPPOSITEZ: boolean;
  120373. LODINREFLECTIONALPHA: boolean;
  120374. GAMMAREFLECTION: boolean;
  120375. RGBDREFLECTION: boolean;
  120376. LINEARSPECULARREFLECTION: boolean;
  120377. RADIANCEOCCLUSION: boolean;
  120378. HORIZONOCCLUSION: boolean;
  120379. INSTANCES: boolean;
  120380. NUM_BONE_INFLUENCERS: number;
  120381. BonesPerMesh: number;
  120382. BONETEXTURE: boolean;
  120383. NONUNIFORMSCALING: boolean;
  120384. MORPHTARGETS: boolean;
  120385. MORPHTARGETS_NORMAL: boolean;
  120386. MORPHTARGETS_TANGENT: boolean;
  120387. MORPHTARGETS_UV: boolean;
  120388. NUM_MORPH_INFLUENCERS: number;
  120389. IMAGEPROCESSING: boolean;
  120390. VIGNETTE: boolean;
  120391. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120392. VIGNETTEBLENDMODEOPAQUE: boolean;
  120393. TONEMAPPING: boolean;
  120394. TONEMAPPING_ACES: boolean;
  120395. CONTRAST: boolean;
  120396. COLORCURVES: boolean;
  120397. COLORGRADING: boolean;
  120398. COLORGRADING3D: boolean;
  120399. SAMPLER3DGREENDEPTH: boolean;
  120400. SAMPLER3DBGRMAP: boolean;
  120401. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120402. EXPOSURE: boolean;
  120403. MULTIVIEW: boolean;
  120404. USEPHYSICALLIGHTFALLOFF: boolean;
  120405. USEGLTFLIGHTFALLOFF: boolean;
  120406. TWOSIDEDLIGHTING: boolean;
  120407. SHADOWFLOAT: boolean;
  120408. CLIPPLANE: boolean;
  120409. CLIPPLANE2: boolean;
  120410. CLIPPLANE3: boolean;
  120411. CLIPPLANE4: boolean;
  120412. CLIPPLANE5: boolean;
  120413. CLIPPLANE6: boolean;
  120414. POINTSIZE: boolean;
  120415. FOG: boolean;
  120416. LOGARITHMICDEPTH: boolean;
  120417. FORCENORMALFORWARD: boolean;
  120418. SPECULARAA: boolean;
  120419. CLEARCOAT: boolean;
  120420. CLEARCOAT_DEFAULTIOR: boolean;
  120421. CLEARCOAT_TEXTURE: boolean;
  120422. CLEARCOAT_TEXTUREDIRECTUV: number;
  120423. CLEARCOAT_BUMP: boolean;
  120424. CLEARCOAT_BUMPDIRECTUV: number;
  120425. CLEARCOAT_TINT: boolean;
  120426. CLEARCOAT_TINT_TEXTURE: boolean;
  120427. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120428. ANISOTROPIC: boolean;
  120429. ANISOTROPIC_TEXTURE: boolean;
  120430. ANISOTROPIC_TEXTUREDIRECTUV: number;
  120431. BRDF_V_HEIGHT_CORRELATED: boolean;
  120432. MS_BRDF_ENERGY_CONSERVATION: boolean;
  120433. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  120434. SHEEN: boolean;
  120435. SHEEN_TEXTURE: boolean;
  120436. SHEEN_TEXTUREDIRECTUV: number;
  120437. SHEEN_LINKWITHALBEDO: boolean;
  120438. SUBSURFACE: boolean;
  120439. SS_REFRACTION: boolean;
  120440. SS_TRANSLUCENCY: boolean;
  120441. SS_SCATERRING: boolean;
  120442. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120443. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120444. SS_REFRACTIONMAP_3D: boolean;
  120445. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120446. SS_LODINREFRACTIONALPHA: boolean;
  120447. SS_GAMMAREFRACTION: boolean;
  120448. SS_RGBDREFRACTION: boolean;
  120449. SS_LINEARSPECULARREFRACTION: boolean;
  120450. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120451. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120452. UNLIT: boolean;
  120453. DEBUGMODE: number;
  120454. /**
  120455. * Initializes the PBR Material defines.
  120456. */
  120457. constructor();
  120458. /**
  120459. * Resets the PBR Material defines.
  120460. */
  120461. reset(): void;
  120462. }
  120463. /**
  120464. * The Physically based material base class of BJS.
  120465. *
  120466. * This offers the main features of a standard PBR material.
  120467. * For more information, please refer to the documentation :
  120468. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120469. */
  120470. export abstract class PBRBaseMaterial extends PushMaterial {
  120471. /**
  120472. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120473. */
  120474. static readonly PBRMATERIAL_OPAQUE: number;
  120475. /**
  120476. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120477. */
  120478. static readonly PBRMATERIAL_ALPHATEST: number;
  120479. /**
  120480. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120481. */
  120482. static readonly PBRMATERIAL_ALPHABLEND: number;
  120483. /**
  120484. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120485. * They are also discarded below the alpha cutoff threshold to improve performances.
  120486. */
  120487. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120488. /**
  120489. * Defines the default value of how much AO map is occluding the analytical lights
  120490. * (point spot...).
  120491. */
  120492. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120493. /**
  120494. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  120495. */
  120496. static readonly LIGHTFALLOFF_PHYSICAL: number;
  120497. /**
  120498. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  120499. * to enhance interoperability with other engines.
  120500. */
  120501. static readonly LIGHTFALLOFF_GLTF: number;
  120502. /**
  120503. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  120504. * to enhance interoperability with other materials.
  120505. */
  120506. static readonly LIGHTFALLOFF_STANDARD: number;
  120507. /**
  120508. * Intensity of the direct lights e.g. the four lights available in your scene.
  120509. * This impacts both the direct diffuse and specular highlights.
  120510. */
  120511. protected _directIntensity: number;
  120512. /**
  120513. * Intensity of the emissive part of the material.
  120514. * This helps controlling the emissive effect without modifying the emissive color.
  120515. */
  120516. protected _emissiveIntensity: number;
  120517. /**
  120518. * Intensity of the environment e.g. how much the environment will light the object
  120519. * either through harmonics for rough material or through the refelction for shiny ones.
  120520. */
  120521. protected _environmentIntensity: number;
  120522. /**
  120523. * This is a special control allowing the reduction of the specular highlights coming from the
  120524. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120525. */
  120526. protected _specularIntensity: number;
  120527. /**
  120528. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  120529. */
  120530. private _lightingInfos;
  120531. /**
  120532. * Debug Control allowing disabling the bump map on this material.
  120533. */
  120534. protected _disableBumpMap: boolean;
  120535. /**
  120536. * AKA Diffuse Texture in standard nomenclature.
  120537. */
  120538. protected _albedoTexture: Nullable<BaseTexture>;
  120539. /**
  120540. * AKA Occlusion Texture in other nomenclature.
  120541. */
  120542. protected _ambientTexture: Nullable<BaseTexture>;
  120543. /**
  120544. * AKA Occlusion Texture Intensity in other nomenclature.
  120545. */
  120546. protected _ambientTextureStrength: number;
  120547. /**
  120548. * Defines how much the AO map is occluding the analytical lights (point spot...).
  120549. * 1 means it completely occludes it
  120550. * 0 mean it has no impact
  120551. */
  120552. protected _ambientTextureImpactOnAnalyticalLights: number;
  120553. /**
  120554. * Stores the alpha values in a texture.
  120555. */
  120556. protected _opacityTexture: Nullable<BaseTexture>;
  120557. /**
  120558. * Stores the reflection values in a texture.
  120559. */
  120560. protected _reflectionTexture: Nullable<BaseTexture>;
  120561. /**
  120562. * Stores the emissive values in a texture.
  120563. */
  120564. protected _emissiveTexture: Nullable<BaseTexture>;
  120565. /**
  120566. * AKA Specular texture in other nomenclature.
  120567. */
  120568. protected _reflectivityTexture: Nullable<BaseTexture>;
  120569. /**
  120570. * Used to switch from specular/glossiness to metallic/roughness workflow.
  120571. */
  120572. protected _metallicTexture: Nullable<BaseTexture>;
  120573. /**
  120574. * Specifies the metallic scalar of the metallic/roughness workflow.
  120575. * Can also be used to scale the metalness values of the metallic texture.
  120576. */
  120577. protected _metallic: Nullable<number>;
  120578. /**
  120579. * Specifies the roughness scalar of the metallic/roughness workflow.
  120580. * Can also be used to scale the roughness values of the metallic texture.
  120581. */
  120582. protected _roughness: Nullable<number>;
  120583. /**
  120584. * Specifies the an F0 factor to help configuring the material F0.
  120585. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  120586. * to 0.5 the previously hard coded value stays the same.
  120587. * Can also be used to scale the F0 values of the metallic texture.
  120588. */
  120589. protected _metallicF0Factor: number;
  120590. /**
  120591. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  120592. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  120593. * your expectation as it multiplies with the texture data.
  120594. */
  120595. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  120596. /**
  120597. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  120598. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  120599. */
  120600. protected _microSurfaceTexture: Nullable<BaseTexture>;
  120601. /**
  120602. * Stores surface normal data used to displace a mesh in a texture.
  120603. */
  120604. protected _bumpTexture: Nullable<BaseTexture>;
  120605. /**
  120606. * Stores the pre-calculated light information of a mesh in a texture.
  120607. */
  120608. protected _lightmapTexture: Nullable<BaseTexture>;
  120609. /**
  120610. * The color of a material in ambient lighting.
  120611. */
  120612. protected _ambientColor: Color3;
  120613. /**
  120614. * AKA Diffuse Color in other nomenclature.
  120615. */
  120616. protected _albedoColor: Color3;
  120617. /**
  120618. * AKA Specular Color in other nomenclature.
  120619. */
  120620. protected _reflectivityColor: Color3;
  120621. /**
  120622. * The color applied when light is reflected from a material.
  120623. */
  120624. protected _reflectionColor: Color3;
  120625. /**
  120626. * The color applied when light is emitted from a material.
  120627. */
  120628. protected _emissiveColor: Color3;
  120629. /**
  120630. * AKA Glossiness in other nomenclature.
  120631. */
  120632. protected _microSurface: number;
  120633. /**
  120634. * Specifies that the material will use the light map as a show map.
  120635. */
  120636. protected _useLightmapAsShadowmap: boolean;
  120637. /**
  120638. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  120639. * makes the reflect vector face the model (under horizon).
  120640. */
  120641. protected _useHorizonOcclusion: boolean;
  120642. /**
  120643. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  120644. * too much the area relying on ambient texture to define their ambient occlusion.
  120645. */
  120646. protected _useRadianceOcclusion: boolean;
  120647. /**
  120648. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  120649. */
  120650. protected _useAlphaFromAlbedoTexture: boolean;
  120651. /**
  120652. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  120653. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  120654. */
  120655. protected _useSpecularOverAlpha: boolean;
  120656. /**
  120657. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  120658. */
  120659. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  120660. /**
  120661. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  120662. */
  120663. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  120664. /**
  120665. * Specifies if the metallic texture contains the roughness information in its green channel.
  120666. */
  120667. protected _useRoughnessFromMetallicTextureGreen: boolean;
  120668. /**
  120669. * Specifies if the metallic texture contains the metallness information in its blue channel.
  120670. */
  120671. protected _useMetallnessFromMetallicTextureBlue: boolean;
  120672. /**
  120673. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  120674. */
  120675. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  120676. /**
  120677. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  120678. */
  120679. protected _useAmbientInGrayScale: boolean;
  120680. /**
  120681. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  120682. * The material will try to infer what glossiness each pixel should be.
  120683. */
  120684. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  120685. /**
  120686. * Defines the falloff type used in this material.
  120687. * It by default is Physical.
  120688. */
  120689. protected _lightFalloff: number;
  120690. /**
  120691. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  120692. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  120693. */
  120694. protected _useRadianceOverAlpha: boolean;
  120695. /**
  120696. * Allows using an object space normal map (instead of tangent space).
  120697. */
  120698. protected _useObjectSpaceNormalMap: boolean;
  120699. /**
  120700. * Allows using the bump map in parallax mode.
  120701. */
  120702. protected _useParallax: boolean;
  120703. /**
  120704. * Allows using the bump map in parallax occlusion mode.
  120705. */
  120706. protected _useParallaxOcclusion: boolean;
  120707. /**
  120708. * Controls the scale bias of the parallax mode.
  120709. */
  120710. protected _parallaxScaleBias: number;
  120711. /**
  120712. * If sets to true, disables all the lights affecting the material.
  120713. */
  120714. protected _disableLighting: boolean;
  120715. /**
  120716. * Number of Simultaneous lights allowed on the material.
  120717. */
  120718. protected _maxSimultaneousLights: number;
  120719. /**
  120720. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  120721. */
  120722. protected _invertNormalMapX: boolean;
  120723. /**
  120724. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  120725. */
  120726. protected _invertNormalMapY: boolean;
  120727. /**
  120728. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120729. */
  120730. protected _twoSidedLighting: boolean;
  120731. /**
  120732. * Defines the alpha limits in alpha test mode.
  120733. */
  120734. protected _alphaCutOff: number;
  120735. /**
  120736. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  120737. */
  120738. protected _forceAlphaTest: boolean;
  120739. /**
  120740. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120741. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  120742. */
  120743. protected _useAlphaFresnel: boolean;
  120744. /**
  120745. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120746. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  120747. */
  120748. protected _useLinearAlphaFresnel: boolean;
  120749. /**
  120750. * The transparency mode of the material.
  120751. */
  120752. protected _transparencyMode: Nullable<number>;
  120753. /**
  120754. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  120755. * from cos thetav and roughness:
  120756. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  120757. */
  120758. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  120759. /**
  120760. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  120761. */
  120762. protected _forceIrradianceInFragment: boolean;
  120763. /**
  120764. * Force normal to face away from face.
  120765. */
  120766. protected _forceNormalForward: boolean;
  120767. /**
  120768. * Enables specular anti aliasing in the PBR shader.
  120769. * It will both interacts on the Geometry for analytical and IBL lighting.
  120770. * It also prefilter the roughness map based on the bump values.
  120771. */
  120772. protected _enableSpecularAntiAliasing: boolean;
  120773. /**
  120774. * Default configuration related to image processing available in the PBR Material.
  120775. */
  120776. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120777. /**
  120778. * Keep track of the image processing observer to allow dispose and replace.
  120779. */
  120780. private _imageProcessingObserver;
  120781. /**
  120782. * Attaches a new image processing configuration to the PBR Material.
  120783. * @param configuration
  120784. */
  120785. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120786. /**
  120787. * Stores the available render targets.
  120788. */
  120789. private _renderTargets;
  120790. /**
  120791. * Sets the global ambient color for the material used in lighting calculations.
  120792. */
  120793. private _globalAmbientColor;
  120794. /**
  120795. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  120796. */
  120797. private _useLogarithmicDepth;
  120798. /**
  120799. * If set to true, no lighting calculations will be applied.
  120800. */
  120801. private _unlit;
  120802. private _debugMode;
  120803. /**
  120804. * @hidden
  120805. * This is reserved for the inspector.
  120806. * Defines the material debug mode.
  120807. * It helps seeing only some components of the material while troubleshooting.
  120808. */
  120809. debugMode: number;
  120810. /**
  120811. * @hidden
  120812. * This is reserved for the inspector.
  120813. * Specify from where on screen the debug mode should start.
  120814. * The value goes from -1 (full screen) to 1 (not visible)
  120815. * It helps with side by side comparison against the final render
  120816. * This defaults to -1
  120817. */
  120818. private debugLimit;
  120819. /**
  120820. * @hidden
  120821. * This is reserved for the inspector.
  120822. * As the default viewing range might not be enough (if the ambient is really small for instance)
  120823. * You can use the factor to better multiply the final value.
  120824. */
  120825. private debugFactor;
  120826. /**
  120827. * Defines the clear coat layer parameters for the material.
  120828. */
  120829. readonly clearCoat: PBRClearCoatConfiguration;
  120830. /**
  120831. * Defines the anisotropic parameters for the material.
  120832. */
  120833. readonly anisotropy: PBRAnisotropicConfiguration;
  120834. /**
  120835. * Defines the BRDF parameters for the material.
  120836. */
  120837. readonly brdf: PBRBRDFConfiguration;
  120838. /**
  120839. * Defines the Sheen parameters for the material.
  120840. */
  120841. readonly sheen: PBRSheenConfiguration;
  120842. /**
  120843. * Defines the SubSurface parameters for the material.
  120844. */
  120845. readonly subSurface: PBRSubSurfaceConfiguration;
  120846. /**
  120847. * Custom callback helping to override the default shader used in the material.
  120848. */
  120849. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  120850. protected _rebuildInParallel: boolean;
  120851. /**
  120852. * Instantiates a new PBRMaterial instance.
  120853. *
  120854. * @param name The material name
  120855. * @param scene The scene the material will be use in.
  120856. */
  120857. constructor(name: string, scene: Scene);
  120858. /**
  120859. * Gets a boolean indicating that current material needs to register RTT
  120860. */
  120861. get hasRenderTargetTextures(): boolean;
  120862. /**
  120863. * Gets the name of the material class.
  120864. */
  120865. getClassName(): string;
  120866. /**
  120867. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120868. */
  120869. get useLogarithmicDepth(): boolean;
  120870. /**
  120871. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120872. */
  120873. set useLogarithmicDepth(value: boolean);
  120874. /**
  120875. * Gets the current transparency mode.
  120876. */
  120877. get transparencyMode(): Nullable<number>;
  120878. /**
  120879. * Sets the transparency mode of the material.
  120880. *
  120881. * | Value | Type | Description |
  120882. * | ----- | ----------------------------------- | ----------- |
  120883. * | 0 | OPAQUE | |
  120884. * | 1 | ALPHATEST | |
  120885. * | 2 | ALPHABLEND | |
  120886. * | 3 | ALPHATESTANDBLEND | |
  120887. *
  120888. */
  120889. set transparencyMode(value: Nullable<number>);
  120890. /**
  120891. * Returns true if alpha blending should be disabled.
  120892. */
  120893. private get _disableAlphaBlending();
  120894. /**
  120895. * Specifies whether or not this material should be rendered in alpha blend mode.
  120896. */
  120897. needAlphaBlending(): boolean;
  120898. /**
  120899. * Specifies if the mesh will require alpha blending.
  120900. * @param mesh - BJS mesh.
  120901. */
  120902. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  120903. /**
  120904. * Specifies whether or not this material should be rendered in alpha test mode.
  120905. */
  120906. needAlphaTesting(): boolean;
  120907. /**
  120908. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  120909. */
  120910. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  120911. /**
  120912. * Gets the texture used for the alpha test.
  120913. */
  120914. getAlphaTestTexture(): Nullable<BaseTexture>;
  120915. /**
  120916. * Specifies that the submesh is ready to be used.
  120917. * @param mesh - BJS mesh.
  120918. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  120919. * @param useInstances - Specifies that instances should be used.
  120920. * @returns - boolean indicating that the submesh is ready or not.
  120921. */
  120922. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120923. /**
  120924. * Specifies if the material uses metallic roughness workflow.
  120925. * @returns boolean specifiying if the material uses metallic roughness workflow.
  120926. */
  120927. isMetallicWorkflow(): boolean;
  120928. private _prepareEffect;
  120929. private _prepareDefines;
  120930. /**
  120931. * Force shader compilation
  120932. */
  120933. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  120934. /**
  120935. * Initializes the uniform buffer layout for the shader.
  120936. */
  120937. buildUniformLayout(): void;
  120938. /**
  120939. * Unbinds the material from the mesh
  120940. */
  120941. unbind(): void;
  120942. /**
  120943. * Binds the submesh data.
  120944. * @param world - The world matrix.
  120945. * @param mesh - The BJS mesh.
  120946. * @param subMesh - A submesh of the BJS mesh.
  120947. */
  120948. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120949. /**
  120950. * Returns the animatable textures.
  120951. * @returns - Array of animatable textures.
  120952. */
  120953. getAnimatables(): IAnimatable[];
  120954. /**
  120955. * Returns the texture used for reflections.
  120956. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  120957. */
  120958. private _getReflectionTexture;
  120959. /**
  120960. * Returns an array of the actively used textures.
  120961. * @returns - Array of BaseTextures
  120962. */
  120963. getActiveTextures(): BaseTexture[];
  120964. /**
  120965. * Checks to see if a texture is used in the material.
  120966. * @param texture - Base texture to use.
  120967. * @returns - Boolean specifying if a texture is used in the material.
  120968. */
  120969. hasTexture(texture: BaseTexture): boolean;
  120970. /**
  120971. * Disposes the resources of the material.
  120972. * @param forceDisposeEffect - Forces the disposal of effects.
  120973. * @param forceDisposeTextures - Forces the disposal of all textures.
  120974. */
  120975. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  120976. }
  120977. }
  120978. declare module BABYLON {
  120979. /**
  120980. * The Physically based material of BJS.
  120981. *
  120982. * This offers the main features of a standard PBR material.
  120983. * For more information, please refer to the documentation :
  120984. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120985. */
  120986. export class PBRMaterial extends PBRBaseMaterial {
  120987. /**
  120988. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120989. */
  120990. static readonly PBRMATERIAL_OPAQUE: number;
  120991. /**
  120992. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120993. */
  120994. static readonly PBRMATERIAL_ALPHATEST: number;
  120995. /**
  120996. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120997. */
  120998. static readonly PBRMATERIAL_ALPHABLEND: number;
  120999. /**
  121000. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  121001. * They are also discarded below the alpha cutoff threshold to improve performances.
  121002. */
  121003. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  121004. /**
  121005. * Defines the default value of how much AO map is occluding the analytical lights
  121006. * (point spot...).
  121007. */
  121008. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  121009. /**
  121010. * Intensity of the direct lights e.g. the four lights available in your scene.
  121011. * This impacts both the direct diffuse and specular highlights.
  121012. */
  121013. directIntensity: number;
  121014. /**
  121015. * Intensity of the emissive part of the material.
  121016. * This helps controlling the emissive effect without modifying the emissive color.
  121017. */
  121018. emissiveIntensity: number;
  121019. /**
  121020. * Intensity of the environment e.g. how much the environment will light the object
  121021. * either through harmonics for rough material or through the refelction for shiny ones.
  121022. */
  121023. environmentIntensity: number;
  121024. /**
  121025. * This is a special control allowing the reduction of the specular highlights coming from the
  121026. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  121027. */
  121028. specularIntensity: number;
  121029. /**
  121030. * Debug Control allowing disabling the bump map on this material.
  121031. */
  121032. disableBumpMap: boolean;
  121033. /**
  121034. * AKA Diffuse Texture in standard nomenclature.
  121035. */
  121036. albedoTexture: BaseTexture;
  121037. /**
  121038. * AKA Occlusion Texture in other nomenclature.
  121039. */
  121040. ambientTexture: BaseTexture;
  121041. /**
  121042. * AKA Occlusion Texture Intensity in other nomenclature.
  121043. */
  121044. ambientTextureStrength: number;
  121045. /**
  121046. * Defines how much the AO map is occluding the analytical lights (point spot...).
  121047. * 1 means it completely occludes it
  121048. * 0 mean it has no impact
  121049. */
  121050. ambientTextureImpactOnAnalyticalLights: number;
  121051. /**
  121052. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  121053. */
  121054. opacityTexture: BaseTexture;
  121055. /**
  121056. * Stores the reflection values in a texture.
  121057. */
  121058. reflectionTexture: Nullable<BaseTexture>;
  121059. /**
  121060. * Stores the emissive values in a texture.
  121061. */
  121062. emissiveTexture: BaseTexture;
  121063. /**
  121064. * AKA Specular texture in other nomenclature.
  121065. */
  121066. reflectivityTexture: BaseTexture;
  121067. /**
  121068. * Used to switch from specular/glossiness to metallic/roughness workflow.
  121069. */
  121070. metallicTexture: BaseTexture;
  121071. /**
  121072. * Specifies the metallic scalar of the metallic/roughness workflow.
  121073. * Can also be used to scale the metalness values of the metallic texture.
  121074. */
  121075. metallic: Nullable<number>;
  121076. /**
  121077. * Specifies the roughness scalar of the metallic/roughness workflow.
  121078. * Can also be used to scale the roughness values of the metallic texture.
  121079. */
  121080. roughness: Nullable<number>;
  121081. /**
  121082. * Specifies the an F0 factor to help configuring the material F0.
  121083. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  121084. * to 0.5 the previously hard coded value stays the same.
  121085. * Can also be used to scale the F0 values of the metallic texture.
  121086. */
  121087. metallicF0Factor: number;
  121088. /**
  121089. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  121090. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  121091. * your expectation as it multiplies with the texture data.
  121092. */
  121093. useMetallicF0FactorFromMetallicTexture: boolean;
  121094. /**
  121095. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  121096. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  121097. */
  121098. microSurfaceTexture: BaseTexture;
  121099. /**
  121100. * Stores surface normal data used to displace a mesh in a texture.
  121101. */
  121102. bumpTexture: BaseTexture;
  121103. /**
  121104. * Stores the pre-calculated light information of a mesh in a texture.
  121105. */
  121106. lightmapTexture: BaseTexture;
  121107. /**
  121108. * Stores the refracted light information in a texture.
  121109. */
  121110. get refractionTexture(): Nullable<BaseTexture>;
  121111. set refractionTexture(value: Nullable<BaseTexture>);
  121112. /**
  121113. * The color of a material in ambient lighting.
  121114. */
  121115. ambientColor: Color3;
  121116. /**
  121117. * AKA Diffuse Color in other nomenclature.
  121118. */
  121119. albedoColor: Color3;
  121120. /**
  121121. * AKA Specular Color in other nomenclature.
  121122. */
  121123. reflectivityColor: Color3;
  121124. /**
  121125. * The color reflected from the material.
  121126. */
  121127. reflectionColor: Color3;
  121128. /**
  121129. * The color emitted from the material.
  121130. */
  121131. emissiveColor: Color3;
  121132. /**
  121133. * AKA Glossiness in other nomenclature.
  121134. */
  121135. microSurface: number;
  121136. /**
  121137. * source material index of refraction (IOR)' / 'destination material IOR.
  121138. */
  121139. get indexOfRefraction(): number;
  121140. set indexOfRefraction(value: number);
  121141. /**
  121142. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121143. */
  121144. get invertRefractionY(): boolean;
  121145. set invertRefractionY(value: boolean);
  121146. /**
  121147. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121148. * Materials half opaque for instance using refraction could benefit from this control.
  121149. */
  121150. get linkRefractionWithTransparency(): boolean;
  121151. set linkRefractionWithTransparency(value: boolean);
  121152. /**
  121153. * If true, the light map contains occlusion information instead of lighting info.
  121154. */
  121155. useLightmapAsShadowmap: boolean;
  121156. /**
  121157. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  121158. */
  121159. useAlphaFromAlbedoTexture: boolean;
  121160. /**
  121161. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  121162. */
  121163. forceAlphaTest: boolean;
  121164. /**
  121165. * Defines the alpha limits in alpha test mode.
  121166. */
  121167. alphaCutOff: number;
  121168. /**
  121169. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  121170. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  121171. */
  121172. useSpecularOverAlpha: boolean;
  121173. /**
  121174. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  121175. */
  121176. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  121177. /**
  121178. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  121179. */
  121180. useRoughnessFromMetallicTextureAlpha: boolean;
  121181. /**
  121182. * Specifies if the metallic texture contains the roughness information in its green channel.
  121183. */
  121184. useRoughnessFromMetallicTextureGreen: boolean;
  121185. /**
  121186. * Specifies if the metallic texture contains the metallness information in its blue channel.
  121187. */
  121188. useMetallnessFromMetallicTextureBlue: boolean;
  121189. /**
  121190. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  121191. */
  121192. useAmbientOcclusionFromMetallicTextureRed: boolean;
  121193. /**
  121194. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  121195. */
  121196. useAmbientInGrayScale: boolean;
  121197. /**
  121198. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  121199. * The material will try to infer what glossiness each pixel should be.
  121200. */
  121201. useAutoMicroSurfaceFromReflectivityMap: boolean;
  121202. /**
  121203. * BJS is using an harcoded light falloff based on a manually sets up range.
  121204. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121205. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121206. */
  121207. get usePhysicalLightFalloff(): boolean;
  121208. /**
  121209. * BJS is using an harcoded light falloff based on a manually sets up range.
  121210. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121211. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121212. */
  121213. set usePhysicalLightFalloff(value: boolean);
  121214. /**
  121215. * In order to support the falloff compatibility with gltf, a special mode has been added
  121216. * to reproduce the gltf light falloff.
  121217. */
  121218. get useGLTFLightFalloff(): boolean;
  121219. /**
  121220. * In order to support the falloff compatibility with gltf, a special mode has been added
  121221. * to reproduce the gltf light falloff.
  121222. */
  121223. set useGLTFLightFalloff(value: boolean);
  121224. /**
  121225. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  121226. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  121227. */
  121228. useRadianceOverAlpha: boolean;
  121229. /**
  121230. * Allows using an object space normal map (instead of tangent space).
  121231. */
  121232. useObjectSpaceNormalMap: boolean;
  121233. /**
  121234. * Allows using the bump map in parallax mode.
  121235. */
  121236. useParallax: boolean;
  121237. /**
  121238. * Allows using the bump map in parallax occlusion mode.
  121239. */
  121240. useParallaxOcclusion: boolean;
  121241. /**
  121242. * Controls the scale bias of the parallax mode.
  121243. */
  121244. parallaxScaleBias: number;
  121245. /**
  121246. * If sets to true, disables all the lights affecting the material.
  121247. */
  121248. disableLighting: boolean;
  121249. /**
  121250. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  121251. */
  121252. forceIrradianceInFragment: boolean;
  121253. /**
  121254. * Number of Simultaneous lights allowed on the material.
  121255. */
  121256. maxSimultaneousLights: number;
  121257. /**
  121258. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121259. */
  121260. invertNormalMapX: boolean;
  121261. /**
  121262. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121263. */
  121264. invertNormalMapY: boolean;
  121265. /**
  121266. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121267. */
  121268. twoSidedLighting: boolean;
  121269. /**
  121270. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121271. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  121272. */
  121273. useAlphaFresnel: boolean;
  121274. /**
  121275. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121276. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  121277. */
  121278. useLinearAlphaFresnel: boolean;
  121279. /**
  121280. * Let user defines the brdf lookup texture used for IBL.
  121281. * A default 8bit version is embedded but you could point at :
  121282. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  121283. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  121284. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  121285. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  121286. */
  121287. environmentBRDFTexture: Nullable<BaseTexture>;
  121288. /**
  121289. * Force normal to face away from face.
  121290. */
  121291. forceNormalForward: boolean;
  121292. /**
  121293. * Enables specular anti aliasing in the PBR shader.
  121294. * It will both interacts on the Geometry for analytical and IBL lighting.
  121295. * It also prefilter the roughness map based on the bump values.
  121296. */
  121297. enableSpecularAntiAliasing: boolean;
  121298. /**
  121299. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  121300. * makes the reflect vector face the model (under horizon).
  121301. */
  121302. useHorizonOcclusion: boolean;
  121303. /**
  121304. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  121305. * too much the area relying on ambient texture to define their ambient occlusion.
  121306. */
  121307. useRadianceOcclusion: boolean;
  121308. /**
  121309. * If set to true, no lighting calculations will be applied.
  121310. */
  121311. unlit: boolean;
  121312. /**
  121313. * Gets the image processing configuration used either in this material.
  121314. */
  121315. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  121316. /**
  121317. * Sets the Default image processing configuration used either in the this material.
  121318. *
  121319. * If sets to null, the scene one is in use.
  121320. */
  121321. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  121322. /**
  121323. * Gets wether the color curves effect is enabled.
  121324. */
  121325. get cameraColorCurvesEnabled(): boolean;
  121326. /**
  121327. * Sets wether the color curves effect is enabled.
  121328. */
  121329. set cameraColorCurvesEnabled(value: boolean);
  121330. /**
  121331. * Gets wether the color grading effect is enabled.
  121332. */
  121333. get cameraColorGradingEnabled(): boolean;
  121334. /**
  121335. * Gets wether the color grading effect is enabled.
  121336. */
  121337. set cameraColorGradingEnabled(value: boolean);
  121338. /**
  121339. * Gets wether tonemapping is enabled or not.
  121340. */
  121341. get cameraToneMappingEnabled(): boolean;
  121342. /**
  121343. * Sets wether tonemapping is enabled or not
  121344. */
  121345. set cameraToneMappingEnabled(value: boolean);
  121346. /**
  121347. * The camera exposure used on this material.
  121348. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121349. * This corresponds to a photographic exposure.
  121350. */
  121351. get cameraExposure(): number;
  121352. /**
  121353. * The camera exposure used on this material.
  121354. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121355. * This corresponds to a photographic exposure.
  121356. */
  121357. set cameraExposure(value: number);
  121358. /**
  121359. * Gets The camera contrast used on this material.
  121360. */
  121361. get cameraContrast(): number;
  121362. /**
  121363. * Sets The camera contrast used on this material.
  121364. */
  121365. set cameraContrast(value: number);
  121366. /**
  121367. * Gets the Color Grading 2D Lookup Texture.
  121368. */
  121369. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121370. /**
  121371. * Sets the Color Grading 2D Lookup Texture.
  121372. */
  121373. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121374. /**
  121375. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121376. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121377. * 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;
  121378. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121379. */
  121380. get cameraColorCurves(): Nullable<ColorCurves>;
  121381. /**
  121382. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121383. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121384. * 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;
  121385. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121386. */
  121387. set cameraColorCurves(value: Nullable<ColorCurves>);
  121388. /**
  121389. * Instantiates a new PBRMaterial instance.
  121390. *
  121391. * @param name The material name
  121392. * @param scene The scene the material will be use in.
  121393. */
  121394. constructor(name: string, scene: Scene);
  121395. /**
  121396. * Returns the name of this material class.
  121397. */
  121398. getClassName(): string;
  121399. /**
  121400. * Makes a duplicate of the current material.
  121401. * @param name - name to use for the new material.
  121402. */
  121403. clone(name: string): PBRMaterial;
  121404. /**
  121405. * Serializes this PBR Material.
  121406. * @returns - An object with the serialized material.
  121407. */
  121408. serialize(): any;
  121409. /**
  121410. * Parses a PBR Material from a serialized object.
  121411. * @param source - Serialized object.
  121412. * @param scene - BJS scene instance.
  121413. * @param rootUrl - url for the scene object
  121414. * @returns - PBRMaterial
  121415. */
  121416. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  121417. }
  121418. }
  121419. declare module BABYLON {
  121420. /**
  121421. * Direct draw surface info
  121422. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  121423. */
  121424. export interface DDSInfo {
  121425. /**
  121426. * Width of the texture
  121427. */
  121428. width: number;
  121429. /**
  121430. * Width of the texture
  121431. */
  121432. height: number;
  121433. /**
  121434. * Number of Mipmaps for the texture
  121435. * @see https://en.wikipedia.org/wiki/Mipmap
  121436. */
  121437. mipmapCount: number;
  121438. /**
  121439. * If the textures format is a known fourCC format
  121440. * @see https://www.fourcc.org/
  121441. */
  121442. isFourCC: boolean;
  121443. /**
  121444. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  121445. */
  121446. isRGB: boolean;
  121447. /**
  121448. * If the texture is a lumincance format
  121449. */
  121450. isLuminance: boolean;
  121451. /**
  121452. * If this is a cube texture
  121453. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  121454. */
  121455. isCube: boolean;
  121456. /**
  121457. * If the texture is a compressed format eg. FOURCC_DXT1
  121458. */
  121459. isCompressed: boolean;
  121460. /**
  121461. * The dxgiFormat of the texture
  121462. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  121463. */
  121464. dxgiFormat: number;
  121465. /**
  121466. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  121467. */
  121468. textureType: number;
  121469. /**
  121470. * Sphericle polynomial created for the dds texture
  121471. */
  121472. sphericalPolynomial?: SphericalPolynomial;
  121473. }
  121474. /**
  121475. * Class used to provide DDS decompression tools
  121476. */
  121477. export class DDSTools {
  121478. /**
  121479. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  121480. */
  121481. static StoreLODInAlphaChannel: boolean;
  121482. /**
  121483. * Gets DDS information from an array buffer
  121484. * @param arrayBuffer defines the array buffer to read data from
  121485. * @returns the DDS information
  121486. */
  121487. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  121488. private static _FloatView;
  121489. private static _Int32View;
  121490. private static _ToHalfFloat;
  121491. private static _FromHalfFloat;
  121492. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  121493. private static _GetHalfFloatRGBAArrayBuffer;
  121494. private static _GetFloatRGBAArrayBuffer;
  121495. private static _GetFloatAsUIntRGBAArrayBuffer;
  121496. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  121497. private static _GetRGBAArrayBuffer;
  121498. private static _ExtractLongWordOrder;
  121499. private static _GetRGBArrayBuffer;
  121500. private static _GetLuminanceArrayBuffer;
  121501. /**
  121502. * Uploads DDS Levels to a Babylon Texture
  121503. * @hidden
  121504. */
  121505. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  121506. }
  121507. interface ThinEngine {
  121508. /**
  121509. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  121510. * @param rootUrl defines the url where the file to load is located
  121511. * @param scene defines the current scene
  121512. * @param lodScale defines scale to apply to the mip map selection
  121513. * @param lodOffset defines offset to apply to the mip map selection
  121514. * @param onLoad defines an optional callback raised when the texture is loaded
  121515. * @param onError defines an optional callback raised if there is an issue to load the texture
  121516. * @param format defines the format of the data
  121517. * @param forcedExtension defines the extension to use to pick the right loader
  121518. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  121519. * @returns the cube texture as an InternalTexture
  121520. */
  121521. 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;
  121522. }
  121523. }
  121524. declare module BABYLON {
  121525. /**
  121526. * Implementation of the DDS Texture Loader.
  121527. * @hidden
  121528. */
  121529. export class _DDSTextureLoader implements IInternalTextureLoader {
  121530. /**
  121531. * Defines wether the loader supports cascade loading the different faces.
  121532. */
  121533. readonly supportCascades: boolean;
  121534. /**
  121535. * This returns if the loader support the current file information.
  121536. * @param extension defines the file extension of the file being loaded
  121537. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121538. * @param fallback defines the fallback internal texture if any
  121539. * @param isBase64 defines whether the texture is encoded as a base64
  121540. * @param isBuffer defines whether the texture data are stored as a buffer
  121541. * @returns true if the loader can load the specified file
  121542. */
  121543. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121544. /**
  121545. * Transform the url before loading if required.
  121546. * @param rootUrl the url of the texture
  121547. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121548. * @returns the transformed texture
  121549. */
  121550. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121551. /**
  121552. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121553. * @param rootUrl the url of the texture
  121554. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121555. * @returns the fallback texture
  121556. */
  121557. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121558. /**
  121559. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121560. * @param data contains the texture data
  121561. * @param texture defines the BabylonJS internal texture
  121562. * @param createPolynomials will be true if polynomials have been requested
  121563. * @param onLoad defines the callback to trigger once the texture is ready
  121564. * @param onError defines the callback to trigger in case of error
  121565. */
  121566. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121567. /**
  121568. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121569. * @param data contains the texture data
  121570. * @param texture defines the BabylonJS internal texture
  121571. * @param callback defines the method to call once ready to upload
  121572. */
  121573. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121574. }
  121575. }
  121576. declare module BABYLON {
  121577. /**
  121578. * Implementation of the ENV Texture Loader.
  121579. * @hidden
  121580. */
  121581. export class _ENVTextureLoader implements IInternalTextureLoader {
  121582. /**
  121583. * Defines wether the loader supports cascade loading the different faces.
  121584. */
  121585. readonly supportCascades: boolean;
  121586. /**
  121587. * This returns if the loader support the current file information.
  121588. * @param extension defines the file extension of the file being loaded
  121589. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121590. * @param fallback defines the fallback internal texture if any
  121591. * @param isBase64 defines whether the texture is encoded as a base64
  121592. * @param isBuffer defines whether the texture data are stored as a buffer
  121593. * @returns true if the loader can load the specified file
  121594. */
  121595. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121596. /**
  121597. * Transform the url before loading if required.
  121598. * @param rootUrl the url of the texture
  121599. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121600. * @returns the transformed texture
  121601. */
  121602. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121603. /**
  121604. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121605. * @param rootUrl the url of the texture
  121606. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121607. * @returns the fallback texture
  121608. */
  121609. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121610. /**
  121611. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121612. * @param data contains the texture data
  121613. * @param texture defines the BabylonJS internal texture
  121614. * @param createPolynomials will be true if polynomials have been requested
  121615. * @param onLoad defines the callback to trigger once the texture is ready
  121616. * @param onError defines the callback to trigger in case of error
  121617. */
  121618. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121619. /**
  121620. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121621. * @param data contains the texture data
  121622. * @param texture defines the BabylonJS internal texture
  121623. * @param callback defines the method to call once ready to upload
  121624. */
  121625. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121626. }
  121627. }
  121628. declare module BABYLON {
  121629. /**
  121630. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121631. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121632. */
  121633. export class KhronosTextureContainer {
  121634. /** contents of the KTX container file */
  121635. arrayBuffer: any;
  121636. private static HEADER_LEN;
  121637. private static COMPRESSED_2D;
  121638. private static COMPRESSED_3D;
  121639. private static TEX_2D;
  121640. private static TEX_3D;
  121641. /**
  121642. * Gets the openGL type
  121643. */
  121644. glType: number;
  121645. /**
  121646. * Gets the openGL type size
  121647. */
  121648. glTypeSize: number;
  121649. /**
  121650. * Gets the openGL format
  121651. */
  121652. glFormat: number;
  121653. /**
  121654. * Gets the openGL internal format
  121655. */
  121656. glInternalFormat: number;
  121657. /**
  121658. * Gets the base internal format
  121659. */
  121660. glBaseInternalFormat: number;
  121661. /**
  121662. * Gets image width in pixel
  121663. */
  121664. pixelWidth: number;
  121665. /**
  121666. * Gets image height in pixel
  121667. */
  121668. pixelHeight: number;
  121669. /**
  121670. * Gets image depth in pixels
  121671. */
  121672. pixelDepth: number;
  121673. /**
  121674. * Gets the number of array elements
  121675. */
  121676. numberOfArrayElements: number;
  121677. /**
  121678. * Gets the number of faces
  121679. */
  121680. numberOfFaces: number;
  121681. /**
  121682. * Gets the number of mipmap levels
  121683. */
  121684. numberOfMipmapLevels: number;
  121685. /**
  121686. * Gets the bytes of key value data
  121687. */
  121688. bytesOfKeyValueData: number;
  121689. /**
  121690. * Gets the load type
  121691. */
  121692. loadType: number;
  121693. /**
  121694. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  121695. */
  121696. isInvalid: boolean;
  121697. /**
  121698. * Creates a new KhronosTextureContainer
  121699. * @param arrayBuffer contents of the KTX container file
  121700. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  121701. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  121702. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  121703. */
  121704. constructor(
  121705. /** contents of the KTX container file */
  121706. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  121707. /**
  121708. * Uploads KTX content to a Babylon Texture.
  121709. * It is assumed that the texture has already been created & is currently bound
  121710. * @hidden
  121711. */
  121712. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  121713. private _upload2DCompressedLevels;
  121714. }
  121715. }
  121716. declare module BABYLON {
  121717. /**
  121718. * Implementation of the KTX Texture Loader.
  121719. * @hidden
  121720. */
  121721. export class _KTXTextureLoader implements IInternalTextureLoader {
  121722. /**
  121723. * Defines wether the loader supports cascade loading the different faces.
  121724. */
  121725. readonly supportCascades: boolean;
  121726. /**
  121727. * This returns if the loader support the current file information.
  121728. * @param extension defines the file extension of the file being loaded
  121729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121730. * @param fallback defines the fallback internal texture if any
  121731. * @param isBase64 defines whether the texture is encoded as a base64
  121732. * @param isBuffer defines whether the texture data are stored as a buffer
  121733. * @returns true if the loader can load the specified file
  121734. */
  121735. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121736. /**
  121737. * Transform the url before loading if required.
  121738. * @param rootUrl the url of the texture
  121739. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121740. * @returns the transformed texture
  121741. */
  121742. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121743. /**
  121744. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121745. * @param rootUrl the url of the texture
  121746. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121747. * @returns the fallback texture
  121748. */
  121749. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121750. /**
  121751. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121752. * @param data contains the texture data
  121753. * @param texture defines the BabylonJS internal texture
  121754. * @param createPolynomials will be true if polynomials have been requested
  121755. * @param onLoad defines the callback to trigger once the texture is ready
  121756. * @param onError defines the callback to trigger in case of error
  121757. */
  121758. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121759. /**
  121760. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121761. * @param data contains the texture data
  121762. * @param texture defines the BabylonJS internal texture
  121763. * @param callback defines the method to call once ready to upload
  121764. */
  121765. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  121766. }
  121767. }
  121768. declare module BABYLON {
  121769. /** @hidden */
  121770. export var _forceSceneHelpersToBundle: boolean;
  121771. interface Scene {
  121772. /**
  121773. * Creates a default light for the scene.
  121774. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  121775. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  121776. */
  121777. createDefaultLight(replace?: boolean): void;
  121778. /**
  121779. * Creates a default camera for the scene.
  121780. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  121781. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121782. * @param replace has default false, when true replaces the active camera in the scene
  121783. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  121784. */
  121785. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121786. /**
  121787. * Creates a default camera and a default light.
  121788. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  121789. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121790. * @param replace has the default false, when true replaces the active camera/light in the scene
  121791. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  121792. */
  121793. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121794. /**
  121795. * Creates a new sky box
  121796. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  121797. * @param environmentTexture defines the texture to use as environment texture
  121798. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  121799. * @param scale defines the overall scale of the skybox
  121800. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  121801. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  121802. * @returns a new mesh holding the sky box
  121803. */
  121804. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  121805. /**
  121806. * Creates a new environment
  121807. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  121808. * @param options defines the options you can use to configure the environment
  121809. * @returns the new EnvironmentHelper
  121810. */
  121811. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  121812. /**
  121813. * Creates a new VREXperienceHelper
  121814. * @see http://doc.babylonjs.com/how_to/webvr_helper
  121815. * @param webVROptions defines the options used to create the new VREXperienceHelper
  121816. * @returns a new VREXperienceHelper
  121817. */
  121818. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  121819. /**
  121820. * Creates a new WebXRDefaultExperience
  121821. * @see http://doc.babylonjs.com/how_to/webxr
  121822. * @param options experience options
  121823. * @returns a promise for a new WebXRDefaultExperience
  121824. */
  121825. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121826. }
  121827. }
  121828. declare module BABYLON {
  121829. /**
  121830. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  121831. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  121832. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  121833. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  121834. */
  121835. export class VideoDome extends TransformNode {
  121836. /**
  121837. * Define the video source as a Monoscopic panoramic 360 video.
  121838. */
  121839. static readonly MODE_MONOSCOPIC: number;
  121840. /**
  121841. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121842. */
  121843. static readonly MODE_TOPBOTTOM: number;
  121844. /**
  121845. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121846. */
  121847. static readonly MODE_SIDEBYSIDE: number;
  121848. private _halfDome;
  121849. private _useDirectMapping;
  121850. /**
  121851. * The video texture being displayed on the sphere
  121852. */
  121853. protected _videoTexture: VideoTexture;
  121854. /**
  121855. * Gets the video texture being displayed on the sphere
  121856. */
  121857. get videoTexture(): VideoTexture;
  121858. /**
  121859. * The skybox material
  121860. */
  121861. protected _material: BackgroundMaterial;
  121862. /**
  121863. * The surface used for the skybox
  121864. */
  121865. protected _mesh: Mesh;
  121866. /**
  121867. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  121868. */
  121869. private _halfDomeMask;
  121870. /**
  121871. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121872. * Also see the options.resolution property.
  121873. */
  121874. get fovMultiplier(): number;
  121875. set fovMultiplier(value: number);
  121876. private _videoMode;
  121877. /**
  121878. * Gets or set the current video mode for the video. It can be:
  121879. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  121880. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121881. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121882. */
  121883. get videoMode(): number;
  121884. set videoMode(value: number);
  121885. /**
  121886. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  121887. *
  121888. */
  121889. get halfDome(): boolean;
  121890. /**
  121891. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  121892. */
  121893. set halfDome(enabled: boolean);
  121894. /**
  121895. * Oberserver used in Stereoscopic VR Mode.
  121896. */
  121897. private _onBeforeCameraRenderObserver;
  121898. /**
  121899. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  121900. * @param name Element's name, child elements will append suffixes for their own names.
  121901. * @param urlsOrVideo defines the url(s) or the video element to use
  121902. * @param options An object containing optional or exposed sub element properties
  121903. */
  121904. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  121905. resolution?: number;
  121906. clickToPlay?: boolean;
  121907. autoPlay?: boolean;
  121908. loop?: boolean;
  121909. size?: number;
  121910. poster?: string;
  121911. faceForward?: boolean;
  121912. useDirectMapping?: boolean;
  121913. halfDomeMode?: boolean;
  121914. }, scene: Scene);
  121915. private _changeVideoMode;
  121916. /**
  121917. * Releases resources associated with this node.
  121918. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121919. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121920. */
  121921. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121922. }
  121923. }
  121924. declare module BABYLON {
  121925. /**
  121926. * This class can be used to get instrumentation data from a Babylon engine
  121927. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121928. */
  121929. export class EngineInstrumentation implements IDisposable {
  121930. /**
  121931. * Define the instrumented engine.
  121932. */
  121933. engine: Engine;
  121934. private _captureGPUFrameTime;
  121935. private _gpuFrameTimeToken;
  121936. private _gpuFrameTime;
  121937. private _captureShaderCompilationTime;
  121938. private _shaderCompilationTime;
  121939. private _onBeginFrameObserver;
  121940. private _onEndFrameObserver;
  121941. private _onBeforeShaderCompilationObserver;
  121942. private _onAfterShaderCompilationObserver;
  121943. /**
  121944. * Gets the perf counter used for GPU frame time
  121945. */
  121946. get gpuFrameTimeCounter(): PerfCounter;
  121947. /**
  121948. * Gets the GPU frame time capture status
  121949. */
  121950. get captureGPUFrameTime(): boolean;
  121951. /**
  121952. * Enable or disable the GPU frame time capture
  121953. */
  121954. set captureGPUFrameTime(value: boolean);
  121955. /**
  121956. * Gets the perf counter used for shader compilation time
  121957. */
  121958. get shaderCompilationTimeCounter(): PerfCounter;
  121959. /**
  121960. * Gets the shader compilation time capture status
  121961. */
  121962. get captureShaderCompilationTime(): boolean;
  121963. /**
  121964. * Enable or disable the shader compilation time capture
  121965. */
  121966. set captureShaderCompilationTime(value: boolean);
  121967. /**
  121968. * Instantiates a new engine instrumentation.
  121969. * This class can be used to get instrumentation data from a Babylon engine
  121970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121971. * @param engine Defines the engine to instrument
  121972. */
  121973. constructor(
  121974. /**
  121975. * Define the instrumented engine.
  121976. */
  121977. engine: Engine);
  121978. /**
  121979. * Dispose and release associated resources.
  121980. */
  121981. dispose(): void;
  121982. }
  121983. }
  121984. declare module BABYLON {
  121985. /**
  121986. * This class can be used to get instrumentation data from a Babylon engine
  121987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  121988. */
  121989. export class SceneInstrumentation implements IDisposable {
  121990. /**
  121991. * Defines the scene to instrument
  121992. */
  121993. scene: Scene;
  121994. private _captureActiveMeshesEvaluationTime;
  121995. private _activeMeshesEvaluationTime;
  121996. private _captureRenderTargetsRenderTime;
  121997. private _renderTargetsRenderTime;
  121998. private _captureFrameTime;
  121999. private _frameTime;
  122000. private _captureRenderTime;
  122001. private _renderTime;
  122002. private _captureInterFrameTime;
  122003. private _interFrameTime;
  122004. private _captureParticlesRenderTime;
  122005. private _particlesRenderTime;
  122006. private _captureSpritesRenderTime;
  122007. private _spritesRenderTime;
  122008. private _capturePhysicsTime;
  122009. private _physicsTime;
  122010. private _captureAnimationsTime;
  122011. private _animationsTime;
  122012. private _captureCameraRenderTime;
  122013. private _cameraRenderTime;
  122014. private _onBeforeActiveMeshesEvaluationObserver;
  122015. private _onAfterActiveMeshesEvaluationObserver;
  122016. private _onBeforeRenderTargetsRenderObserver;
  122017. private _onAfterRenderTargetsRenderObserver;
  122018. private _onAfterRenderObserver;
  122019. private _onBeforeDrawPhaseObserver;
  122020. private _onAfterDrawPhaseObserver;
  122021. private _onBeforeAnimationsObserver;
  122022. private _onBeforeParticlesRenderingObserver;
  122023. private _onAfterParticlesRenderingObserver;
  122024. private _onBeforeSpritesRenderingObserver;
  122025. private _onAfterSpritesRenderingObserver;
  122026. private _onBeforePhysicsObserver;
  122027. private _onAfterPhysicsObserver;
  122028. private _onAfterAnimationsObserver;
  122029. private _onBeforeCameraRenderObserver;
  122030. private _onAfterCameraRenderObserver;
  122031. /**
  122032. * Gets the perf counter used for active meshes evaluation time
  122033. */
  122034. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  122035. /**
  122036. * Gets the active meshes evaluation time capture status
  122037. */
  122038. get captureActiveMeshesEvaluationTime(): boolean;
  122039. /**
  122040. * Enable or disable the active meshes evaluation time capture
  122041. */
  122042. set captureActiveMeshesEvaluationTime(value: boolean);
  122043. /**
  122044. * Gets the perf counter used for render targets render time
  122045. */
  122046. get renderTargetsRenderTimeCounter(): PerfCounter;
  122047. /**
  122048. * Gets the render targets render time capture status
  122049. */
  122050. get captureRenderTargetsRenderTime(): boolean;
  122051. /**
  122052. * Enable or disable the render targets render time capture
  122053. */
  122054. set captureRenderTargetsRenderTime(value: boolean);
  122055. /**
  122056. * Gets the perf counter used for particles render time
  122057. */
  122058. get particlesRenderTimeCounter(): PerfCounter;
  122059. /**
  122060. * Gets the particles render time capture status
  122061. */
  122062. get captureParticlesRenderTime(): boolean;
  122063. /**
  122064. * Enable or disable the particles render time capture
  122065. */
  122066. set captureParticlesRenderTime(value: boolean);
  122067. /**
  122068. * Gets the perf counter used for sprites render time
  122069. */
  122070. get spritesRenderTimeCounter(): PerfCounter;
  122071. /**
  122072. * Gets the sprites render time capture status
  122073. */
  122074. get captureSpritesRenderTime(): boolean;
  122075. /**
  122076. * Enable or disable the sprites render time capture
  122077. */
  122078. set captureSpritesRenderTime(value: boolean);
  122079. /**
  122080. * Gets the perf counter used for physics time
  122081. */
  122082. get physicsTimeCounter(): PerfCounter;
  122083. /**
  122084. * Gets the physics time capture status
  122085. */
  122086. get capturePhysicsTime(): boolean;
  122087. /**
  122088. * Enable or disable the physics time capture
  122089. */
  122090. set capturePhysicsTime(value: boolean);
  122091. /**
  122092. * Gets the perf counter used for animations time
  122093. */
  122094. get animationsTimeCounter(): PerfCounter;
  122095. /**
  122096. * Gets the animations time capture status
  122097. */
  122098. get captureAnimationsTime(): boolean;
  122099. /**
  122100. * Enable or disable the animations time capture
  122101. */
  122102. set captureAnimationsTime(value: boolean);
  122103. /**
  122104. * Gets the perf counter used for frame time capture
  122105. */
  122106. get frameTimeCounter(): PerfCounter;
  122107. /**
  122108. * Gets the frame time capture status
  122109. */
  122110. get captureFrameTime(): boolean;
  122111. /**
  122112. * Enable or disable the frame time capture
  122113. */
  122114. set captureFrameTime(value: boolean);
  122115. /**
  122116. * Gets the perf counter used for inter-frames time capture
  122117. */
  122118. get interFrameTimeCounter(): PerfCounter;
  122119. /**
  122120. * Gets the inter-frames time capture status
  122121. */
  122122. get captureInterFrameTime(): boolean;
  122123. /**
  122124. * Enable or disable the inter-frames time capture
  122125. */
  122126. set captureInterFrameTime(value: boolean);
  122127. /**
  122128. * Gets the perf counter used for render time capture
  122129. */
  122130. get renderTimeCounter(): PerfCounter;
  122131. /**
  122132. * Gets the render time capture status
  122133. */
  122134. get captureRenderTime(): boolean;
  122135. /**
  122136. * Enable or disable the render time capture
  122137. */
  122138. set captureRenderTime(value: boolean);
  122139. /**
  122140. * Gets the perf counter used for camera render time capture
  122141. */
  122142. get cameraRenderTimeCounter(): PerfCounter;
  122143. /**
  122144. * Gets the camera render time capture status
  122145. */
  122146. get captureCameraRenderTime(): boolean;
  122147. /**
  122148. * Enable or disable the camera render time capture
  122149. */
  122150. set captureCameraRenderTime(value: boolean);
  122151. /**
  122152. * Gets the perf counter used for draw calls
  122153. */
  122154. get drawCallsCounter(): PerfCounter;
  122155. /**
  122156. * Instantiates a new scene instrumentation.
  122157. * This class can be used to get instrumentation data from a Babylon engine
  122158. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122159. * @param scene Defines the scene to instrument
  122160. */
  122161. constructor(
  122162. /**
  122163. * Defines the scene to instrument
  122164. */
  122165. scene: Scene);
  122166. /**
  122167. * Dispose and release associated resources.
  122168. */
  122169. dispose(): void;
  122170. }
  122171. }
  122172. declare module BABYLON {
  122173. /** @hidden */
  122174. export var glowMapGenerationPixelShader: {
  122175. name: string;
  122176. shader: string;
  122177. };
  122178. }
  122179. declare module BABYLON {
  122180. /** @hidden */
  122181. export var glowMapGenerationVertexShader: {
  122182. name: string;
  122183. shader: string;
  122184. };
  122185. }
  122186. declare module BABYLON {
  122187. /**
  122188. * Effect layer options. This helps customizing the behaviour
  122189. * of the effect layer.
  122190. */
  122191. export interface IEffectLayerOptions {
  122192. /**
  122193. * Multiplication factor apply to the canvas size to compute the render target size
  122194. * used to generated the objects (the smaller the faster).
  122195. */
  122196. mainTextureRatio: number;
  122197. /**
  122198. * Enforces a fixed size texture to ensure effect stability across devices.
  122199. */
  122200. mainTextureFixedSize?: number;
  122201. /**
  122202. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  122203. */
  122204. alphaBlendingMode: number;
  122205. /**
  122206. * The camera attached to the layer.
  122207. */
  122208. camera: Nullable<Camera>;
  122209. /**
  122210. * The rendering group to draw the layer in.
  122211. */
  122212. renderingGroupId: number;
  122213. }
  122214. /**
  122215. * The effect layer Helps adding post process effect blended with the main pass.
  122216. *
  122217. * This can be for instance use to generate glow or higlight effects on the scene.
  122218. *
  122219. * The effect layer class can not be used directly and is intented to inherited from to be
  122220. * customized per effects.
  122221. */
  122222. export abstract class EffectLayer {
  122223. private _vertexBuffers;
  122224. private _indexBuffer;
  122225. private _cachedDefines;
  122226. private _effectLayerMapGenerationEffect;
  122227. private _effectLayerOptions;
  122228. private _mergeEffect;
  122229. protected _scene: Scene;
  122230. protected _engine: Engine;
  122231. protected _maxSize: number;
  122232. protected _mainTextureDesiredSize: ISize;
  122233. protected _mainTexture: RenderTargetTexture;
  122234. protected _shouldRender: boolean;
  122235. protected _postProcesses: PostProcess[];
  122236. protected _textures: BaseTexture[];
  122237. protected _emissiveTextureAndColor: {
  122238. texture: Nullable<BaseTexture>;
  122239. color: Color4;
  122240. };
  122241. /**
  122242. * The name of the layer
  122243. */
  122244. name: string;
  122245. /**
  122246. * The clear color of the texture used to generate the glow map.
  122247. */
  122248. neutralColor: Color4;
  122249. /**
  122250. * Specifies wether the highlight layer is enabled or not.
  122251. */
  122252. isEnabled: boolean;
  122253. /**
  122254. * Gets the camera attached to the layer.
  122255. */
  122256. get camera(): Nullable<Camera>;
  122257. /**
  122258. * Gets the rendering group id the layer should render in.
  122259. */
  122260. get renderingGroupId(): number;
  122261. set renderingGroupId(renderingGroupId: number);
  122262. /**
  122263. * An event triggered when the effect layer has been disposed.
  122264. */
  122265. onDisposeObservable: Observable<EffectLayer>;
  122266. /**
  122267. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  122268. */
  122269. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  122270. /**
  122271. * An event triggered when the generated texture is being merged in the scene.
  122272. */
  122273. onBeforeComposeObservable: Observable<EffectLayer>;
  122274. /**
  122275. * An event triggered when the mesh is rendered into the effect render target.
  122276. */
  122277. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  122278. /**
  122279. * An event triggered after the mesh has been rendered into the effect render target.
  122280. */
  122281. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  122282. /**
  122283. * An event triggered when the generated texture has been merged in the scene.
  122284. */
  122285. onAfterComposeObservable: Observable<EffectLayer>;
  122286. /**
  122287. * An event triggered when the efffect layer changes its size.
  122288. */
  122289. onSizeChangedObservable: Observable<EffectLayer>;
  122290. /** @hidden */
  122291. static _SceneComponentInitialization: (scene: Scene) => void;
  122292. /**
  122293. * Instantiates a new effect Layer and references it in the scene.
  122294. * @param name The name of the layer
  122295. * @param scene The scene to use the layer in
  122296. */
  122297. constructor(
  122298. /** The Friendly of the effect in the scene */
  122299. name: string, scene: Scene);
  122300. /**
  122301. * Get the effect name of the layer.
  122302. * @return The effect name
  122303. */
  122304. abstract getEffectName(): string;
  122305. /**
  122306. * Checks for the readiness of the element composing the layer.
  122307. * @param subMesh the mesh to check for
  122308. * @param useInstances specify wether or not to use instances to render the mesh
  122309. * @return true if ready otherwise, false
  122310. */
  122311. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122312. /**
  122313. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122314. * @returns true if the effect requires stencil during the main canvas render pass.
  122315. */
  122316. abstract needStencil(): boolean;
  122317. /**
  122318. * Create the merge effect. This is the shader use to blit the information back
  122319. * to the main canvas at the end of the scene rendering.
  122320. * @returns The effect containing the shader used to merge the effect on the main canvas
  122321. */
  122322. protected abstract _createMergeEffect(): Effect;
  122323. /**
  122324. * Creates the render target textures and post processes used in the effect layer.
  122325. */
  122326. protected abstract _createTextureAndPostProcesses(): void;
  122327. /**
  122328. * Implementation specific of rendering the generating effect on the main canvas.
  122329. * @param effect The effect used to render through
  122330. */
  122331. protected abstract _internalRender(effect: Effect): void;
  122332. /**
  122333. * Sets the required values for both the emissive texture and and the main color.
  122334. */
  122335. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122336. /**
  122337. * Free any resources and references associated to a mesh.
  122338. * Internal use
  122339. * @param mesh The mesh to free.
  122340. */
  122341. abstract _disposeMesh(mesh: Mesh): void;
  122342. /**
  122343. * Serializes this layer (Glow or Highlight for example)
  122344. * @returns a serialized layer object
  122345. */
  122346. abstract serialize?(): any;
  122347. /**
  122348. * Initializes the effect layer with the required options.
  122349. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  122350. */
  122351. protected _init(options: Partial<IEffectLayerOptions>): void;
  122352. /**
  122353. * Generates the index buffer of the full screen quad blending to the main canvas.
  122354. */
  122355. private _generateIndexBuffer;
  122356. /**
  122357. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  122358. */
  122359. private _generateVertexBuffer;
  122360. /**
  122361. * Sets the main texture desired size which is the closest power of two
  122362. * of the engine canvas size.
  122363. */
  122364. private _setMainTextureSize;
  122365. /**
  122366. * Creates the main texture for the effect layer.
  122367. */
  122368. protected _createMainTexture(): void;
  122369. /**
  122370. * Adds specific effects defines.
  122371. * @param defines The defines to add specifics to.
  122372. */
  122373. protected _addCustomEffectDefines(defines: string[]): void;
  122374. /**
  122375. * Checks for the readiness of the element composing the layer.
  122376. * @param subMesh the mesh to check for
  122377. * @param useInstances specify wether or not to use instances to render the mesh
  122378. * @param emissiveTexture the associated emissive texture used to generate the glow
  122379. * @return true if ready otherwise, false
  122380. */
  122381. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  122382. /**
  122383. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  122384. */
  122385. render(): void;
  122386. /**
  122387. * Determine if a given mesh will be used in the current effect.
  122388. * @param mesh mesh to test
  122389. * @returns true if the mesh will be used
  122390. */
  122391. hasMesh(mesh: AbstractMesh): boolean;
  122392. /**
  122393. * Returns true if the layer contains information to display, otherwise false.
  122394. * @returns true if the glow layer should be rendered
  122395. */
  122396. shouldRender(): boolean;
  122397. /**
  122398. * Returns true if the mesh should render, otherwise false.
  122399. * @param mesh The mesh to render
  122400. * @returns true if it should render otherwise false
  122401. */
  122402. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  122403. /**
  122404. * Returns true if the mesh can be rendered, otherwise false.
  122405. * @param mesh The mesh to render
  122406. * @param material The material used on the mesh
  122407. * @returns true if it can be rendered otherwise false
  122408. */
  122409. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122410. /**
  122411. * Returns true if the mesh should render, otherwise false.
  122412. * @param mesh The mesh to render
  122413. * @returns true if it should render otherwise false
  122414. */
  122415. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  122416. /**
  122417. * Renders the submesh passed in parameter to the generation map.
  122418. */
  122419. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  122420. /**
  122421. * Defines wether the current material of the mesh should be use to render the effect.
  122422. * @param mesh defines the current mesh to render
  122423. */
  122424. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122425. /**
  122426. * Rebuild the required buffers.
  122427. * @hidden Internal use only.
  122428. */
  122429. _rebuild(): void;
  122430. /**
  122431. * Dispose only the render target textures and post process.
  122432. */
  122433. private _disposeTextureAndPostProcesses;
  122434. /**
  122435. * Dispose the highlight layer and free resources.
  122436. */
  122437. dispose(): void;
  122438. /**
  122439. * Gets the class name of the effect layer
  122440. * @returns the string with the class name of the effect layer
  122441. */
  122442. getClassName(): string;
  122443. /**
  122444. * Creates an effect layer from parsed effect layer data
  122445. * @param parsedEffectLayer defines effect layer data
  122446. * @param scene defines the current scene
  122447. * @param rootUrl defines the root URL containing the effect layer information
  122448. * @returns a parsed effect Layer
  122449. */
  122450. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  122451. }
  122452. }
  122453. declare module BABYLON {
  122454. interface AbstractScene {
  122455. /**
  122456. * The list of effect layers (highlights/glow) added to the scene
  122457. * @see http://doc.babylonjs.com/how_to/highlight_layer
  122458. * @see http://doc.babylonjs.com/how_to/glow_layer
  122459. */
  122460. effectLayers: Array<EffectLayer>;
  122461. /**
  122462. * Removes the given effect layer from this scene.
  122463. * @param toRemove defines the effect layer to remove
  122464. * @returns the index of the removed effect layer
  122465. */
  122466. removeEffectLayer(toRemove: EffectLayer): number;
  122467. /**
  122468. * Adds the given effect layer to this scene
  122469. * @param newEffectLayer defines the effect layer to add
  122470. */
  122471. addEffectLayer(newEffectLayer: EffectLayer): void;
  122472. }
  122473. /**
  122474. * Defines the layer scene component responsible to manage any effect layers
  122475. * in a given scene.
  122476. */
  122477. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  122478. /**
  122479. * The component name helpfull to identify the component in the list of scene components.
  122480. */
  122481. readonly name: string;
  122482. /**
  122483. * The scene the component belongs to.
  122484. */
  122485. scene: Scene;
  122486. private _engine;
  122487. private _renderEffects;
  122488. private _needStencil;
  122489. private _previousStencilState;
  122490. /**
  122491. * Creates a new instance of the component for the given scene
  122492. * @param scene Defines the scene to register the component in
  122493. */
  122494. constructor(scene: Scene);
  122495. /**
  122496. * Registers the component in a given scene
  122497. */
  122498. register(): void;
  122499. /**
  122500. * Rebuilds the elements related to this component in case of
  122501. * context lost for instance.
  122502. */
  122503. rebuild(): void;
  122504. /**
  122505. * Serializes the component data to the specified json object
  122506. * @param serializationObject The object to serialize to
  122507. */
  122508. serialize(serializationObject: any): void;
  122509. /**
  122510. * Adds all the elements from the container to the scene
  122511. * @param container the container holding the elements
  122512. */
  122513. addFromContainer(container: AbstractScene): void;
  122514. /**
  122515. * Removes all the elements in the container from the scene
  122516. * @param container contains the elements to remove
  122517. * @param dispose if the removed element should be disposed (default: false)
  122518. */
  122519. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122520. /**
  122521. * Disposes the component and the associated ressources.
  122522. */
  122523. dispose(): void;
  122524. private _isReadyForMesh;
  122525. private _renderMainTexture;
  122526. private _setStencil;
  122527. private _setStencilBack;
  122528. private _draw;
  122529. private _drawCamera;
  122530. private _drawRenderingGroup;
  122531. }
  122532. }
  122533. declare module BABYLON {
  122534. /** @hidden */
  122535. export var glowMapMergePixelShader: {
  122536. name: string;
  122537. shader: string;
  122538. };
  122539. }
  122540. declare module BABYLON {
  122541. /** @hidden */
  122542. export var glowMapMergeVertexShader: {
  122543. name: string;
  122544. shader: string;
  122545. };
  122546. }
  122547. declare module BABYLON {
  122548. interface AbstractScene {
  122549. /**
  122550. * Return a the first highlight layer of the scene with a given name.
  122551. * @param name The name of the highlight layer to look for.
  122552. * @return The highlight layer if found otherwise null.
  122553. */
  122554. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  122555. }
  122556. /**
  122557. * Glow layer options. This helps customizing the behaviour
  122558. * of the glow layer.
  122559. */
  122560. export interface IGlowLayerOptions {
  122561. /**
  122562. * Multiplication factor apply to the canvas size to compute the render target size
  122563. * used to generated the glowing objects (the smaller the faster).
  122564. */
  122565. mainTextureRatio: number;
  122566. /**
  122567. * Enforces a fixed size texture to ensure resize independant blur.
  122568. */
  122569. mainTextureFixedSize?: number;
  122570. /**
  122571. * How big is the kernel of the blur texture.
  122572. */
  122573. blurKernelSize: number;
  122574. /**
  122575. * The camera attached to the layer.
  122576. */
  122577. camera: Nullable<Camera>;
  122578. /**
  122579. * Enable MSAA by chosing the number of samples.
  122580. */
  122581. mainTextureSamples?: number;
  122582. /**
  122583. * The rendering group to draw the layer in.
  122584. */
  122585. renderingGroupId: number;
  122586. }
  122587. /**
  122588. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  122589. *
  122590. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  122591. *
  122592. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  122593. */
  122594. export class GlowLayer extends EffectLayer {
  122595. /**
  122596. * Effect Name of the layer.
  122597. */
  122598. static readonly EffectName: string;
  122599. /**
  122600. * The default blur kernel size used for the glow.
  122601. */
  122602. static DefaultBlurKernelSize: number;
  122603. /**
  122604. * The default texture size ratio used for the glow.
  122605. */
  122606. static DefaultTextureRatio: number;
  122607. /**
  122608. * Sets the kernel size of the blur.
  122609. */
  122610. set blurKernelSize(value: number);
  122611. /**
  122612. * Gets the kernel size of the blur.
  122613. */
  122614. get blurKernelSize(): number;
  122615. /**
  122616. * Sets the glow intensity.
  122617. */
  122618. set intensity(value: number);
  122619. /**
  122620. * Gets the glow intensity.
  122621. */
  122622. get intensity(): number;
  122623. private _options;
  122624. private _intensity;
  122625. private _horizontalBlurPostprocess1;
  122626. private _verticalBlurPostprocess1;
  122627. private _horizontalBlurPostprocess2;
  122628. private _verticalBlurPostprocess2;
  122629. private _blurTexture1;
  122630. private _blurTexture2;
  122631. private _postProcesses1;
  122632. private _postProcesses2;
  122633. private _includedOnlyMeshes;
  122634. private _excludedMeshes;
  122635. private _meshesUsingTheirOwnMaterials;
  122636. /**
  122637. * Callback used to let the user override the color selection on a per mesh basis
  122638. */
  122639. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  122640. /**
  122641. * Callback used to let the user override the texture selection on a per mesh basis
  122642. */
  122643. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  122644. /**
  122645. * Instantiates a new glow Layer and references it to the scene.
  122646. * @param name The name of the layer
  122647. * @param scene The scene to use the layer in
  122648. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  122649. */
  122650. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  122651. /**
  122652. * Get the effect name of the layer.
  122653. * @return The effect name
  122654. */
  122655. getEffectName(): string;
  122656. /**
  122657. * Create the merge effect. This is the shader use to blit the information back
  122658. * to the main canvas at the end of the scene rendering.
  122659. */
  122660. protected _createMergeEffect(): Effect;
  122661. /**
  122662. * Creates the render target textures and post processes used in the glow layer.
  122663. */
  122664. protected _createTextureAndPostProcesses(): void;
  122665. /**
  122666. * Checks for the readiness of the element composing the layer.
  122667. * @param subMesh the mesh to check for
  122668. * @param useInstances specify wether or not to use instances to render the mesh
  122669. * @param emissiveTexture the associated emissive texture used to generate the glow
  122670. * @return true if ready otherwise, false
  122671. */
  122672. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122673. /**
  122674. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122675. */
  122676. needStencil(): boolean;
  122677. /**
  122678. * Returns true if the mesh can be rendered, otherwise false.
  122679. * @param mesh The mesh to render
  122680. * @param material The material used on the mesh
  122681. * @returns true if it can be rendered otherwise false
  122682. */
  122683. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122684. /**
  122685. * Implementation specific of rendering the generating effect on the main canvas.
  122686. * @param effect The effect used to render through
  122687. */
  122688. protected _internalRender(effect: Effect): void;
  122689. /**
  122690. * Sets the required values for both the emissive texture and and the main color.
  122691. */
  122692. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122693. /**
  122694. * Returns true if the mesh should render, otherwise false.
  122695. * @param mesh The mesh to render
  122696. * @returns true if it should render otherwise false
  122697. */
  122698. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122699. /**
  122700. * Adds specific effects defines.
  122701. * @param defines The defines to add specifics to.
  122702. */
  122703. protected _addCustomEffectDefines(defines: string[]): void;
  122704. /**
  122705. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  122706. * @param mesh The mesh to exclude from the glow layer
  122707. */
  122708. addExcludedMesh(mesh: Mesh): void;
  122709. /**
  122710. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  122711. * @param mesh The mesh to remove
  122712. */
  122713. removeExcludedMesh(mesh: Mesh): void;
  122714. /**
  122715. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  122716. * @param mesh The mesh to include in the glow layer
  122717. */
  122718. addIncludedOnlyMesh(mesh: Mesh): void;
  122719. /**
  122720. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  122721. * @param mesh The mesh to remove
  122722. */
  122723. removeIncludedOnlyMesh(mesh: Mesh): void;
  122724. /**
  122725. * Determine if a given mesh will be used in the glow layer
  122726. * @param mesh The mesh to test
  122727. * @returns true if the mesh will be highlighted by the current glow layer
  122728. */
  122729. hasMesh(mesh: AbstractMesh): boolean;
  122730. /**
  122731. * Defines wether the current material of the mesh should be use to render the effect.
  122732. * @param mesh defines the current mesh to render
  122733. */
  122734. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122735. /**
  122736. * Add a mesh to be rendered through its own material and not with emissive only.
  122737. * @param mesh The mesh for which we need to use its material
  122738. */
  122739. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  122740. /**
  122741. * Remove a mesh from being rendered through its own material and not with emissive only.
  122742. * @param mesh The mesh for which we need to not use its material
  122743. */
  122744. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  122745. /**
  122746. * Free any resources and references associated to a mesh.
  122747. * Internal use
  122748. * @param mesh The mesh to free.
  122749. * @hidden
  122750. */
  122751. _disposeMesh(mesh: Mesh): void;
  122752. /**
  122753. * Gets the class name of the effect layer
  122754. * @returns the string with the class name of the effect layer
  122755. */
  122756. getClassName(): string;
  122757. /**
  122758. * Serializes this glow layer
  122759. * @returns a serialized glow layer object
  122760. */
  122761. serialize(): any;
  122762. /**
  122763. * Creates a Glow Layer from parsed glow layer data
  122764. * @param parsedGlowLayer defines glow layer data
  122765. * @param scene defines the current scene
  122766. * @param rootUrl defines the root URL containing the glow layer information
  122767. * @returns a parsed Glow Layer
  122768. */
  122769. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  122770. }
  122771. }
  122772. declare module BABYLON {
  122773. /** @hidden */
  122774. export var glowBlurPostProcessPixelShader: {
  122775. name: string;
  122776. shader: string;
  122777. };
  122778. }
  122779. declare module BABYLON {
  122780. interface AbstractScene {
  122781. /**
  122782. * Return a the first highlight layer of the scene with a given name.
  122783. * @param name The name of the highlight layer to look for.
  122784. * @return The highlight layer if found otherwise null.
  122785. */
  122786. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  122787. }
  122788. /**
  122789. * Highlight layer options. This helps customizing the behaviour
  122790. * of the highlight layer.
  122791. */
  122792. export interface IHighlightLayerOptions {
  122793. /**
  122794. * Multiplication factor apply to the canvas size to compute the render target size
  122795. * used to generated the glowing objects (the smaller the faster).
  122796. */
  122797. mainTextureRatio: number;
  122798. /**
  122799. * Enforces a fixed size texture to ensure resize independant blur.
  122800. */
  122801. mainTextureFixedSize?: number;
  122802. /**
  122803. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  122804. * of the picture to blur (the smaller the faster).
  122805. */
  122806. blurTextureSizeRatio: number;
  122807. /**
  122808. * How big in texel of the blur texture is the vertical blur.
  122809. */
  122810. blurVerticalSize: number;
  122811. /**
  122812. * How big in texel of the blur texture is the horizontal blur.
  122813. */
  122814. blurHorizontalSize: number;
  122815. /**
  122816. * Alpha blending mode used to apply the blur. Default is combine.
  122817. */
  122818. alphaBlendingMode: number;
  122819. /**
  122820. * The camera attached to the layer.
  122821. */
  122822. camera: Nullable<Camera>;
  122823. /**
  122824. * Should we display highlight as a solid stroke?
  122825. */
  122826. isStroke?: boolean;
  122827. /**
  122828. * The rendering group to draw the layer in.
  122829. */
  122830. renderingGroupId: number;
  122831. }
  122832. /**
  122833. * The highlight layer Helps adding a glow effect around a mesh.
  122834. *
  122835. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  122836. * glowy meshes to your scene.
  122837. *
  122838. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  122839. */
  122840. export class HighlightLayer extends EffectLayer {
  122841. name: string;
  122842. /**
  122843. * Effect Name of the highlight layer.
  122844. */
  122845. static readonly EffectName: string;
  122846. /**
  122847. * The neutral color used during the preparation of the glow effect.
  122848. * This is black by default as the blend operation is a blend operation.
  122849. */
  122850. static NeutralColor: Color4;
  122851. /**
  122852. * Stencil value used for glowing meshes.
  122853. */
  122854. static GlowingMeshStencilReference: number;
  122855. /**
  122856. * Stencil value used for the other meshes in the scene.
  122857. */
  122858. static NormalMeshStencilReference: number;
  122859. /**
  122860. * Specifies whether or not the inner glow is ACTIVE in the layer.
  122861. */
  122862. innerGlow: boolean;
  122863. /**
  122864. * Specifies whether or not the outer glow is ACTIVE in the layer.
  122865. */
  122866. outerGlow: boolean;
  122867. /**
  122868. * Specifies the horizontal size of the blur.
  122869. */
  122870. set blurHorizontalSize(value: number);
  122871. /**
  122872. * Specifies the vertical size of the blur.
  122873. */
  122874. set blurVerticalSize(value: number);
  122875. /**
  122876. * Gets the horizontal size of the blur.
  122877. */
  122878. get blurHorizontalSize(): number;
  122879. /**
  122880. * Gets the vertical size of the blur.
  122881. */
  122882. get blurVerticalSize(): number;
  122883. /**
  122884. * An event triggered when the highlight layer is being blurred.
  122885. */
  122886. onBeforeBlurObservable: Observable<HighlightLayer>;
  122887. /**
  122888. * An event triggered when the highlight layer has been blurred.
  122889. */
  122890. onAfterBlurObservable: Observable<HighlightLayer>;
  122891. private _instanceGlowingMeshStencilReference;
  122892. private _options;
  122893. private _downSamplePostprocess;
  122894. private _horizontalBlurPostprocess;
  122895. private _verticalBlurPostprocess;
  122896. private _blurTexture;
  122897. private _meshes;
  122898. private _excludedMeshes;
  122899. /**
  122900. * Instantiates a new highlight Layer and references it to the scene..
  122901. * @param name The name of the layer
  122902. * @param scene The scene to use the layer in
  122903. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  122904. */
  122905. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  122906. /**
  122907. * Get the effect name of the layer.
  122908. * @return The effect name
  122909. */
  122910. getEffectName(): string;
  122911. /**
  122912. * Create the merge effect. This is the shader use to blit the information back
  122913. * to the main canvas at the end of the scene rendering.
  122914. */
  122915. protected _createMergeEffect(): Effect;
  122916. /**
  122917. * Creates the render target textures and post processes used in the highlight layer.
  122918. */
  122919. protected _createTextureAndPostProcesses(): void;
  122920. /**
  122921. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122922. */
  122923. needStencil(): boolean;
  122924. /**
  122925. * Checks for the readiness of the element composing the layer.
  122926. * @param subMesh the mesh to check for
  122927. * @param useInstances specify wether or not to use instances to render the mesh
  122928. * @param emissiveTexture the associated emissive texture used to generate the glow
  122929. * @return true if ready otherwise, false
  122930. */
  122931. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122932. /**
  122933. * Implementation specific of rendering the generating effect on the main canvas.
  122934. * @param effect The effect used to render through
  122935. */
  122936. protected _internalRender(effect: Effect): void;
  122937. /**
  122938. * Returns true if the layer contains information to display, otherwise false.
  122939. */
  122940. shouldRender(): boolean;
  122941. /**
  122942. * Returns true if the mesh should render, otherwise false.
  122943. * @param mesh The mesh to render
  122944. * @returns true if it should render otherwise false
  122945. */
  122946. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122947. /**
  122948. * Sets the required values for both the emissive texture and and the main color.
  122949. */
  122950. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122951. /**
  122952. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  122953. * @param mesh The mesh to exclude from the highlight layer
  122954. */
  122955. addExcludedMesh(mesh: Mesh): void;
  122956. /**
  122957. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  122958. * @param mesh The mesh to highlight
  122959. */
  122960. removeExcludedMesh(mesh: Mesh): void;
  122961. /**
  122962. * Determine if a given mesh will be highlighted by the current HighlightLayer
  122963. * @param mesh mesh to test
  122964. * @returns true if the mesh will be highlighted by the current HighlightLayer
  122965. */
  122966. hasMesh(mesh: AbstractMesh): boolean;
  122967. /**
  122968. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  122969. * @param mesh The mesh to highlight
  122970. * @param color The color of the highlight
  122971. * @param glowEmissiveOnly Extract the glow from the emissive texture
  122972. */
  122973. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  122974. /**
  122975. * Remove a mesh from the highlight layer in order to make it stop glowing.
  122976. * @param mesh The mesh to highlight
  122977. */
  122978. removeMesh(mesh: Mesh): void;
  122979. /**
  122980. * Force the stencil to the normal expected value for none glowing parts
  122981. */
  122982. private _defaultStencilReference;
  122983. /**
  122984. * Free any resources and references associated to a mesh.
  122985. * Internal use
  122986. * @param mesh The mesh to free.
  122987. * @hidden
  122988. */
  122989. _disposeMesh(mesh: Mesh): void;
  122990. /**
  122991. * Dispose the highlight layer and free resources.
  122992. */
  122993. dispose(): void;
  122994. /**
  122995. * Gets the class name of the effect layer
  122996. * @returns the string with the class name of the effect layer
  122997. */
  122998. getClassName(): string;
  122999. /**
  123000. * Serializes this Highlight layer
  123001. * @returns a serialized Highlight layer object
  123002. */
  123003. serialize(): any;
  123004. /**
  123005. * Creates a Highlight layer from parsed Highlight layer data
  123006. * @param parsedHightlightLayer defines the Highlight layer data
  123007. * @param scene defines the current scene
  123008. * @param rootUrl defines the root URL containing the Highlight layer information
  123009. * @returns a parsed Highlight layer
  123010. */
  123011. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  123012. }
  123013. }
  123014. declare module BABYLON {
  123015. interface AbstractScene {
  123016. /**
  123017. * The list of layers (background and foreground) of the scene
  123018. */
  123019. layers: Array<Layer>;
  123020. }
  123021. /**
  123022. * Defines the layer scene component responsible to manage any layers
  123023. * in a given scene.
  123024. */
  123025. export class LayerSceneComponent implements ISceneComponent {
  123026. /**
  123027. * The component name helpfull to identify the component in the list of scene components.
  123028. */
  123029. readonly name: string;
  123030. /**
  123031. * The scene the component belongs to.
  123032. */
  123033. scene: Scene;
  123034. private _engine;
  123035. /**
  123036. * Creates a new instance of the component for the given scene
  123037. * @param scene Defines the scene to register the component in
  123038. */
  123039. constructor(scene: Scene);
  123040. /**
  123041. * Registers the component in a given scene
  123042. */
  123043. register(): void;
  123044. /**
  123045. * Rebuilds the elements related to this component in case of
  123046. * context lost for instance.
  123047. */
  123048. rebuild(): void;
  123049. /**
  123050. * Disposes the component and the associated ressources.
  123051. */
  123052. dispose(): void;
  123053. private _draw;
  123054. private _drawCameraPredicate;
  123055. private _drawCameraBackground;
  123056. private _drawCameraForeground;
  123057. private _drawRenderTargetPredicate;
  123058. private _drawRenderTargetBackground;
  123059. private _drawRenderTargetForeground;
  123060. /**
  123061. * Adds all the elements from the container to the scene
  123062. * @param container the container holding the elements
  123063. */
  123064. addFromContainer(container: AbstractScene): void;
  123065. /**
  123066. * Removes all the elements in the container from the scene
  123067. * @param container contains the elements to remove
  123068. * @param dispose if the removed element should be disposed (default: false)
  123069. */
  123070. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123071. }
  123072. }
  123073. declare module BABYLON {
  123074. /** @hidden */
  123075. export var layerPixelShader: {
  123076. name: string;
  123077. shader: string;
  123078. };
  123079. }
  123080. declare module BABYLON {
  123081. /** @hidden */
  123082. export var layerVertexShader: {
  123083. name: string;
  123084. shader: string;
  123085. };
  123086. }
  123087. declare module BABYLON {
  123088. /**
  123089. * This represents a full screen 2d layer.
  123090. * This can be useful to display a picture in the background of your scene for instance.
  123091. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123092. */
  123093. export class Layer {
  123094. /**
  123095. * Define the name of the layer.
  123096. */
  123097. name: string;
  123098. /**
  123099. * Define the texture the layer should display.
  123100. */
  123101. texture: Nullable<Texture>;
  123102. /**
  123103. * Is the layer in background or foreground.
  123104. */
  123105. isBackground: boolean;
  123106. /**
  123107. * Define the color of the layer (instead of texture).
  123108. */
  123109. color: Color4;
  123110. /**
  123111. * Define the scale of the layer in order to zoom in out of the texture.
  123112. */
  123113. scale: Vector2;
  123114. /**
  123115. * Define an offset for the layer in order to shift the texture.
  123116. */
  123117. offset: Vector2;
  123118. /**
  123119. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  123120. */
  123121. alphaBlendingMode: number;
  123122. /**
  123123. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  123124. * Alpha test will not mix with the background color in case of transparency.
  123125. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  123126. */
  123127. alphaTest: boolean;
  123128. /**
  123129. * Define a mask to restrict the layer to only some of the scene cameras.
  123130. */
  123131. layerMask: number;
  123132. /**
  123133. * Define the list of render target the layer is visible into.
  123134. */
  123135. renderTargetTextures: RenderTargetTexture[];
  123136. /**
  123137. * Define if the layer is only used in renderTarget or if it also
  123138. * renders in the main frame buffer of the canvas.
  123139. */
  123140. renderOnlyInRenderTargetTextures: boolean;
  123141. private _scene;
  123142. private _vertexBuffers;
  123143. private _indexBuffer;
  123144. private _effect;
  123145. private _previousDefines;
  123146. /**
  123147. * An event triggered when the layer is disposed.
  123148. */
  123149. onDisposeObservable: Observable<Layer>;
  123150. private _onDisposeObserver;
  123151. /**
  123152. * Back compatibility with callback before the onDisposeObservable existed.
  123153. * The set callback will be triggered when the layer has been disposed.
  123154. */
  123155. set onDispose(callback: () => void);
  123156. /**
  123157. * An event triggered before rendering the scene
  123158. */
  123159. onBeforeRenderObservable: Observable<Layer>;
  123160. private _onBeforeRenderObserver;
  123161. /**
  123162. * Back compatibility with callback before the onBeforeRenderObservable existed.
  123163. * The set callback will be triggered just before rendering the layer.
  123164. */
  123165. set onBeforeRender(callback: () => void);
  123166. /**
  123167. * An event triggered after rendering the scene
  123168. */
  123169. onAfterRenderObservable: Observable<Layer>;
  123170. private _onAfterRenderObserver;
  123171. /**
  123172. * Back compatibility with callback before the onAfterRenderObservable existed.
  123173. * The set callback will be triggered just after rendering the layer.
  123174. */
  123175. set onAfterRender(callback: () => void);
  123176. /**
  123177. * Instantiates a new layer.
  123178. * This represents a full screen 2d layer.
  123179. * This can be useful to display a picture in the background of your scene for instance.
  123180. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123181. * @param name Define the name of the layer in the scene
  123182. * @param imgUrl Define the url of the texture to display in the layer
  123183. * @param scene Define the scene the layer belongs to
  123184. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  123185. * @param color Defines a color for the layer
  123186. */
  123187. constructor(
  123188. /**
  123189. * Define the name of the layer.
  123190. */
  123191. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  123192. private _createIndexBuffer;
  123193. /** @hidden */
  123194. _rebuild(): void;
  123195. /**
  123196. * Renders the layer in the scene.
  123197. */
  123198. render(): void;
  123199. /**
  123200. * Disposes and releases the associated ressources.
  123201. */
  123202. dispose(): void;
  123203. }
  123204. }
  123205. declare module BABYLON {
  123206. /** @hidden */
  123207. export var lensFlarePixelShader: {
  123208. name: string;
  123209. shader: string;
  123210. };
  123211. }
  123212. declare module BABYLON {
  123213. /** @hidden */
  123214. export var lensFlareVertexShader: {
  123215. name: string;
  123216. shader: string;
  123217. };
  123218. }
  123219. declare module BABYLON {
  123220. /**
  123221. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123222. * It is usually composed of several `lensFlare`.
  123223. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123224. */
  123225. export class LensFlareSystem {
  123226. /**
  123227. * Define the name of the lens flare system
  123228. */
  123229. name: string;
  123230. /**
  123231. * List of lens flares used in this system.
  123232. */
  123233. lensFlares: LensFlare[];
  123234. /**
  123235. * Define a limit from the border the lens flare can be visible.
  123236. */
  123237. borderLimit: number;
  123238. /**
  123239. * Define a viewport border we do not want to see the lens flare in.
  123240. */
  123241. viewportBorder: number;
  123242. /**
  123243. * Define a predicate which could limit the list of meshes able to occlude the effect.
  123244. */
  123245. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  123246. /**
  123247. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  123248. */
  123249. layerMask: number;
  123250. /**
  123251. * Define the id of the lens flare system in the scene.
  123252. * (equal to name by default)
  123253. */
  123254. id: string;
  123255. private _scene;
  123256. private _emitter;
  123257. private _vertexBuffers;
  123258. private _indexBuffer;
  123259. private _effect;
  123260. private _positionX;
  123261. private _positionY;
  123262. private _isEnabled;
  123263. /** @hidden */
  123264. static _SceneComponentInitialization: (scene: Scene) => void;
  123265. /**
  123266. * Instantiates a lens flare system.
  123267. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123268. * It is usually composed of several `lensFlare`.
  123269. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123270. * @param name Define the name of the lens flare system in the scene
  123271. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  123272. * @param scene Define the scene the lens flare system belongs to
  123273. */
  123274. constructor(
  123275. /**
  123276. * Define the name of the lens flare system
  123277. */
  123278. name: string, emitter: any, scene: Scene);
  123279. /**
  123280. * Define if the lens flare system is enabled.
  123281. */
  123282. get isEnabled(): boolean;
  123283. set isEnabled(value: boolean);
  123284. /**
  123285. * Get the scene the effects belongs to.
  123286. * @returns the scene holding the lens flare system
  123287. */
  123288. getScene(): Scene;
  123289. /**
  123290. * Get the emitter of the lens flare system.
  123291. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123292. * @returns the emitter of the lens flare system
  123293. */
  123294. getEmitter(): any;
  123295. /**
  123296. * Set the emitter of the lens flare system.
  123297. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123298. * @param newEmitter Define the new emitter of the system
  123299. */
  123300. setEmitter(newEmitter: any): void;
  123301. /**
  123302. * Get the lens flare system emitter position.
  123303. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  123304. * @returns the position
  123305. */
  123306. getEmitterPosition(): Vector3;
  123307. /**
  123308. * @hidden
  123309. */
  123310. computeEffectivePosition(globalViewport: Viewport): boolean;
  123311. /** @hidden */
  123312. _isVisible(): boolean;
  123313. /**
  123314. * @hidden
  123315. */
  123316. render(): boolean;
  123317. /**
  123318. * Dispose and release the lens flare with its associated resources.
  123319. */
  123320. dispose(): void;
  123321. /**
  123322. * Parse a lens flare system from a JSON repressentation
  123323. * @param parsedLensFlareSystem Define the JSON to parse
  123324. * @param scene Define the scene the parsed system should be instantiated in
  123325. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  123326. * @returns the parsed system
  123327. */
  123328. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  123329. /**
  123330. * Serialize the current Lens Flare System into a JSON representation.
  123331. * @returns the serialized JSON
  123332. */
  123333. serialize(): any;
  123334. }
  123335. }
  123336. declare module BABYLON {
  123337. /**
  123338. * This represents one of the lens effect in a `lensFlareSystem`.
  123339. * It controls one of the indiviual texture used in the effect.
  123340. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123341. */
  123342. export class LensFlare {
  123343. /**
  123344. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123345. */
  123346. size: number;
  123347. /**
  123348. * 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.
  123349. */
  123350. position: number;
  123351. /**
  123352. * Define the lens color.
  123353. */
  123354. color: Color3;
  123355. /**
  123356. * Define the lens texture.
  123357. */
  123358. texture: Nullable<Texture>;
  123359. /**
  123360. * Define the alpha mode to render this particular lens.
  123361. */
  123362. alphaMode: number;
  123363. private _system;
  123364. /**
  123365. * Creates a new Lens Flare.
  123366. * This represents one of the lens effect in a `lensFlareSystem`.
  123367. * It controls one of the indiviual texture used in the effect.
  123368. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123369. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  123370. * @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.
  123371. * @param color Define the lens color
  123372. * @param imgUrl Define the lens texture url
  123373. * @param system Define the `lensFlareSystem` this flare is part of
  123374. * @returns The newly created Lens Flare
  123375. */
  123376. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  123377. /**
  123378. * Instantiates a new Lens Flare.
  123379. * This represents one of the lens effect in a `lensFlareSystem`.
  123380. * It controls one of the indiviual texture used in the effect.
  123381. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123382. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  123383. * @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.
  123384. * @param color Define the lens color
  123385. * @param imgUrl Define the lens texture url
  123386. * @param system Define the `lensFlareSystem` this flare is part of
  123387. */
  123388. constructor(
  123389. /**
  123390. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123391. */
  123392. size: number,
  123393. /**
  123394. * 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.
  123395. */
  123396. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  123397. /**
  123398. * Dispose and release the lens flare with its associated resources.
  123399. */
  123400. dispose(): void;
  123401. }
  123402. }
  123403. declare module BABYLON {
  123404. interface AbstractScene {
  123405. /**
  123406. * The list of lens flare system added to the scene
  123407. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123408. */
  123409. lensFlareSystems: Array<LensFlareSystem>;
  123410. /**
  123411. * Removes the given lens flare system from this scene.
  123412. * @param toRemove The lens flare system to remove
  123413. * @returns The index of the removed lens flare system
  123414. */
  123415. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  123416. /**
  123417. * Adds the given lens flare system to this scene
  123418. * @param newLensFlareSystem The lens flare system to add
  123419. */
  123420. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  123421. /**
  123422. * Gets a lens flare system using its name
  123423. * @param name defines the name to look for
  123424. * @returns the lens flare system or null if not found
  123425. */
  123426. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  123427. /**
  123428. * Gets a lens flare system using its id
  123429. * @param id defines the id to look for
  123430. * @returns the lens flare system or null if not found
  123431. */
  123432. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  123433. }
  123434. /**
  123435. * Defines the lens flare scene component responsible to manage any lens flares
  123436. * in a given scene.
  123437. */
  123438. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  123439. /**
  123440. * The component name helpfull to identify the component in the list of scene components.
  123441. */
  123442. readonly name: string;
  123443. /**
  123444. * The scene the component belongs to.
  123445. */
  123446. scene: Scene;
  123447. /**
  123448. * Creates a new instance of the component for the given scene
  123449. * @param scene Defines the scene to register the component in
  123450. */
  123451. constructor(scene: Scene);
  123452. /**
  123453. * Registers the component in a given scene
  123454. */
  123455. register(): void;
  123456. /**
  123457. * Rebuilds the elements related to this component in case of
  123458. * context lost for instance.
  123459. */
  123460. rebuild(): void;
  123461. /**
  123462. * Adds all the elements from the container to the scene
  123463. * @param container the container holding the elements
  123464. */
  123465. addFromContainer(container: AbstractScene): void;
  123466. /**
  123467. * Removes all the elements in the container from the scene
  123468. * @param container contains the elements to remove
  123469. * @param dispose if the removed element should be disposed (default: false)
  123470. */
  123471. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123472. /**
  123473. * Serializes the component data to the specified json object
  123474. * @param serializationObject The object to serialize to
  123475. */
  123476. serialize(serializationObject: any): void;
  123477. /**
  123478. * Disposes the component and the associated ressources.
  123479. */
  123480. dispose(): void;
  123481. private _draw;
  123482. }
  123483. }
  123484. declare module BABYLON {
  123485. /**
  123486. * Defines the shadow generator component responsible to manage any shadow generators
  123487. * in a given scene.
  123488. */
  123489. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  123490. /**
  123491. * The component name helpfull to identify the component in the list of scene components.
  123492. */
  123493. readonly name: string;
  123494. /**
  123495. * The scene the component belongs to.
  123496. */
  123497. scene: Scene;
  123498. /**
  123499. * Creates a new instance of the component for the given scene
  123500. * @param scene Defines the scene to register the component in
  123501. */
  123502. constructor(scene: Scene);
  123503. /**
  123504. * Registers the component in a given scene
  123505. */
  123506. register(): void;
  123507. /**
  123508. * Rebuilds the elements related to this component in case of
  123509. * context lost for instance.
  123510. */
  123511. rebuild(): void;
  123512. /**
  123513. * Serializes the component data to the specified json object
  123514. * @param serializationObject The object to serialize to
  123515. */
  123516. serialize(serializationObject: any): void;
  123517. /**
  123518. * Adds all the elements from the container to the scene
  123519. * @param container the container holding the elements
  123520. */
  123521. addFromContainer(container: AbstractScene): void;
  123522. /**
  123523. * Removes all the elements in the container from the scene
  123524. * @param container contains the elements to remove
  123525. * @param dispose if the removed element should be disposed (default: false)
  123526. */
  123527. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123528. /**
  123529. * Rebuilds the elements related to this component in case of
  123530. * context lost for instance.
  123531. */
  123532. dispose(): void;
  123533. private _gatherRenderTargets;
  123534. }
  123535. }
  123536. declare module BABYLON {
  123537. /**
  123538. * A point light is a light defined by an unique point in world space.
  123539. * The light is emitted in every direction from this point.
  123540. * A good example of a point light is a standard light bulb.
  123541. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123542. */
  123543. export class PointLight extends ShadowLight {
  123544. private _shadowAngle;
  123545. /**
  123546. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123547. * This specifies what angle the shadow will use to be created.
  123548. *
  123549. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123550. */
  123551. get shadowAngle(): number;
  123552. /**
  123553. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123554. * This specifies what angle the shadow will use to be created.
  123555. *
  123556. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123557. */
  123558. set shadowAngle(value: number);
  123559. /**
  123560. * Gets the direction if it has been set.
  123561. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123562. */
  123563. get direction(): Vector3;
  123564. /**
  123565. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123566. */
  123567. set direction(value: Vector3);
  123568. /**
  123569. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  123570. * A PointLight emits the light in every direction.
  123571. * It can cast shadows.
  123572. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  123573. * ```javascript
  123574. * var pointLight = new PointLight("pl", camera.position, scene);
  123575. * ```
  123576. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123577. * @param name The light friendly name
  123578. * @param position The position of the point light in the scene
  123579. * @param scene The scene the lights belongs to
  123580. */
  123581. constructor(name: string, position: Vector3, scene: Scene);
  123582. /**
  123583. * Returns the string "PointLight"
  123584. * @returns the class name
  123585. */
  123586. getClassName(): string;
  123587. /**
  123588. * Returns the integer 0.
  123589. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123590. */
  123591. getTypeID(): number;
  123592. /**
  123593. * Specifies wether or not the shadowmap should be a cube texture.
  123594. * @returns true if the shadowmap needs to be a cube texture.
  123595. */
  123596. needCube(): boolean;
  123597. /**
  123598. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  123599. * @param faceIndex The index of the face we are computed the direction to generate shadow
  123600. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  123601. */
  123602. getShadowDirection(faceIndex?: number): Vector3;
  123603. /**
  123604. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  123605. * - fov = PI / 2
  123606. * - aspect ratio : 1.0
  123607. * - z-near and far equal to the active camera minZ and maxZ.
  123608. * Returns the PointLight.
  123609. */
  123610. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123611. protected _buildUniformLayout(): void;
  123612. /**
  123613. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  123614. * @param effect The effect to update
  123615. * @param lightIndex The index of the light in the effect to update
  123616. * @returns The point light
  123617. */
  123618. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  123619. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123620. /**
  123621. * Prepares the list of defines specific to the light type.
  123622. * @param defines the list of defines
  123623. * @param lightIndex defines the index of the light for the effect
  123624. */
  123625. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123626. }
  123627. }
  123628. declare module BABYLON {
  123629. /**
  123630. * Header information of HDR texture files.
  123631. */
  123632. export interface HDRInfo {
  123633. /**
  123634. * The height of the texture in pixels.
  123635. */
  123636. height: number;
  123637. /**
  123638. * The width of the texture in pixels.
  123639. */
  123640. width: number;
  123641. /**
  123642. * The index of the beginning of the data in the binary file.
  123643. */
  123644. dataPosition: number;
  123645. }
  123646. /**
  123647. * This groups tools to convert HDR texture to native colors array.
  123648. */
  123649. export class HDRTools {
  123650. private static Ldexp;
  123651. private static Rgbe2float;
  123652. private static readStringLine;
  123653. /**
  123654. * Reads header information from an RGBE texture stored in a native array.
  123655. * More information on this format are available here:
  123656. * https://en.wikipedia.org/wiki/RGBE_image_format
  123657. *
  123658. * @param uint8array The binary file stored in native array.
  123659. * @return The header information.
  123660. */
  123661. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  123662. /**
  123663. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  123664. * This RGBE texture needs to store the information as a panorama.
  123665. *
  123666. * More information on this format are available here:
  123667. * https://en.wikipedia.org/wiki/RGBE_image_format
  123668. *
  123669. * @param buffer The binary file stored in an array buffer.
  123670. * @param size The expected size of the extracted cubemap.
  123671. * @return The Cube Map information.
  123672. */
  123673. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  123674. /**
  123675. * Returns the pixels data extracted from an RGBE texture.
  123676. * This pixels will be stored left to right up to down in the R G B order in one array.
  123677. *
  123678. * More information on this format are available here:
  123679. * https://en.wikipedia.org/wiki/RGBE_image_format
  123680. *
  123681. * @param uint8array The binary file stored in an array buffer.
  123682. * @param hdrInfo The header information of the file.
  123683. * @return The pixels data in RGB right to left up to down order.
  123684. */
  123685. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  123686. private static RGBE_ReadPixels_RLE;
  123687. }
  123688. }
  123689. declare module BABYLON {
  123690. /**
  123691. * This represents a texture coming from an HDR input.
  123692. *
  123693. * The only supported format is currently panorama picture stored in RGBE format.
  123694. * Example of such files can be found on HDRLib: http://hdrlib.com/
  123695. */
  123696. export class HDRCubeTexture extends BaseTexture {
  123697. private static _facesMapping;
  123698. private _generateHarmonics;
  123699. private _noMipmap;
  123700. private _textureMatrix;
  123701. private _size;
  123702. private _onLoad;
  123703. private _onError;
  123704. /**
  123705. * The texture URL.
  123706. */
  123707. url: string;
  123708. /**
  123709. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  123710. */
  123711. coordinatesMode: number;
  123712. protected _isBlocking: boolean;
  123713. /**
  123714. * Sets wether or not the texture is blocking during loading.
  123715. */
  123716. set isBlocking(value: boolean);
  123717. /**
  123718. * Gets wether or not the texture is blocking during loading.
  123719. */
  123720. get isBlocking(): boolean;
  123721. protected _rotationY: number;
  123722. /**
  123723. * Sets texture matrix rotation angle around Y axis in radians.
  123724. */
  123725. set rotationY(value: number);
  123726. /**
  123727. * Gets texture matrix rotation angle around Y axis radians.
  123728. */
  123729. get rotationY(): number;
  123730. /**
  123731. * Gets or sets the center of the bounding box associated with the cube texture
  123732. * It must define where the camera used to render the texture was set
  123733. */
  123734. boundingBoxPosition: Vector3;
  123735. private _boundingBoxSize;
  123736. /**
  123737. * Gets or sets the size of the bounding box associated with the cube texture
  123738. * When defined, the cubemap will switch to local mode
  123739. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123740. * @example https://www.babylonjs-playground.com/#RNASML
  123741. */
  123742. set boundingBoxSize(value: Vector3);
  123743. get boundingBoxSize(): Vector3;
  123744. /**
  123745. * Instantiates an HDRTexture from the following parameters.
  123746. *
  123747. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  123748. * @param scene The scene the texture will be used in
  123749. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  123750. * @param noMipmap Forces to not generate the mipmap if true
  123751. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  123752. * @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)
  123753. * @param reserved Reserved flag for internal use.
  123754. */
  123755. 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>);
  123756. /**
  123757. * Get the current class name of the texture useful for serialization or dynamic coding.
  123758. * @returns "HDRCubeTexture"
  123759. */
  123760. getClassName(): string;
  123761. /**
  123762. * Occurs when the file is raw .hdr file.
  123763. */
  123764. private loadTexture;
  123765. clone(): HDRCubeTexture;
  123766. delayLoad(): void;
  123767. /**
  123768. * Get the texture reflection matrix used to rotate/transform the reflection.
  123769. * @returns the reflection matrix
  123770. */
  123771. getReflectionTextureMatrix(): Matrix;
  123772. /**
  123773. * Set the texture reflection matrix used to rotate/transform the reflection.
  123774. * @param value Define the reflection matrix to set
  123775. */
  123776. setReflectionTextureMatrix(value: Matrix): void;
  123777. /**
  123778. * Parses a JSON representation of an HDR Texture in order to create the texture
  123779. * @param parsedTexture Define the JSON representation
  123780. * @param scene Define the scene the texture should be created in
  123781. * @param rootUrl Define the root url in case we need to load relative dependencies
  123782. * @returns the newly created texture after parsing
  123783. */
  123784. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  123785. serialize(): any;
  123786. }
  123787. }
  123788. declare module BABYLON {
  123789. /**
  123790. * Class used to control physics engine
  123791. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123792. */
  123793. export class PhysicsEngine implements IPhysicsEngine {
  123794. private _physicsPlugin;
  123795. /**
  123796. * Global value used to control the smallest number supported by the simulation
  123797. */
  123798. static Epsilon: number;
  123799. private _impostors;
  123800. private _joints;
  123801. private _subTimeStep;
  123802. /**
  123803. * Gets the gravity vector used by the simulation
  123804. */
  123805. gravity: Vector3;
  123806. /**
  123807. * Factory used to create the default physics plugin.
  123808. * @returns The default physics plugin
  123809. */
  123810. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  123811. /**
  123812. * Creates a new Physics Engine
  123813. * @param gravity defines the gravity vector used by the simulation
  123814. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  123815. */
  123816. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  123817. /**
  123818. * Sets the gravity vector used by the simulation
  123819. * @param gravity defines the gravity vector to use
  123820. */
  123821. setGravity(gravity: Vector3): void;
  123822. /**
  123823. * Set the time step of the physics engine.
  123824. * Default is 1/60.
  123825. * To slow it down, enter 1/600 for example.
  123826. * To speed it up, 1/30
  123827. * @param newTimeStep defines the new timestep to apply to this world.
  123828. */
  123829. setTimeStep(newTimeStep?: number): void;
  123830. /**
  123831. * Get the time step of the physics engine.
  123832. * @returns the current time step
  123833. */
  123834. getTimeStep(): number;
  123835. /**
  123836. * Set the sub time step of the physics engine.
  123837. * Default is 0 meaning there is no sub steps
  123838. * To increase physics resolution precision, set a small value (like 1 ms)
  123839. * @param subTimeStep defines the new sub timestep used for physics resolution.
  123840. */
  123841. setSubTimeStep(subTimeStep?: number): void;
  123842. /**
  123843. * Get the sub time step of the physics engine.
  123844. * @returns the current sub time step
  123845. */
  123846. getSubTimeStep(): number;
  123847. /**
  123848. * Release all resources
  123849. */
  123850. dispose(): void;
  123851. /**
  123852. * Gets the name of the current physics plugin
  123853. * @returns the name of the plugin
  123854. */
  123855. getPhysicsPluginName(): string;
  123856. /**
  123857. * Adding a new impostor for the impostor tracking.
  123858. * This will be done by the impostor itself.
  123859. * @param impostor the impostor to add
  123860. */
  123861. addImpostor(impostor: PhysicsImpostor): void;
  123862. /**
  123863. * Remove an impostor from the engine.
  123864. * This impostor and its mesh will not longer be updated by the physics engine.
  123865. * @param impostor the impostor to remove
  123866. */
  123867. removeImpostor(impostor: PhysicsImpostor): void;
  123868. /**
  123869. * Add a joint to the physics engine
  123870. * @param mainImpostor defines the main impostor to which the joint is added.
  123871. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  123872. * @param joint defines the joint that will connect both impostors.
  123873. */
  123874. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123875. /**
  123876. * Removes a joint from the simulation
  123877. * @param mainImpostor defines the impostor used with the joint
  123878. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  123879. * @param joint defines the joint to remove
  123880. */
  123881. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123882. /**
  123883. * Called by the scene. No need to call it.
  123884. * @param delta defines the timespam between frames
  123885. */
  123886. _step(delta: number): void;
  123887. /**
  123888. * Gets the current plugin used to run the simulation
  123889. * @returns current plugin
  123890. */
  123891. getPhysicsPlugin(): IPhysicsEnginePlugin;
  123892. /**
  123893. * Gets the list of physic impostors
  123894. * @returns an array of PhysicsImpostor
  123895. */
  123896. getImpostors(): Array<PhysicsImpostor>;
  123897. /**
  123898. * Gets the impostor for a physics enabled object
  123899. * @param object defines the object impersonated by the impostor
  123900. * @returns the PhysicsImpostor or null if not found
  123901. */
  123902. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  123903. /**
  123904. * Gets the impostor for a physics body object
  123905. * @param body defines physics body used by the impostor
  123906. * @returns the PhysicsImpostor or null if not found
  123907. */
  123908. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  123909. /**
  123910. * Does a raycast in the physics world
  123911. * @param from when should the ray start?
  123912. * @param to when should the ray end?
  123913. * @returns PhysicsRaycastResult
  123914. */
  123915. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123916. }
  123917. }
  123918. declare module BABYLON {
  123919. /** @hidden */
  123920. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  123921. private _useDeltaForWorldStep;
  123922. world: any;
  123923. name: string;
  123924. private _physicsMaterials;
  123925. private _fixedTimeStep;
  123926. private _cannonRaycastResult;
  123927. private _raycastResult;
  123928. private _physicsBodysToRemoveAfterStep;
  123929. BJSCANNON: any;
  123930. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  123931. setGravity(gravity: Vector3): void;
  123932. setTimeStep(timeStep: number): void;
  123933. getTimeStep(): number;
  123934. executeStep(delta: number): void;
  123935. private _removeMarkedPhysicsBodiesFromWorld;
  123936. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123937. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123938. generatePhysicsBody(impostor: PhysicsImpostor): void;
  123939. private _processChildMeshes;
  123940. removePhysicsBody(impostor: PhysicsImpostor): void;
  123941. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  123942. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  123943. private _addMaterial;
  123944. private _checkWithEpsilon;
  123945. private _createShape;
  123946. private _createHeightmap;
  123947. private _minus90X;
  123948. private _plus90X;
  123949. private _tmpPosition;
  123950. private _tmpDeltaPosition;
  123951. private _tmpUnityRotation;
  123952. private _updatePhysicsBodyTransformation;
  123953. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  123954. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  123955. isSupported(): boolean;
  123956. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123957. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123958. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123959. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123960. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  123961. getBodyMass(impostor: PhysicsImpostor): number;
  123962. getBodyFriction(impostor: PhysicsImpostor): number;
  123963. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  123964. getBodyRestitution(impostor: PhysicsImpostor): number;
  123965. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  123966. sleepBody(impostor: PhysicsImpostor): void;
  123967. wakeUpBody(impostor: PhysicsImpostor): void;
  123968. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  123969. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  123970. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  123971. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  123972. getRadius(impostor: PhysicsImpostor): number;
  123973. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  123974. dispose(): void;
  123975. private _extendNamespace;
  123976. /**
  123977. * Does a raycast in the physics world
  123978. * @param from when should the ray start?
  123979. * @param to when should the ray end?
  123980. * @returns PhysicsRaycastResult
  123981. */
  123982. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123983. }
  123984. }
  123985. declare module BABYLON {
  123986. /** @hidden */
  123987. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  123988. world: any;
  123989. name: string;
  123990. BJSOIMO: any;
  123991. private _raycastResult;
  123992. constructor(iterations?: number, oimoInjection?: any);
  123993. setGravity(gravity: Vector3): void;
  123994. setTimeStep(timeStep: number): void;
  123995. getTimeStep(): number;
  123996. private _tmpImpostorsArray;
  123997. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  123998. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123999. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124000. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124001. private _tmpPositionVector;
  124002. removePhysicsBody(impostor: PhysicsImpostor): void;
  124003. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124004. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124005. isSupported(): boolean;
  124006. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124007. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124008. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124009. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124010. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124011. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124012. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124013. getBodyMass(impostor: PhysicsImpostor): number;
  124014. getBodyFriction(impostor: PhysicsImpostor): number;
  124015. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124016. getBodyRestitution(impostor: PhysicsImpostor): number;
  124017. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124018. sleepBody(impostor: PhysicsImpostor): void;
  124019. wakeUpBody(impostor: PhysicsImpostor): void;
  124020. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124021. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  124022. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  124023. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124024. getRadius(impostor: PhysicsImpostor): number;
  124025. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124026. dispose(): void;
  124027. /**
  124028. * Does a raycast in the physics world
  124029. * @param from when should the ray start?
  124030. * @param to when should the ray end?
  124031. * @returns PhysicsRaycastResult
  124032. */
  124033. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124034. }
  124035. }
  124036. declare module BABYLON {
  124037. /**
  124038. * Class containing static functions to help procedurally build meshes
  124039. */
  124040. export class RibbonBuilder {
  124041. /**
  124042. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124043. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124044. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124045. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124046. * * 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
  124047. * * 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
  124048. * * 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
  124049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124051. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124052. * * 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
  124053. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124054. * * 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
  124055. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124057. * @param name defines the name of the mesh
  124058. * @param options defines the options used to create the mesh
  124059. * @param scene defines the hosting scene
  124060. * @returns the ribbon mesh
  124061. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124063. */
  124064. static CreateRibbon(name: string, options: {
  124065. pathArray: Vector3[][];
  124066. closeArray?: boolean;
  124067. closePath?: boolean;
  124068. offset?: number;
  124069. updatable?: boolean;
  124070. sideOrientation?: number;
  124071. frontUVs?: Vector4;
  124072. backUVs?: Vector4;
  124073. instance?: Mesh;
  124074. invertUV?: boolean;
  124075. uvs?: Vector2[];
  124076. colors?: Color4[];
  124077. }, scene?: Nullable<Scene>): Mesh;
  124078. }
  124079. }
  124080. declare module BABYLON {
  124081. /**
  124082. * Class containing static functions to help procedurally build meshes
  124083. */
  124084. export class ShapeBuilder {
  124085. /**
  124086. * 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.
  124087. * * 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.
  124088. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124089. * * 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.
  124090. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124091. * * 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
  124092. * * 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
  124093. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124096. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124098. * @param name defines the name of the mesh
  124099. * @param options defines the options used to create the mesh
  124100. * @param scene defines the hosting scene
  124101. * @returns the extruded shape mesh
  124102. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124104. */
  124105. static ExtrudeShape(name: string, options: {
  124106. shape: Vector3[];
  124107. path: Vector3[];
  124108. scale?: number;
  124109. rotation?: number;
  124110. cap?: number;
  124111. updatable?: boolean;
  124112. sideOrientation?: number;
  124113. frontUVs?: Vector4;
  124114. backUVs?: Vector4;
  124115. instance?: Mesh;
  124116. invertUV?: boolean;
  124117. }, scene?: Nullable<Scene>): Mesh;
  124118. /**
  124119. * Creates an custom extruded shape mesh.
  124120. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124121. * * 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.
  124122. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124123. * * 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
  124124. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124125. * * 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
  124126. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124127. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124128. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124129. * * 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
  124130. * * 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
  124131. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124134. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124136. * @param name defines the name of the mesh
  124137. * @param options defines the options used to create the mesh
  124138. * @param scene defines the hosting scene
  124139. * @returns the custom extruded shape mesh
  124140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124141. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124143. */
  124144. static ExtrudeShapeCustom(name: string, options: {
  124145. shape: Vector3[];
  124146. path: Vector3[];
  124147. scaleFunction?: any;
  124148. rotationFunction?: any;
  124149. ribbonCloseArray?: boolean;
  124150. ribbonClosePath?: boolean;
  124151. cap?: number;
  124152. updatable?: boolean;
  124153. sideOrientation?: number;
  124154. frontUVs?: Vector4;
  124155. backUVs?: Vector4;
  124156. instance?: Mesh;
  124157. invertUV?: boolean;
  124158. }, scene?: Nullable<Scene>): Mesh;
  124159. private static _ExtrudeShapeGeneric;
  124160. }
  124161. }
  124162. declare module BABYLON {
  124163. /**
  124164. * AmmoJS Physics plugin
  124165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  124166. * @see https://github.com/kripken/ammo.js/
  124167. */
  124168. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  124169. private _useDeltaForWorldStep;
  124170. /**
  124171. * Reference to the Ammo library
  124172. */
  124173. bjsAMMO: any;
  124174. /**
  124175. * Created ammoJS world which physics bodies are added to
  124176. */
  124177. world: any;
  124178. /**
  124179. * Name of the plugin
  124180. */
  124181. name: string;
  124182. private _timeStep;
  124183. private _fixedTimeStep;
  124184. private _maxSteps;
  124185. private _tmpQuaternion;
  124186. private _tmpAmmoTransform;
  124187. private _tmpAmmoQuaternion;
  124188. private _tmpAmmoConcreteContactResultCallback;
  124189. private _collisionConfiguration;
  124190. private _dispatcher;
  124191. private _overlappingPairCache;
  124192. private _solver;
  124193. private _softBodySolver;
  124194. private _tmpAmmoVectorA;
  124195. private _tmpAmmoVectorB;
  124196. private _tmpAmmoVectorC;
  124197. private _tmpAmmoVectorD;
  124198. private _tmpContactCallbackResult;
  124199. private _tmpAmmoVectorRCA;
  124200. private _tmpAmmoVectorRCB;
  124201. private _raycastResult;
  124202. private static readonly DISABLE_COLLISION_FLAG;
  124203. private static readonly KINEMATIC_FLAG;
  124204. private static readonly DISABLE_DEACTIVATION_FLAG;
  124205. /**
  124206. * Initializes the ammoJS plugin
  124207. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  124208. * @param ammoInjection can be used to inject your own ammo reference
  124209. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  124210. */
  124211. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  124212. /**
  124213. * Sets the gravity of the physics world (m/(s^2))
  124214. * @param gravity Gravity to set
  124215. */
  124216. setGravity(gravity: Vector3): void;
  124217. /**
  124218. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  124219. * @param timeStep timestep to use in seconds
  124220. */
  124221. setTimeStep(timeStep: number): void;
  124222. /**
  124223. * 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)
  124224. * @param fixedTimeStep fixedTimeStep to use in seconds
  124225. */
  124226. setFixedTimeStep(fixedTimeStep: number): void;
  124227. /**
  124228. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  124229. * @param maxSteps the maximum number of steps by the physics engine per frame
  124230. */
  124231. setMaxSteps(maxSteps: number): void;
  124232. /**
  124233. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  124234. * @returns the current timestep in seconds
  124235. */
  124236. getTimeStep(): number;
  124237. /**
  124238. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  124239. */
  124240. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  124241. private _isImpostorInContact;
  124242. private _isImpostorPairInContact;
  124243. private _stepSimulation;
  124244. /**
  124245. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  124246. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  124247. * After the step the babylon meshes are set to the position of the physics imposters
  124248. * @param delta amount of time to step forward
  124249. * @param impostors array of imposters to update before/after the step
  124250. */
  124251. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124252. /**
  124253. * Update babylon mesh to match physics world object
  124254. * @param impostor imposter to match
  124255. */
  124256. private _afterSoftStep;
  124257. /**
  124258. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124259. * @param impostor imposter to match
  124260. */
  124261. private _ropeStep;
  124262. /**
  124263. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124264. * @param impostor imposter to match
  124265. */
  124266. private _softbodyOrClothStep;
  124267. private _tmpVector;
  124268. private _tmpMatrix;
  124269. /**
  124270. * Applies an impulse on the imposter
  124271. * @param impostor imposter to apply impulse to
  124272. * @param force amount of force to be applied to the imposter
  124273. * @param contactPoint the location to apply the impulse on the imposter
  124274. */
  124275. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124276. /**
  124277. * Applies a force on the imposter
  124278. * @param impostor imposter to apply force
  124279. * @param force amount of force to be applied to the imposter
  124280. * @param contactPoint the location to apply the force on the imposter
  124281. */
  124282. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124283. /**
  124284. * Creates a physics body using the plugin
  124285. * @param impostor the imposter to create the physics body on
  124286. */
  124287. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124288. /**
  124289. * Removes the physics body from the imposter and disposes of the body's memory
  124290. * @param impostor imposter to remove the physics body from
  124291. */
  124292. removePhysicsBody(impostor: PhysicsImpostor): void;
  124293. /**
  124294. * Generates a joint
  124295. * @param impostorJoint the imposter joint to create the joint with
  124296. */
  124297. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124298. /**
  124299. * Removes a joint
  124300. * @param impostorJoint the imposter joint to remove the joint from
  124301. */
  124302. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124303. private _addMeshVerts;
  124304. /**
  124305. * Initialise the soft body vertices to match its object's (mesh) vertices
  124306. * Softbody vertices (nodes) are in world space and to match this
  124307. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  124308. * @param impostor to create the softbody for
  124309. */
  124310. private _softVertexData;
  124311. /**
  124312. * Create an impostor's soft body
  124313. * @param impostor to create the softbody for
  124314. */
  124315. private _createSoftbody;
  124316. /**
  124317. * Create cloth for an impostor
  124318. * @param impostor to create the softbody for
  124319. */
  124320. private _createCloth;
  124321. /**
  124322. * Create rope for an impostor
  124323. * @param impostor to create the softbody for
  124324. */
  124325. private _createRope;
  124326. /**
  124327. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  124328. * @param impostor to create the custom physics shape for
  124329. */
  124330. private _createCustom;
  124331. private _addHullVerts;
  124332. private _createShape;
  124333. /**
  124334. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  124335. * @param impostor imposter containing the physics body and babylon object
  124336. */
  124337. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124338. /**
  124339. * Sets the babylon object's position/rotation from the physics body's position/rotation
  124340. * @param impostor imposter containing the physics body and babylon object
  124341. * @param newPosition new position
  124342. * @param newRotation new rotation
  124343. */
  124344. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124345. /**
  124346. * If this plugin is supported
  124347. * @returns true if its supported
  124348. */
  124349. isSupported(): boolean;
  124350. /**
  124351. * Sets the linear velocity of the physics body
  124352. * @param impostor imposter to set the velocity on
  124353. * @param velocity velocity to set
  124354. */
  124355. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124356. /**
  124357. * Sets the angular velocity of the physics body
  124358. * @param impostor imposter to set the velocity on
  124359. * @param velocity velocity to set
  124360. */
  124361. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124362. /**
  124363. * gets the linear velocity
  124364. * @param impostor imposter to get linear velocity from
  124365. * @returns linear velocity
  124366. */
  124367. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124368. /**
  124369. * gets the angular velocity
  124370. * @param impostor imposter to get angular velocity from
  124371. * @returns angular velocity
  124372. */
  124373. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124374. /**
  124375. * Sets the mass of physics body
  124376. * @param impostor imposter to set the mass on
  124377. * @param mass mass to set
  124378. */
  124379. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124380. /**
  124381. * Gets the mass of the physics body
  124382. * @param impostor imposter to get the mass from
  124383. * @returns mass
  124384. */
  124385. getBodyMass(impostor: PhysicsImpostor): number;
  124386. /**
  124387. * Gets friction of the impostor
  124388. * @param impostor impostor to get friction from
  124389. * @returns friction value
  124390. */
  124391. getBodyFriction(impostor: PhysicsImpostor): number;
  124392. /**
  124393. * Sets friction of the impostor
  124394. * @param impostor impostor to set friction on
  124395. * @param friction friction value
  124396. */
  124397. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124398. /**
  124399. * Gets restitution of the impostor
  124400. * @param impostor impostor to get restitution from
  124401. * @returns restitution value
  124402. */
  124403. getBodyRestitution(impostor: PhysicsImpostor): number;
  124404. /**
  124405. * Sets resitution of the impostor
  124406. * @param impostor impostor to set resitution on
  124407. * @param restitution resitution value
  124408. */
  124409. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124410. /**
  124411. * Gets pressure inside the impostor
  124412. * @param impostor impostor to get pressure from
  124413. * @returns pressure value
  124414. */
  124415. getBodyPressure(impostor: PhysicsImpostor): number;
  124416. /**
  124417. * Sets pressure inside a soft body impostor
  124418. * Cloth and rope must remain 0 pressure
  124419. * @param impostor impostor to set pressure on
  124420. * @param pressure pressure value
  124421. */
  124422. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  124423. /**
  124424. * Gets stiffness of the impostor
  124425. * @param impostor impostor to get stiffness from
  124426. * @returns pressure value
  124427. */
  124428. getBodyStiffness(impostor: PhysicsImpostor): number;
  124429. /**
  124430. * Sets stiffness of the impostor
  124431. * @param impostor impostor to set stiffness on
  124432. * @param stiffness stiffness value from 0 to 1
  124433. */
  124434. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  124435. /**
  124436. * Gets velocityIterations of the impostor
  124437. * @param impostor impostor to get velocity iterations from
  124438. * @returns velocityIterations value
  124439. */
  124440. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  124441. /**
  124442. * Sets velocityIterations of the impostor
  124443. * @param impostor impostor to set velocity iterations on
  124444. * @param velocityIterations velocityIterations value
  124445. */
  124446. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  124447. /**
  124448. * Gets positionIterations of the impostor
  124449. * @param impostor impostor to get position iterations from
  124450. * @returns positionIterations value
  124451. */
  124452. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  124453. /**
  124454. * Sets positionIterations of the impostor
  124455. * @param impostor impostor to set position on
  124456. * @param positionIterations positionIterations value
  124457. */
  124458. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  124459. /**
  124460. * Append an anchor to a cloth object
  124461. * @param impostor is the cloth impostor to add anchor to
  124462. * @param otherImpostor is the rigid impostor to anchor to
  124463. * @param width ratio across width from 0 to 1
  124464. * @param height ratio up height from 0 to 1
  124465. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  124466. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124467. */
  124468. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124469. /**
  124470. * Append an hook to a rope object
  124471. * @param impostor is the rope impostor to add hook to
  124472. * @param otherImpostor is the rigid impostor to hook to
  124473. * @param length ratio along the rope from 0 to 1
  124474. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  124475. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124476. */
  124477. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124478. /**
  124479. * Sleeps the physics body and stops it from being active
  124480. * @param impostor impostor to sleep
  124481. */
  124482. sleepBody(impostor: PhysicsImpostor): void;
  124483. /**
  124484. * Activates the physics body
  124485. * @param impostor impostor to activate
  124486. */
  124487. wakeUpBody(impostor: PhysicsImpostor): void;
  124488. /**
  124489. * Updates the distance parameters of the joint
  124490. * @param joint joint to update
  124491. * @param maxDistance maximum distance of the joint
  124492. * @param minDistance minimum distance of the joint
  124493. */
  124494. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124495. /**
  124496. * Sets a motor on the joint
  124497. * @param joint joint to set motor on
  124498. * @param speed speed of the motor
  124499. * @param maxForce maximum force of the motor
  124500. * @param motorIndex index of the motor
  124501. */
  124502. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124503. /**
  124504. * Sets the motors limit
  124505. * @param joint joint to set limit on
  124506. * @param upperLimit upper limit
  124507. * @param lowerLimit lower limit
  124508. */
  124509. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124510. /**
  124511. * Syncs the position and rotation of a mesh with the impostor
  124512. * @param mesh mesh to sync
  124513. * @param impostor impostor to update the mesh with
  124514. */
  124515. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124516. /**
  124517. * Gets the radius of the impostor
  124518. * @param impostor impostor to get radius from
  124519. * @returns the radius
  124520. */
  124521. getRadius(impostor: PhysicsImpostor): number;
  124522. /**
  124523. * Gets the box size of the impostor
  124524. * @param impostor impostor to get box size from
  124525. * @param result the resulting box size
  124526. */
  124527. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124528. /**
  124529. * Disposes of the impostor
  124530. */
  124531. dispose(): void;
  124532. /**
  124533. * Does a raycast in the physics world
  124534. * @param from when should the ray start?
  124535. * @param to when should the ray end?
  124536. * @returns PhysicsRaycastResult
  124537. */
  124538. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124539. }
  124540. }
  124541. declare module BABYLON {
  124542. interface AbstractScene {
  124543. /**
  124544. * The list of reflection probes added to the scene
  124545. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124546. */
  124547. reflectionProbes: Array<ReflectionProbe>;
  124548. /**
  124549. * Removes the given reflection probe from this scene.
  124550. * @param toRemove The reflection probe to remove
  124551. * @returns The index of the removed reflection probe
  124552. */
  124553. removeReflectionProbe(toRemove: ReflectionProbe): number;
  124554. /**
  124555. * Adds the given reflection probe to this scene.
  124556. * @param newReflectionProbe The reflection probe to add
  124557. */
  124558. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  124559. }
  124560. /**
  124561. * Class used to generate realtime reflection / refraction cube textures
  124562. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124563. */
  124564. export class ReflectionProbe {
  124565. /** defines the name of the probe */
  124566. name: string;
  124567. private _scene;
  124568. private _renderTargetTexture;
  124569. private _projectionMatrix;
  124570. private _viewMatrix;
  124571. private _target;
  124572. private _add;
  124573. private _attachedMesh;
  124574. private _invertYAxis;
  124575. /** Gets or sets probe position (center of the cube map) */
  124576. position: Vector3;
  124577. /**
  124578. * Creates a new reflection probe
  124579. * @param name defines the name of the probe
  124580. * @param size defines the texture resolution (for each face)
  124581. * @param scene defines the hosting scene
  124582. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124583. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124584. */
  124585. constructor(
  124586. /** defines the name of the probe */
  124587. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  124588. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124589. get samples(): number;
  124590. set samples(value: number);
  124591. /** Gets or sets the refresh rate to use (on every frame by default) */
  124592. get refreshRate(): number;
  124593. set refreshRate(value: number);
  124594. /**
  124595. * Gets the hosting scene
  124596. * @returns a Scene
  124597. */
  124598. getScene(): Scene;
  124599. /** Gets the internal CubeTexture used to render to */
  124600. get cubeTexture(): RenderTargetTexture;
  124601. /** Gets the list of meshes to render */
  124602. get renderList(): Nullable<AbstractMesh[]>;
  124603. /**
  124604. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124605. * @param mesh defines the mesh to attach to
  124606. */
  124607. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  124608. /**
  124609. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124610. * @param renderingGroupId The rendering group id corresponding to its index
  124611. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124612. */
  124613. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  124614. /**
  124615. * Clean all associated resources
  124616. */
  124617. dispose(): void;
  124618. /**
  124619. * Converts the reflection probe information to a readable string for debug purpose.
  124620. * @param fullDetails Supports for multiple levels of logging within scene loading
  124621. * @returns the human readable reflection probe info
  124622. */
  124623. toString(fullDetails?: boolean): string;
  124624. /**
  124625. * Get the class name of the relfection probe.
  124626. * @returns "ReflectionProbe"
  124627. */
  124628. getClassName(): string;
  124629. /**
  124630. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124631. * @returns The JSON representation of the texture
  124632. */
  124633. serialize(): any;
  124634. /**
  124635. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124636. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124637. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124638. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124639. * @returns The parsed reflection probe if successful
  124640. */
  124641. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  124642. }
  124643. }
  124644. declare module BABYLON {
  124645. /** @hidden */
  124646. export var _BabylonLoaderRegistered: boolean;
  124647. /**
  124648. * Helps setting up some configuration for the babylon file loader.
  124649. */
  124650. export class BabylonFileLoaderConfiguration {
  124651. /**
  124652. * The loader does not allow injecting custom physix engine into the plugins.
  124653. * Unfortunately in ES6, we need to manually inject them into the plugin.
  124654. * So you could set this variable to your engine import to make it work.
  124655. */
  124656. static LoaderInjectedPhysicsEngine: any;
  124657. }
  124658. }
  124659. declare module BABYLON {
  124660. /**
  124661. * The Physically based simple base material of BJS.
  124662. *
  124663. * This enables better naming and convention enforcements on top of the pbrMaterial.
  124664. * It is used as the base class for both the specGloss and metalRough conventions.
  124665. */
  124666. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  124667. /**
  124668. * Number of Simultaneous lights allowed on the material.
  124669. */
  124670. maxSimultaneousLights: number;
  124671. /**
  124672. * If sets to true, disables all the lights affecting the material.
  124673. */
  124674. disableLighting: boolean;
  124675. /**
  124676. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  124677. */
  124678. environmentTexture: BaseTexture;
  124679. /**
  124680. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124681. */
  124682. invertNormalMapX: boolean;
  124683. /**
  124684. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124685. */
  124686. invertNormalMapY: boolean;
  124687. /**
  124688. * Normal map used in the model.
  124689. */
  124690. normalTexture: BaseTexture;
  124691. /**
  124692. * Emissivie color used to self-illuminate the model.
  124693. */
  124694. emissiveColor: Color3;
  124695. /**
  124696. * Emissivie texture used to self-illuminate the model.
  124697. */
  124698. emissiveTexture: BaseTexture;
  124699. /**
  124700. * Occlusion Channel Strenght.
  124701. */
  124702. occlusionStrength: number;
  124703. /**
  124704. * Occlusion Texture of the material (adding extra occlusion effects).
  124705. */
  124706. occlusionTexture: BaseTexture;
  124707. /**
  124708. * Defines the alpha limits in alpha test mode.
  124709. */
  124710. alphaCutOff: number;
  124711. /**
  124712. * Gets the current double sided mode.
  124713. */
  124714. get doubleSided(): boolean;
  124715. /**
  124716. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124717. */
  124718. set doubleSided(value: boolean);
  124719. /**
  124720. * Stores the pre-calculated light information of a mesh in a texture.
  124721. */
  124722. lightmapTexture: BaseTexture;
  124723. /**
  124724. * If true, the light map contains occlusion information instead of lighting info.
  124725. */
  124726. useLightmapAsShadowmap: boolean;
  124727. /**
  124728. * Instantiates a new PBRMaterial instance.
  124729. *
  124730. * @param name The material name
  124731. * @param scene The scene the material will be use in.
  124732. */
  124733. constructor(name: string, scene: Scene);
  124734. getClassName(): string;
  124735. }
  124736. }
  124737. declare module BABYLON {
  124738. /**
  124739. * The PBR material of BJS following the metal roughness convention.
  124740. *
  124741. * This fits to the PBR convention in the GLTF definition:
  124742. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  124743. */
  124744. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  124745. /**
  124746. * The base color has two different interpretations depending on the value of metalness.
  124747. * When the material is a metal, the base color is the specific measured reflectance value
  124748. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  124749. * of the material.
  124750. */
  124751. baseColor: Color3;
  124752. /**
  124753. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  124754. * well as opacity information in the alpha channel.
  124755. */
  124756. baseTexture: BaseTexture;
  124757. /**
  124758. * Specifies the metallic scalar value of the material.
  124759. * Can also be used to scale the metalness values of the metallic texture.
  124760. */
  124761. metallic: number;
  124762. /**
  124763. * Specifies the roughness scalar value of the material.
  124764. * Can also be used to scale the roughness values of the metallic texture.
  124765. */
  124766. roughness: number;
  124767. /**
  124768. * Texture containing both the metallic value in the B channel and the
  124769. * roughness value in the G channel to keep better precision.
  124770. */
  124771. metallicRoughnessTexture: BaseTexture;
  124772. /**
  124773. * Instantiates a new PBRMetalRoughnessMaterial instance.
  124774. *
  124775. * @param name The material name
  124776. * @param scene The scene the material will be use in.
  124777. */
  124778. constructor(name: string, scene: Scene);
  124779. /**
  124780. * Return the currrent class name of the material.
  124781. */
  124782. getClassName(): string;
  124783. /**
  124784. * Makes a duplicate of the current material.
  124785. * @param name - name to use for the new material.
  124786. */
  124787. clone(name: string): PBRMetallicRoughnessMaterial;
  124788. /**
  124789. * Serialize the material to a parsable JSON object.
  124790. */
  124791. serialize(): any;
  124792. /**
  124793. * Parses a JSON object correponding to the serialize function.
  124794. */
  124795. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  124796. }
  124797. }
  124798. declare module BABYLON {
  124799. /**
  124800. * The PBR material of BJS following the specular glossiness convention.
  124801. *
  124802. * This fits to the PBR convention in the GLTF definition:
  124803. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  124804. */
  124805. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  124806. /**
  124807. * Specifies the diffuse color of the material.
  124808. */
  124809. diffuseColor: Color3;
  124810. /**
  124811. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  124812. * channel.
  124813. */
  124814. diffuseTexture: BaseTexture;
  124815. /**
  124816. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  124817. */
  124818. specularColor: Color3;
  124819. /**
  124820. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  124821. */
  124822. glossiness: number;
  124823. /**
  124824. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  124825. */
  124826. specularGlossinessTexture: BaseTexture;
  124827. /**
  124828. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  124829. *
  124830. * @param name The material name
  124831. * @param scene The scene the material will be use in.
  124832. */
  124833. constructor(name: string, scene: Scene);
  124834. /**
  124835. * Return the currrent class name of the material.
  124836. */
  124837. getClassName(): string;
  124838. /**
  124839. * Makes a duplicate of the current material.
  124840. * @param name - name to use for the new material.
  124841. */
  124842. clone(name: string): PBRSpecularGlossinessMaterial;
  124843. /**
  124844. * Serialize the material to a parsable JSON object.
  124845. */
  124846. serialize(): any;
  124847. /**
  124848. * Parses a JSON object correponding to the serialize function.
  124849. */
  124850. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  124851. }
  124852. }
  124853. declare module BABYLON {
  124854. /**
  124855. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  124856. * It can help converting any input color in a desired output one. This can then be used to create effects
  124857. * from sepia, black and white to sixties or futuristic rendering...
  124858. *
  124859. * The only supported format is currently 3dl.
  124860. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  124861. */
  124862. export class ColorGradingTexture extends BaseTexture {
  124863. /**
  124864. * The current texture matrix. (will always be identity in color grading texture)
  124865. */
  124866. private _textureMatrix;
  124867. /**
  124868. * The texture URL.
  124869. */
  124870. url: string;
  124871. /**
  124872. * Empty line regex stored for GC.
  124873. */
  124874. private static _noneEmptyLineRegex;
  124875. private _engine;
  124876. /**
  124877. * Instantiates a ColorGradingTexture from the following parameters.
  124878. *
  124879. * @param url The location of the color gradind data (currently only supporting 3dl)
  124880. * @param scene The scene the texture will be used in
  124881. */
  124882. constructor(url: string, scene: Scene);
  124883. /**
  124884. * Returns the texture matrix used in most of the material.
  124885. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  124886. */
  124887. getTextureMatrix(): Matrix;
  124888. /**
  124889. * Occurs when the file being loaded is a .3dl LUT file.
  124890. */
  124891. private load3dlTexture;
  124892. /**
  124893. * Starts the loading process of the texture.
  124894. */
  124895. private loadTexture;
  124896. /**
  124897. * Clones the color gradind texture.
  124898. */
  124899. clone(): ColorGradingTexture;
  124900. /**
  124901. * Called during delayed load for textures.
  124902. */
  124903. delayLoad(): void;
  124904. /**
  124905. * Parses a color grading texture serialized by Babylon.
  124906. * @param parsedTexture The texture information being parsedTexture
  124907. * @param scene The scene to load the texture in
  124908. * @param rootUrl The root url of the data assets to load
  124909. * @return A color gradind texture
  124910. */
  124911. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  124912. /**
  124913. * Serializes the LUT texture to json format.
  124914. */
  124915. serialize(): any;
  124916. }
  124917. }
  124918. declare module BABYLON {
  124919. /**
  124920. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  124921. */
  124922. export class EquiRectangularCubeTexture extends BaseTexture {
  124923. /** The six faces of the cube. */
  124924. private static _FacesMapping;
  124925. private _noMipmap;
  124926. private _onLoad;
  124927. private _onError;
  124928. /** The size of the cubemap. */
  124929. private _size;
  124930. /** The buffer of the image. */
  124931. private _buffer;
  124932. /** The width of the input image. */
  124933. private _width;
  124934. /** The height of the input image. */
  124935. private _height;
  124936. /** The URL to the image. */
  124937. url: string;
  124938. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  124939. coordinatesMode: number;
  124940. /**
  124941. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  124942. * @param url The location of the image
  124943. * @param scene The scene the texture will be used in
  124944. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  124945. * @param noMipmap Forces to not generate the mipmap if true
  124946. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  124947. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  124948. * @param onLoad — defines a callback called when texture is loaded
  124949. * @param onError — defines a callback called if there is an error
  124950. */
  124951. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  124952. /**
  124953. * Load the image data, by putting the image on a canvas and extracting its buffer.
  124954. */
  124955. private loadImage;
  124956. /**
  124957. * Convert the image buffer into a cubemap and create a CubeTexture.
  124958. */
  124959. private loadTexture;
  124960. /**
  124961. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  124962. * @param buffer The ArrayBuffer that should be converted.
  124963. * @returns The buffer as Float32Array.
  124964. */
  124965. private getFloat32ArrayFromArrayBuffer;
  124966. /**
  124967. * Get the current class name of the texture useful for serialization or dynamic coding.
  124968. * @returns "EquiRectangularCubeTexture"
  124969. */
  124970. getClassName(): string;
  124971. /**
  124972. * Create a clone of the current EquiRectangularCubeTexture and return it.
  124973. * @returns A clone of the current EquiRectangularCubeTexture.
  124974. */
  124975. clone(): EquiRectangularCubeTexture;
  124976. }
  124977. }
  124978. declare module BABYLON {
  124979. /**
  124980. * Based on jsTGALoader - Javascript loader for TGA file
  124981. * By Vincent Thibault
  124982. * @see http://blog.robrowser.com/javascript-tga-loader.html
  124983. */
  124984. export class TGATools {
  124985. private static _TYPE_INDEXED;
  124986. private static _TYPE_RGB;
  124987. private static _TYPE_GREY;
  124988. private static _TYPE_RLE_INDEXED;
  124989. private static _TYPE_RLE_RGB;
  124990. private static _TYPE_RLE_GREY;
  124991. private static _ORIGIN_MASK;
  124992. private static _ORIGIN_SHIFT;
  124993. private static _ORIGIN_BL;
  124994. private static _ORIGIN_BR;
  124995. private static _ORIGIN_UL;
  124996. private static _ORIGIN_UR;
  124997. /**
  124998. * Gets the header of a TGA file
  124999. * @param data defines the TGA data
  125000. * @returns the header
  125001. */
  125002. static GetTGAHeader(data: Uint8Array): any;
  125003. /**
  125004. * Uploads TGA content to a Babylon Texture
  125005. * @hidden
  125006. */
  125007. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  125008. /** @hidden */
  125009. 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;
  125010. /** @hidden */
  125011. 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;
  125012. /** @hidden */
  125013. 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;
  125014. /** @hidden */
  125015. 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;
  125016. /** @hidden */
  125017. 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;
  125018. /** @hidden */
  125019. 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;
  125020. }
  125021. }
  125022. declare module BABYLON {
  125023. /**
  125024. * Implementation of the TGA Texture Loader.
  125025. * @hidden
  125026. */
  125027. export class _TGATextureLoader implements IInternalTextureLoader {
  125028. /**
  125029. * Defines wether the loader supports cascade loading the different faces.
  125030. */
  125031. readonly supportCascades: boolean;
  125032. /**
  125033. * This returns if the loader support the current file information.
  125034. * @param extension defines the file extension of the file being loaded
  125035. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125036. * @param fallback defines the fallback internal texture if any
  125037. * @param isBase64 defines whether the texture is encoded as a base64
  125038. * @param isBuffer defines whether the texture data are stored as a buffer
  125039. * @returns true if the loader can load the specified file
  125040. */
  125041. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125042. /**
  125043. * Transform the url before loading if required.
  125044. * @param rootUrl the url of the texture
  125045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125046. * @returns the transformed texture
  125047. */
  125048. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125049. /**
  125050. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125051. * @param rootUrl the url of the texture
  125052. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125053. * @returns the fallback texture
  125054. */
  125055. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125056. /**
  125057. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125058. * @param data contains the texture data
  125059. * @param texture defines the BabylonJS internal texture
  125060. * @param createPolynomials will be true if polynomials have been requested
  125061. * @param onLoad defines the callback to trigger once the texture is ready
  125062. * @param onError defines the callback to trigger in case of error
  125063. */
  125064. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125065. /**
  125066. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125067. * @param data contains the texture data
  125068. * @param texture defines the BabylonJS internal texture
  125069. * @param callback defines the method to call once ready to upload
  125070. */
  125071. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125072. }
  125073. }
  125074. declare module BABYLON {
  125075. /**
  125076. * Info about the .basis files
  125077. */
  125078. class BasisFileInfo {
  125079. /**
  125080. * If the file has alpha
  125081. */
  125082. hasAlpha: boolean;
  125083. /**
  125084. * Info about each image of the basis file
  125085. */
  125086. images: Array<{
  125087. levels: Array<{
  125088. width: number;
  125089. height: number;
  125090. transcodedPixels: ArrayBufferView;
  125091. }>;
  125092. }>;
  125093. }
  125094. /**
  125095. * Result of transcoding a basis file
  125096. */
  125097. class TranscodeResult {
  125098. /**
  125099. * Info about the .basis file
  125100. */
  125101. fileInfo: BasisFileInfo;
  125102. /**
  125103. * Format to use when loading the file
  125104. */
  125105. format: number;
  125106. }
  125107. /**
  125108. * Configuration options for the Basis transcoder
  125109. */
  125110. export class BasisTranscodeConfiguration {
  125111. /**
  125112. * Supported compression formats used to determine the supported output format of the transcoder
  125113. */
  125114. supportedCompressionFormats?: {
  125115. /**
  125116. * etc1 compression format
  125117. */
  125118. etc1?: boolean;
  125119. /**
  125120. * s3tc compression format
  125121. */
  125122. s3tc?: boolean;
  125123. /**
  125124. * pvrtc compression format
  125125. */
  125126. pvrtc?: boolean;
  125127. /**
  125128. * etc2 compression format
  125129. */
  125130. etc2?: boolean;
  125131. };
  125132. /**
  125133. * If mipmap levels should be loaded for transcoded images (Default: true)
  125134. */
  125135. loadMipmapLevels?: boolean;
  125136. /**
  125137. * Index of a single image to load (Default: all images)
  125138. */
  125139. loadSingleImage?: number;
  125140. }
  125141. /**
  125142. * Used to load .Basis files
  125143. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  125144. */
  125145. export class BasisTools {
  125146. private static _IgnoreSupportedFormats;
  125147. /**
  125148. * URL to use when loading the basis transcoder
  125149. */
  125150. static JSModuleURL: string;
  125151. /**
  125152. * URL to use when loading the wasm module for the transcoder
  125153. */
  125154. static WasmModuleURL: string;
  125155. /**
  125156. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  125157. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  125158. * @returns internal format corresponding to the Basis format
  125159. */
  125160. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  125161. private static _WorkerPromise;
  125162. private static _Worker;
  125163. private static _actionId;
  125164. private static _CreateWorkerAsync;
  125165. /**
  125166. * Transcodes a loaded image file to compressed pixel data
  125167. * @param imageData image data to transcode
  125168. * @param config configuration options for the transcoding
  125169. * @returns a promise resulting in the transcoded image
  125170. */
  125171. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  125172. /**
  125173. * Loads a texture from the transcode result
  125174. * @param texture texture load to
  125175. * @param transcodeResult the result of transcoding the basis file to load from
  125176. */
  125177. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  125178. }
  125179. }
  125180. declare module BABYLON {
  125181. /**
  125182. * Loader for .basis file format
  125183. */
  125184. export class _BasisTextureLoader implements IInternalTextureLoader {
  125185. /**
  125186. * Defines whether the loader supports cascade loading the different faces.
  125187. */
  125188. readonly supportCascades: boolean;
  125189. /**
  125190. * This returns if the loader support the current file information.
  125191. * @param extension defines the file extension of the file being loaded
  125192. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125193. * @param fallback defines the fallback internal texture if any
  125194. * @param isBase64 defines whether the texture is encoded as a base64
  125195. * @param isBuffer defines whether the texture data are stored as a buffer
  125196. * @returns true if the loader can load the specified file
  125197. */
  125198. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125199. /**
  125200. * Transform the url before loading if required.
  125201. * @param rootUrl the url of the texture
  125202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125203. * @returns the transformed texture
  125204. */
  125205. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125206. /**
  125207. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125208. * @param rootUrl the url of the texture
  125209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125210. * @returns the fallback texture
  125211. */
  125212. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125213. /**
  125214. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  125215. * @param data contains the texture data
  125216. * @param texture defines the BabylonJS internal texture
  125217. * @param createPolynomials will be true if polynomials have been requested
  125218. * @param onLoad defines the callback to trigger once the texture is ready
  125219. * @param onError defines the callback to trigger in case of error
  125220. */
  125221. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125222. /**
  125223. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125224. * @param data contains the texture data
  125225. * @param texture defines the BabylonJS internal texture
  125226. * @param callback defines the method to call once ready to upload
  125227. */
  125228. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125229. }
  125230. }
  125231. declare module BABYLON {
  125232. /**
  125233. * 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.
  125234. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125235. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125236. */
  125237. export class CustomProceduralTexture extends ProceduralTexture {
  125238. private _animate;
  125239. private _time;
  125240. private _config;
  125241. private _texturePath;
  125242. /**
  125243. * Instantiates a new Custom Procedural Texture.
  125244. * 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.
  125245. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125246. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125247. * @param name Define the name of the texture
  125248. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  125249. * @param size Define the size of the texture to create
  125250. * @param scene Define the scene the texture belongs to
  125251. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  125252. * @param generateMipMaps Define if the texture should creates mip maps or not
  125253. */
  125254. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125255. private _loadJson;
  125256. /**
  125257. * Is the texture ready to be used ? (rendered at least once)
  125258. * @returns true if ready, otherwise, false.
  125259. */
  125260. isReady(): boolean;
  125261. /**
  125262. * Render the texture to its associated render target.
  125263. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  125264. */
  125265. render(useCameraPostProcess?: boolean): void;
  125266. /**
  125267. * Update the list of dependant textures samplers in the shader.
  125268. */
  125269. updateTextures(): void;
  125270. /**
  125271. * Update the uniform values of the procedural texture in the shader.
  125272. */
  125273. updateShaderUniforms(): void;
  125274. /**
  125275. * Define if the texture animates or not.
  125276. */
  125277. get animate(): boolean;
  125278. set animate(value: boolean);
  125279. }
  125280. }
  125281. declare module BABYLON {
  125282. /** @hidden */
  125283. export var noisePixelShader: {
  125284. name: string;
  125285. shader: string;
  125286. };
  125287. }
  125288. declare module BABYLON {
  125289. /**
  125290. * Class used to generate noise procedural textures
  125291. */
  125292. export class NoiseProceduralTexture extends ProceduralTexture {
  125293. private _time;
  125294. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  125295. brightness: number;
  125296. /** Defines the number of octaves to process */
  125297. octaves: number;
  125298. /** Defines the level of persistence (0.8 by default) */
  125299. persistence: number;
  125300. /** Gets or sets animation speed factor (default is 1) */
  125301. animationSpeedFactor: number;
  125302. /**
  125303. * Creates a new NoiseProceduralTexture
  125304. * @param name defines the name fo the texture
  125305. * @param size defines the size of the texture (default is 256)
  125306. * @param scene defines the hosting scene
  125307. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  125308. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  125309. */
  125310. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125311. private _updateShaderUniforms;
  125312. protected _getDefines(): string;
  125313. /** Generate the current state of the procedural texture */
  125314. render(useCameraPostProcess?: boolean): void;
  125315. /**
  125316. * Serializes this noise procedural texture
  125317. * @returns a serialized noise procedural texture object
  125318. */
  125319. serialize(): any;
  125320. /**
  125321. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  125322. * @param parsedTexture defines parsed texture data
  125323. * @param scene defines the current scene
  125324. * @param rootUrl defines the root URL containing noise procedural texture information
  125325. * @returns a parsed NoiseProceduralTexture
  125326. */
  125327. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  125328. }
  125329. }
  125330. declare module BABYLON {
  125331. /**
  125332. * Raw cube texture where the raw buffers are passed in
  125333. */
  125334. export class RawCubeTexture extends CubeTexture {
  125335. /**
  125336. * Creates a cube texture where the raw buffers are passed in.
  125337. * @param scene defines the scene the texture is attached to
  125338. * @param data defines the array of data to use to create each face
  125339. * @param size defines the size of the textures
  125340. * @param format defines the format of the data
  125341. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  125342. * @param generateMipMaps defines if the engine should generate the mip levels
  125343. * @param invertY defines if data must be stored with Y axis inverted
  125344. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  125345. * @param compression defines the compression used (null by default)
  125346. */
  125347. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  125348. /**
  125349. * Updates the raw cube texture.
  125350. * @param data defines the data to store
  125351. * @param format defines the data format
  125352. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125353. * @param invertY defines if data must be stored with Y axis inverted
  125354. * @param compression defines the compression used (null by default)
  125355. * @param level defines which level of the texture to update
  125356. */
  125357. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  125358. /**
  125359. * Updates a raw cube texture with RGBD encoded data.
  125360. * @param data defines the array of data [mipmap][face] to use to create each face
  125361. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  125362. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  125363. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  125364. * @returns a promsie that resolves when the operation is complete
  125365. */
  125366. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  125367. /**
  125368. * Clones the raw cube texture.
  125369. * @return a new cube texture
  125370. */
  125371. clone(): CubeTexture;
  125372. /** @hidden */
  125373. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  125374. }
  125375. }
  125376. declare module BABYLON {
  125377. /**
  125378. * Class used to store 3D textures containing user data
  125379. */
  125380. export class RawTexture3D extends Texture {
  125381. /** Gets or sets the texture format to use */
  125382. format: number;
  125383. private _engine;
  125384. /**
  125385. * Create a new RawTexture3D
  125386. * @param data defines the data of the texture
  125387. * @param width defines the width of the texture
  125388. * @param height defines the height of the texture
  125389. * @param depth defines the depth of the texture
  125390. * @param format defines the texture format to use
  125391. * @param scene defines the hosting scene
  125392. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125393. * @param invertY defines if texture must be stored with Y axis inverted
  125394. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125395. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125396. */
  125397. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125398. /** Gets or sets the texture format to use */
  125399. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125400. /**
  125401. * Update the texture with new data
  125402. * @param data defines the data to store in the texture
  125403. */
  125404. update(data: ArrayBufferView): void;
  125405. }
  125406. }
  125407. declare module BABYLON {
  125408. /**
  125409. * Class used to store 2D array textures containing user data
  125410. */
  125411. export class RawTexture2DArray extends Texture {
  125412. /** Gets or sets the texture format to use */
  125413. format: number;
  125414. private _engine;
  125415. /**
  125416. * Create a new RawTexture2DArray
  125417. * @param data defines the data of the texture
  125418. * @param width defines the width of the texture
  125419. * @param height defines the height of the texture
  125420. * @param depth defines the number of layers of the texture
  125421. * @param format defines the texture format to use
  125422. * @param scene defines the hosting scene
  125423. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125424. * @param invertY defines if texture must be stored with Y axis inverted
  125425. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125426. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125427. */
  125428. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125429. /** Gets or sets the texture format to use */
  125430. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125431. /**
  125432. * Update the texture with new data
  125433. * @param data defines the data to store in the texture
  125434. */
  125435. update(data: ArrayBufferView): void;
  125436. }
  125437. }
  125438. declare module BABYLON {
  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. */
  125444. export class RefractionTexture extends RenderTargetTexture {
  125445. /**
  125446. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  125447. * 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.
  125448. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125449. */
  125450. refractionPlane: Plane;
  125451. /**
  125452. * Define how deep under the surface we should see.
  125453. */
  125454. depth: number;
  125455. /**
  125456. * Creates a refraction texture used by refraction channel of the standard material.
  125457. * It is like a mirror but to see through a material.
  125458. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125459. * @param name Define the texture name
  125460. * @param size Define the size of the underlying texture
  125461. * @param scene Define the scene the refraction belongs to
  125462. * @param generateMipMaps Define if we need to generate mips level for the refraction
  125463. */
  125464. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  125465. /**
  125466. * Clone the refraction texture.
  125467. * @returns the cloned texture
  125468. */
  125469. clone(): RefractionTexture;
  125470. /**
  125471. * Serialize the texture to a JSON representation you could use in Parse later on
  125472. * @returns the serialized JSON representation
  125473. */
  125474. serialize(): any;
  125475. }
  125476. }
  125477. declare module BABYLON {
  125478. /**
  125479. * Defines the options related to the creation of an HtmlElementTexture
  125480. */
  125481. export interface IHtmlElementTextureOptions {
  125482. /**
  125483. * Defines wether mip maps should be created or not.
  125484. */
  125485. generateMipMaps?: boolean;
  125486. /**
  125487. * Defines the sampling mode of the texture.
  125488. */
  125489. samplingMode?: number;
  125490. /**
  125491. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  125492. */
  125493. engine: Nullable<ThinEngine>;
  125494. /**
  125495. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  125496. */
  125497. scene: Nullable<Scene>;
  125498. }
  125499. /**
  125500. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  125501. * To be as efficient as possible depending on your constraints nothing aside the first upload
  125502. * is automatically managed.
  125503. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  125504. * in your application.
  125505. *
  125506. * As the update is not automatic, you need to call them manually.
  125507. */
  125508. export class HtmlElementTexture extends BaseTexture {
  125509. /**
  125510. * The texture URL.
  125511. */
  125512. element: HTMLVideoElement | HTMLCanvasElement;
  125513. private static readonly DefaultOptions;
  125514. private _textureMatrix;
  125515. private _engine;
  125516. private _isVideo;
  125517. private _generateMipMaps;
  125518. private _samplingMode;
  125519. /**
  125520. * Instantiates a HtmlElementTexture from the following parameters.
  125521. *
  125522. * @param name Defines the name of the texture
  125523. * @param element Defines the video or canvas the texture is filled with
  125524. * @param options Defines the other none mandatory texture creation options
  125525. */
  125526. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  125527. private _createInternalTexture;
  125528. /**
  125529. * Returns the texture matrix used in most of the material.
  125530. */
  125531. getTextureMatrix(): Matrix;
  125532. /**
  125533. * Updates the content of the texture.
  125534. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  125535. */
  125536. update(invertY?: Nullable<boolean>): void;
  125537. }
  125538. }
  125539. declare module BABYLON {
  125540. /**
  125541. * Enum used to define the target of a block
  125542. */
  125543. export enum NodeMaterialBlockTargets {
  125544. /** Vertex shader */
  125545. Vertex = 1,
  125546. /** Fragment shader */
  125547. Fragment = 2,
  125548. /** Neutral */
  125549. Neutral = 4,
  125550. /** Vertex and Fragment */
  125551. VertexAndFragment = 3
  125552. }
  125553. }
  125554. declare module BABYLON {
  125555. /**
  125556. * Defines the kind of connection point for node based material
  125557. */
  125558. export enum NodeMaterialBlockConnectionPointTypes {
  125559. /** Float */
  125560. Float = 1,
  125561. /** Int */
  125562. Int = 2,
  125563. /** Vector2 */
  125564. Vector2 = 4,
  125565. /** Vector3 */
  125566. Vector3 = 8,
  125567. /** Vector4 */
  125568. Vector4 = 16,
  125569. /** Color3 */
  125570. Color3 = 32,
  125571. /** Color4 */
  125572. Color4 = 64,
  125573. /** Matrix */
  125574. Matrix = 128,
  125575. /** Detect type based on connection */
  125576. AutoDetect = 1024,
  125577. /** Output type that will be defined by input type */
  125578. BasedOnInput = 2048
  125579. }
  125580. }
  125581. declare module BABYLON {
  125582. /**
  125583. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  125584. */
  125585. export enum NodeMaterialBlockConnectionPointMode {
  125586. /** Value is an uniform */
  125587. Uniform = 0,
  125588. /** Value is a mesh attribute */
  125589. Attribute = 1,
  125590. /** Value is a varying between vertex and fragment shaders */
  125591. Varying = 2,
  125592. /** Mode is undefined */
  125593. Undefined = 3
  125594. }
  125595. }
  125596. declare module BABYLON {
  125597. /**
  125598. * Enum used to define system values e.g. values automatically provided by the system
  125599. */
  125600. export enum NodeMaterialSystemValues {
  125601. /** World */
  125602. World = 1,
  125603. /** View */
  125604. View = 2,
  125605. /** Projection */
  125606. Projection = 3,
  125607. /** ViewProjection */
  125608. ViewProjection = 4,
  125609. /** WorldView */
  125610. WorldView = 5,
  125611. /** WorldViewProjection */
  125612. WorldViewProjection = 6,
  125613. /** CameraPosition */
  125614. CameraPosition = 7,
  125615. /** Fog Color */
  125616. FogColor = 8,
  125617. /** Delta time */
  125618. DeltaTime = 9
  125619. }
  125620. }
  125621. declare module BABYLON {
  125622. /**
  125623. * Root class for all node material optimizers
  125624. */
  125625. export class NodeMaterialOptimizer {
  125626. /**
  125627. * Function used to optimize a NodeMaterial graph
  125628. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  125629. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  125630. */
  125631. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  125632. }
  125633. }
  125634. declare module BABYLON {
  125635. /**
  125636. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  125637. */
  125638. export class TransformBlock extends NodeMaterialBlock {
  125639. /**
  125640. * Defines the value to use to complement W value to transform it to a Vector4
  125641. */
  125642. complementW: number;
  125643. /**
  125644. * Defines the value to use to complement z value to transform it to a Vector4
  125645. */
  125646. complementZ: number;
  125647. /**
  125648. * Creates a new TransformBlock
  125649. * @param name defines the block name
  125650. */
  125651. constructor(name: string);
  125652. /**
  125653. * Gets the current class name
  125654. * @returns the class name
  125655. */
  125656. getClassName(): string;
  125657. /**
  125658. * Gets the vector input
  125659. */
  125660. get vector(): NodeMaterialConnectionPoint;
  125661. /**
  125662. * Gets the output component
  125663. */
  125664. get output(): NodeMaterialConnectionPoint;
  125665. /**
  125666. * Gets the matrix transform input
  125667. */
  125668. get transform(): NodeMaterialConnectionPoint;
  125669. protected _buildBlock(state: NodeMaterialBuildState): this;
  125670. serialize(): any;
  125671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125672. protected _dumpPropertiesCode(): string;
  125673. }
  125674. }
  125675. declare module BABYLON {
  125676. /**
  125677. * Block used to output the vertex position
  125678. */
  125679. export class VertexOutputBlock extends NodeMaterialBlock {
  125680. /**
  125681. * Creates a new VertexOutputBlock
  125682. * @param name defines the block name
  125683. */
  125684. constructor(name: string);
  125685. /**
  125686. * Gets the current class name
  125687. * @returns the class name
  125688. */
  125689. getClassName(): string;
  125690. /**
  125691. * Gets the vector input component
  125692. */
  125693. get vector(): NodeMaterialConnectionPoint;
  125694. protected _buildBlock(state: NodeMaterialBuildState): this;
  125695. }
  125696. }
  125697. declare module BABYLON {
  125698. /**
  125699. * Block used to output the final color
  125700. */
  125701. export class FragmentOutputBlock extends NodeMaterialBlock {
  125702. /**
  125703. * Create a new FragmentOutputBlock
  125704. * @param name defines the block name
  125705. */
  125706. constructor(name: string);
  125707. /**
  125708. * Gets the current class name
  125709. * @returns the class name
  125710. */
  125711. getClassName(): string;
  125712. /**
  125713. * Gets the rgba input component
  125714. */
  125715. get rgba(): NodeMaterialConnectionPoint;
  125716. /**
  125717. * Gets the rgb input component
  125718. */
  125719. get rgb(): NodeMaterialConnectionPoint;
  125720. /**
  125721. * Gets the a input component
  125722. */
  125723. get a(): NodeMaterialConnectionPoint;
  125724. protected _buildBlock(state: NodeMaterialBuildState): this;
  125725. }
  125726. }
  125727. declare module BABYLON {
  125728. /**
  125729. * Block used to read a reflection texture from a sampler
  125730. */
  125731. export class ReflectionTextureBlock extends NodeMaterialBlock {
  125732. private _define3DName;
  125733. private _defineCubicName;
  125734. private _defineExplicitName;
  125735. private _defineProjectionName;
  125736. private _defineLocalCubicName;
  125737. private _defineSphericalName;
  125738. private _definePlanarName;
  125739. private _defineEquirectangularName;
  125740. private _defineMirroredEquirectangularFixedName;
  125741. private _defineEquirectangularFixedName;
  125742. private _defineSkyboxName;
  125743. private _cubeSamplerName;
  125744. private _2DSamplerName;
  125745. private _positionUVWName;
  125746. private _directionWName;
  125747. private _reflectionCoordsName;
  125748. private _reflection2DCoordsName;
  125749. private _reflectionColorName;
  125750. private _reflectionMatrixName;
  125751. /**
  125752. * Gets or sets the texture associated with the node
  125753. */
  125754. texture: Nullable<BaseTexture>;
  125755. /**
  125756. * Create a new TextureBlock
  125757. * @param name defines the block name
  125758. */
  125759. constructor(name: string);
  125760. /**
  125761. * Gets the current class name
  125762. * @returns the class name
  125763. */
  125764. getClassName(): string;
  125765. /**
  125766. * Gets the world position input component
  125767. */
  125768. get position(): NodeMaterialConnectionPoint;
  125769. /**
  125770. * Gets the world position input component
  125771. */
  125772. get worldPosition(): NodeMaterialConnectionPoint;
  125773. /**
  125774. * Gets the world normal input component
  125775. */
  125776. get worldNormal(): NodeMaterialConnectionPoint;
  125777. /**
  125778. * Gets the world input component
  125779. */
  125780. get world(): NodeMaterialConnectionPoint;
  125781. /**
  125782. * Gets the camera (or eye) position component
  125783. */
  125784. get cameraPosition(): NodeMaterialConnectionPoint;
  125785. /**
  125786. * Gets the view input component
  125787. */
  125788. get view(): NodeMaterialConnectionPoint;
  125789. /**
  125790. * Gets the rgb output component
  125791. */
  125792. get rgb(): NodeMaterialConnectionPoint;
  125793. /**
  125794. * Gets the r output component
  125795. */
  125796. get r(): NodeMaterialConnectionPoint;
  125797. /**
  125798. * Gets the g output component
  125799. */
  125800. get g(): NodeMaterialConnectionPoint;
  125801. /**
  125802. * Gets the b output component
  125803. */
  125804. get b(): NodeMaterialConnectionPoint;
  125805. autoConfigure(material: NodeMaterial): void;
  125806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125807. isReady(): boolean;
  125808. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125809. private _injectVertexCode;
  125810. private _writeOutput;
  125811. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125812. protected _dumpPropertiesCode(): string;
  125813. serialize(): any;
  125814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125815. }
  125816. }
  125817. declare module BABYLON {
  125818. /**
  125819. * Interface used to configure the node material editor
  125820. */
  125821. export interface INodeMaterialEditorOptions {
  125822. /** Define the URl to load node editor script */
  125823. editorURL?: string;
  125824. }
  125825. /** @hidden */
  125826. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  125827. /** BONES */
  125828. NUM_BONE_INFLUENCERS: number;
  125829. BonesPerMesh: number;
  125830. BONETEXTURE: boolean;
  125831. /** MORPH TARGETS */
  125832. MORPHTARGETS: boolean;
  125833. MORPHTARGETS_NORMAL: boolean;
  125834. MORPHTARGETS_TANGENT: boolean;
  125835. MORPHTARGETS_UV: boolean;
  125836. NUM_MORPH_INFLUENCERS: number;
  125837. /** IMAGE PROCESSING */
  125838. IMAGEPROCESSING: boolean;
  125839. VIGNETTE: boolean;
  125840. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125841. VIGNETTEBLENDMODEOPAQUE: boolean;
  125842. TONEMAPPING: boolean;
  125843. TONEMAPPING_ACES: boolean;
  125844. CONTRAST: boolean;
  125845. EXPOSURE: boolean;
  125846. COLORCURVES: boolean;
  125847. COLORGRADING: boolean;
  125848. COLORGRADING3D: boolean;
  125849. SAMPLER3DGREENDEPTH: boolean;
  125850. SAMPLER3DBGRMAP: boolean;
  125851. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125852. /** MISC. */
  125853. BUMPDIRECTUV: number;
  125854. constructor();
  125855. setValue(name: string, value: boolean): void;
  125856. }
  125857. /**
  125858. * Class used to configure NodeMaterial
  125859. */
  125860. export interface INodeMaterialOptions {
  125861. /**
  125862. * Defines if blocks should emit comments
  125863. */
  125864. emitComments: boolean;
  125865. }
  125866. /**
  125867. * Class used to create a node based material built by assembling shader blocks
  125868. */
  125869. export class NodeMaterial extends PushMaterial {
  125870. private static _BuildIdGenerator;
  125871. private _options;
  125872. private _vertexCompilationState;
  125873. private _fragmentCompilationState;
  125874. private _sharedData;
  125875. private _buildId;
  125876. private _buildWasSuccessful;
  125877. private _cachedWorldViewMatrix;
  125878. private _cachedWorldViewProjectionMatrix;
  125879. private _optimizers;
  125880. private _animationFrame;
  125881. /** Define the URl to load node editor script */
  125882. static EditorURL: string;
  125883. private BJSNODEMATERIALEDITOR;
  125884. /** Get the inspector from bundle or global */
  125885. private _getGlobalNodeMaterialEditor;
  125886. /**
  125887. * Gets or sets data used by visual editor
  125888. * @see https://nme.babylonjs.com
  125889. */
  125890. editorData: any;
  125891. /**
  125892. * 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)
  125893. */
  125894. ignoreAlpha: boolean;
  125895. /**
  125896. * Defines the maximum number of lights that can be used in the material
  125897. */
  125898. maxSimultaneousLights: number;
  125899. /**
  125900. * Observable raised when the material is built
  125901. */
  125902. onBuildObservable: Observable<NodeMaterial>;
  125903. /**
  125904. * Gets or sets the root nodes of the material vertex shader
  125905. */
  125906. _vertexOutputNodes: NodeMaterialBlock[];
  125907. /**
  125908. * Gets or sets the root nodes of the material fragment (pixel) shader
  125909. */
  125910. _fragmentOutputNodes: NodeMaterialBlock[];
  125911. /** Gets or sets options to control the node material overall behavior */
  125912. get options(): INodeMaterialOptions;
  125913. set options(options: INodeMaterialOptions);
  125914. /**
  125915. * Default configuration related to image processing available in the standard Material.
  125916. */
  125917. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125918. /**
  125919. * Gets the image processing configuration used either in this material.
  125920. */
  125921. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125922. /**
  125923. * Sets the Default image processing configuration used either in the this material.
  125924. *
  125925. * If sets to null, the scene one is in use.
  125926. */
  125927. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125928. /**
  125929. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  125930. */
  125931. attachedBlocks: NodeMaterialBlock[];
  125932. /**
  125933. * Create a new node based material
  125934. * @param name defines the material name
  125935. * @param scene defines the hosting scene
  125936. * @param options defines creation option
  125937. */
  125938. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  125939. /**
  125940. * Gets the current class name of the material e.g. "NodeMaterial"
  125941. * @returns the class name
  125942. */
  125943. getClassName(): string;
  125944. /**
  125945. * Keep track of the image processing observer to allow dispose and replace.
  125946. */
  125947. private _imageProcessingObserver;
  125948. /**
  125949. * Attaches a new image processing configuration to the Standard Material.
  125950. * @param configuration
  125951. */
  125952. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125953. /**
  125954. * Get a block by its name
  125955. * @param name defines the name of the block to retrieve
  125956. * @returns the required block or null if not found
  125957. */
  125958. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  125959. /**
  125960. * Get a block by its name
  125961. * @param predicate defines the predicate used to find the good candidate
  125962. * @returns the required block or null if not found
  125963. */
  125964. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  125965. /**
  125966. * Get an input block by its name
  125967. * @param predicate defines the predicate used to find the good candidate
  125968. * @returns the required input block or null if not found
  125969. */
  125970. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  125971. /**
  125972. * Gets the list of input blocks attached to this material
  125973. * @returns an array of InputBlocks
  125974. */
  125975. getInputBlocks(): InputBlock[];
  125976. /**
  125977. * Adds a new optimizer to the list of optimizers
  125978. * @param optimizer defines the optimizers to add
  125979. * @returns the current material
  125980. */
  125981. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  125982. /**
  125983. * Remove an optimizer from the list of optimizers
  125984. * @param optimizer defines the optimizers to remove
  125985. * @returns the current material
  125986. */
  125987. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  125988. /**
  125989. * Add a new block to the list of output nodes
  125990. * @param node defines the node to add
  125991. * @returns the current material
  125992. */
  125993. addOutputNode(node: NodeMaterialBlock): this;
  125994. /**
  125995. * Remove a block from the list of root nodes
  125996. * @param node defines the node to remove
  125997. * @returns the current material
  125998. */
  125999. removeOutputNode(node: NodeMaterialBlock): this;
  126000. private _addVertexOutputNode;
  126001. private _removeVertexOutputNode;
  126002. private _addFragmentOutputNode;
  126003. private _removeFragmentOutputNode;
  126004. /**
  126005. * Specifies if the material will require alpha blending
  126006. * @returns a boolean specifying if alpha blending is needed
  126007. */
  126008. needAlphaBlending(): boolean;
  126009. /**
  126010. * Specifies if this material should be rendered in alpha test mode
  126011. * @returns a boolean specifying if an alpha test is needed.
  126012. */
  126013. needAlphaTesting(): boolean;
  126014. private _initializeBlock;
  126015. private _resetDualBlocks;
  126016. /**
  126017. * Remove a block from the current node material
  126018. * @param block defines the block to remove
  126019. */
  126020. removeBlock(block: NodeMaterialBlock): void;
  126021. /**
  126022. * Build the material and generates the inner effect
  126023. * @param verbose defines if the build should log activity
  126024. */
  126025. build(verbose?: boolean): void;
  126026. /**
  126027. * Runs an otpimization phase to try to improve the shader code
  126028. */
  126029. optimize(): void;
  126030. private _prepareDefinesForAttributes;
  126031. /**
  126032. * Get if the submesh is ready to be used and all its information available.
  126033. * Child classes can use it to update shaders
  126034. * @param mesh defines the mesh to check
  126035. * @param subMesh defines which submesh to check
  126036. * @param useInstances specifies that instances should be used
  126037. * @returns a boolean indicating that the submesh is ready or not
  126038. */
  126039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126040. /**
  126041. * Get a string representing the shaders built by the current node graph
  126042. */
  126043. get compiledShaders(): string;
  126044. /**
  126045. * Binds the world matrix to the material
  126046. * @param world defines the world transformation matrix
  126047. */
  126048. bindOnlyWorldMatrix(world: Matrix): void;
  126049. /**
  126050. * Binds the submesh to this material by preparing the effect and shader to draw
  126051. * @param world defines the world transformation matrix
  126052. * @param mesh defines the mesh containing the submesh
  126053. * @param subMesh defines the submesh to bind the material to
  126054. */
  126055. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126056. /**
  126057. * Gets the active textures from the material
  126058. * @returns an array of textures
  126059. */
  126060. getActiveTextures(): BaseTexture[];
  126061. /**
  126062. * Gets the list of texture blocks
  126063. * @returns an array of texture blocks
  126064. */
  126065. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  126066. /**
  126067. * Specifies if the material uses a texture
  126068. * @param texture defines the texture to check against the material
  126069. * @returns a boolean specifying if the material uses the texture
  126070. */
  126071. hasTexture(texture: BaseTexture): boolean;
  126072. /**
  126073. * Disposes the material
  126074. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  126075. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  126076. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  126077. */
  126078. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  126079. /** Creates the node editor window. */
  126080. private _createNodeEditor;
  126081. /**
  126082. * Launch the node material editor
  126083. * @param config Define the configuration of the editor
  126084. * @return a promise fulfilled when the node editor is visible
  126085. */
  126086. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  126087. /**
  126088. * Clear the current material
  126089. */
  126090. clear(): void;
  126091. /**
  126092. * Clear the current material and set it to a default state
  126093. */
  126094. setToDefault(): void;
  126095. /**
  126096. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  126097. * @param url defines the url to load from
  126098. * @returns a promise that will fullfil when the material is fully loaded
  126099. */
  126100. loadAsync(url: string): Promise<void>;
  126101. private _gatherBlocks;
  126102. /**
  126103. * Generate a string containing the code declaration required to create an equivalent of this material
  126104. * @returns a string
  126105. */
  126106. generateCode(): string;
  126107. /**
  126108. * Serializes this material in a JSON representation
  126109. * @returns the serialized material object
  126110. */
  126111. serialize(): any;
  126112. private _restoreConnections;
  126113. /**
  126114. * Clear the current graph and load a new one from a serialization object
  126115. * @param source defines the JSON representation of the material
  126116. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126117. */
  126118. loadFromSerialization(source: any, rootUrl?: string): void;
  126119. /**
  126120. * Creates a node material from parsed material data
  126121. * @param source defines the JSON representation of the material
  126122. * @param scene defines the hosting scene
  126123. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126124. * @returns a new node material
  126125. */
  126126. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  126127. /**
  126128. * Creates a new node material set to default basic configuration
  126129. * @param name defines the name of the material
  126130. * @param scene defines the hosting scene
  126131. * @returns a new NodeMaterial
  126132. */
  126133. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  126134. }
  126135. }
  126136. declare module BABYLON {
  126137. /**
  126138. * Block used to read a texture from a sampler
  126139. */
  126140. export class TextureBlock extends NodeMaterialBlock {
  126141. private _defineName;
  126142. private _linearDefineName;
  126143. private _tempTextureRead;
  126144. private _samplerName;
  126145. private _transformedUVName;
  126146. private _textureTransformName;
  126147. private _textureInfoName;
  126148. private _mainUVName;
  126149. private _mainUVDefineName;
  126150. /**
  126151. * Gets or sets the texture associated with the node
  126152. */
  126153. texture: Nullable<Texture>;
  126154. /**
  126155. * Create a new TextureBlock
  126156. * @param name defines the block name
  126157. */
  126158. constructor(name: string);
  126159. /**
  126160. * Gets the current class name
  126161. * @returns the class name
  126162. */
  126163. getClassName(): string;
  126164. /**
  126165. * Gets the uv input component
  126166. */
  126167. get uv(): NodeMaterialConnectionPoint;
  126168. /**
  126169. * Gets the rgba output component
  126170. */
  126171. get rgba(): NodeMaterialConnectionPoint;
  126172. /**
  126173. * Gets the rgb output component
  126174. */
  126175. get rgb(): NodeMaterialConnectionPoint;
  126176. /**
  126177. * Gets the r output component
  126178. */
  126179. get r(): NodeMaterialConnectionPoint;
  126180. /**
  126181. * Gets the g output component
  126182. */
  126183. get g(): NodeMaterialConnectionPoint;
  126184. /**
  126185. * Gets the b output component
  126186. */
  126187. get b(): NodeMaterialConnectionPoint;
  126188. /**
  126189. * Gets the a output component
  126190. */
  126191. get a(): NodeMaterialConnectionPoint;
  126192. get target(): NodeMaterialBlockTargets;
  126193. autoConfigure(material: NodeMaterial): void;
  126194. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126195. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126196. private _getTextureBase;
  126197. isReady(): boolean;
  126198. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126199. private get _isMixed();
  126200. private _injectVertexCode;
  126201. private _writeTextureRead;
  126202. private _writeOutput;
  126203. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126204. protected _dumpPropertiesCode(): string;
  126205. serialize(): any;
  126206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126207. }
  126208. }
  126209. declare module BABYLON {
  126210. /**
  126211. * Class used to store shared data between 2 NodeMaterialBuildState
  126212. */
  126213. export class NodeMaterialBuildStateSharedData {
  126214. /**
  126215. * Gets the list of emitted varyings
  126216. */
  126217. temps: string[];
  126218. /**
  126219. * Gets the list of emitted varyings
  126220. */
  126221. varyings: string[];
  126222. /**
  126223. * Gets the varying declaration string
  126224. */
  126225. varyingDeclaration: string;
  126226. /**
  126227. * Input blocks
  126228. */
  126229. inputBlocks: InputBlock[];
  126230. /**
  126231. * Input blocks
  126232. */
  126233. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  126234. /**
  126235. * Bindable blocks (Blocks that need to set data to the effect)
  126236. */
  126237. bindableBlocks: NodeMaterialBlock[];
  126238. /**
  126239. * List of blocks that can provide a compilation fallback
  126240. */
  126241. blocksWithFallbacks: NodeMaterialBlock[];
  126242. /**
  126243. * List of blocks that can provide a define update
  126244. */
  126245. blocksWithDefines: NodeMaterialBlock[];
  126246. /**
  126247. * List of blocks that can provide a repeatable content
  126248. */
  126249. repeatableContentBlocks: NodeMaterialBlock[];
  126250. /**
  126251. * List of blocks that can provide a dynamic list of uniforms
  126252. */
  126253. dynamicUniformBlocks: NodeMaterialBlock[];
  126254. /**
  126255. * List of blocks that can block the isReady function for the material
  126256. */
  126257. blockingBlocks: NodeMaterialBlock[];
  126258. /**
  126259. * Gets the list of animated inputs
  126260. */
  126261. animatedInputs: InputBlock[];
  126262. /**
  126263. * Build Id used to avoid multiple recompilations
  126264. */
  126265. buildId: number;
  126266. /** List of emitted variables */
  126267. variableNames: {
  126268. [key: string]: number;
  126269. };
  126270. /** List of emitted defines */
  126271. defineNames: {
  126272. [key: string]: number;
  126273. };
  126274. /** Should emit comments? */
  126275. emitComments: boolean;
  126276. /** Emit build activity */
  126277. verbose: boolean;
  126278. /** Gets or sets the hosting scene */
  126279. scene: Scene;
  126280. /**
  126281. * Gets the compilation hints emitted at compilation time
  126282. */
  126283. hints: {
  126284. needWorldViewMatrix: boolean;
  126285. needWorldViewProjectionMatrix: boolean;
  126286. needAlphaBlending: boolean;
  126287. needAlphaTesting: boolean;
  126288. };
  126289. /**
  126290. * List of compilation checks
  126291. */
  126292. checks: {
  126293. emitVertex: boolean;
  126294. emitFragment: boolean;
  126295. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  126296. };
  126297. /** Creates a new shared data */
  126298. constructor();
  126299. /**
  126300. * Emits console errors and exceptions if there is a failing check
  126301. */
  126302. emitErrors(): void;
  126303. }
  126304. }
  126305. declare module BABYLON {
  126306. /**
  126307. * Class used to store node based material build state
  126308. */
  126309. export class NodeMaterialBuildState {
  126310. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  126311. supportUniformBuffers: boolean;
  126312. /**
  126313. * Gets the list of emitted attributes
  126314. */
  126315. attributes: string[];
  126316. /**
  126317. * Gets the list of emitted uniforms
  126318. */
  126319. uniforms: string[];
  126320. /**
  126321. * Gets the list of emitted constants
  126322. */
  126323. constants: string[];
  126324. /**
  126325. * Gets the list of emitted samplers
  126326. */
  126327. samplers: string[];
  126328. /**
  126329. * Gets the list of emitted functions
  126330. */
  126331. functions: {
  126332. [key: string]: string;
  126333. };
  126334. /**
  126335. * Gets the list of emitted extensions
  126336. */
  126337. extensions: {
  126338. [key: string]: string;
  126339. };
  126340. /**
  126341. * Gets the target of the compilation state
  126342. */
  126343. target: NodeMaterialBlockTargets;
  126344. /**
  126345. * Gets the list of emitted counters
  126346. */
  126347. counters: {
  126348. [key: string]: number;
  126349. };
  126350. /**
  126351. * Shared data between multiple NodeMaterialBuildState instances
  126352. */
  126353. sharedData: NodeMaterialBuildStateSharedData;
  126354. /** @hidden */
  126355. _vertexState: NodeMaterialBuildState;
  126356. /** @hidden */
  126357. _attributeDeclaration: string;
  126358. /** @hidden */
  126359. _uniformDeclaration: string;
  126360. /** @hidden */
  126361. _constantDeclaration: string;
  126362. /** @hidden */
  126363. _samplerDeclaration: string;
  126364. /** @hidden */
  126365. _varyingTransfer: string;
  126366. private _repeatableContentAnchorIndex;
  126367. /** @hidden */
  126368. _builtCompilationString: string;
  126369. /**
  126370. * Gets the emitted compilation strings
  126371. */
  126372. compilationString: string;
  126373. /**
  126374. * Finalize the compilation strings
  126375. * @param state defines the current compilation state
  126376. */
  126377. finalize(state: NodeMaterialBuildState): void;
  126378. /** @hidden */
  126379. get _repeatableContentAnchor(): string;
  126380. /** @hidden */
  126381. _getFreeVariableName(prefix: string): string;
  126382. /** @hidden */
  126383. _getFreeDefineName(prefix: string): string;
  126384. /** @hidden */
  126385. _excludeVariableName(name: string): void;
  126386. /** @hidden */
  126387. _emit2DSampler(name: string): void;
  126388. /** @hidden */
  126389. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  126390. /** @hidden */
  126391. _emitExtension(name: string, extension: string): void;
  126392. /** @hidden */
  126393. _emitFunction(name: string, code: string, comments: string): void;
  126394. /** @hidden */
  126395. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  126396. replaceStrings?: {
  126397. search: RegExp;
  126398. replace: string;
  126399. }[];
  126400. repeatKey?: string;
  126401. }): string;
  126402. /** @hidden */
  126403. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  126404. repeatKey?: string;
  126405. removeAttributes?: boolean;
  126406. removeUniforms?: boolean;
  126407. removeVaryings?: boolean;
  126408. removeIfDef?: boolean;
  126409. replaceStrings?: {
  126410. search: RegExp;
  126411. replace: string;
  126412. }[];
  126413. }, storeKey?: string): void;
  126414. /** @hidden */
  126415. _registerTempVariable(name: string): boolean;
  126416. /** @hidden */
  126417. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  126418. /** @hidden */
  126419. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  126420. /** @hidden */
  126421. _emitFloat(value: number): string;
  126422. }
  126423. }
  126424. declare module BABYLON {
  126425. /**
  126426. * Defines a block that can be used inside a node based material
  126427. */
  126428. export class NodeMaterialBlock {
  126429. private _buildId;
  126430. private _buildTarget;
  126431. private _target;
  126432. private _isFinalMerger;
  126433. private _isInput;
  126434. protected _isUnique: boolean;
  126435. /** @hidden */
  126436. _codeVariableName: string;
  126437. /** @hidden */
  126438. _inputs: NodeMaterialConnectionPoint[];
  126439. /** @hidden */
  126440. _outputs: NodeMaterialConnectionPoint[];
  126441. /** @hidden */
  126442. _preparationId: number;
  126443. /**
  126444. * Gets or sets the name of the block
  126445. */
  126446. name: string;
  126447. /**
  126448. * Gets or sets the unique id of the node
  126449. */
  126450. uniqueId: number;
  126451. /**
  126452. * Gets or sets the comments associated with this block
  126453. */
  126454. comments: string;
  126455. /**
  126456. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  126457. */
  126458. get isUnique(): boolean;
  126459. /**
  126460. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  126461. */
  126462. get isFinalMerger(): boolean;
  126463. /**
  126464. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  126465. */
  126466. get isInput(): boolean;
  126467. /**
  126468. * Gets or sets the build Id
  126469. */
  126470. get buildId(): number;
  126471. set buildId(value: number);
  126472. /**
  126473. * Gets or sets the target of the block
  126474. */
  126475. get target(): NodeMaterialBlockTargets;
  126476. set target(value: NodeMaterialBlockTargets);
  126477. /**
  126478. * Gets the list of input points
  126479. */
  126480. get inputs(): NodeMaterialConnectionPoint[];
  126481. /** Gets the list of output points */
  126482. get outputs(): NodeMaterialConnectionPoint[];
  126483. /**
  126484. * Find an input by its name
  126485. * @param name defines the name of the input to look for
  126486. * @returns the input or null if not found
  126487. */
  126488. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126489. /**
  126490. * Find an output by its name
  126491. * @param name defines the name of the outputto look for
  126492. * @returns the output or null if not found
  126493. */
  126494. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126495. /**
  126496. * Creates a new NodeMaterialBlock
  126497. * @param name defines the block name
  126498. * @param target defines the target of that block (Vertex by default)
  126499. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  126500. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  126501. */
  126502. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  126503. /**
  126504. * Initialize the block and prepare the context for build
  126505. * @param state defines the state that will be used for the build
  126506. */
  126507. initialize(state: NodeMaterialBuildState): void;
  126508. /**
  126509. * Bind data to effect. Will only be called for blocks with isBindable === true
  126510. * @param effect defines the effect to bind data to
  126511. * @param nodeMaterial defines the hosting NodeMaterial
  126512. * @param mesh defines the mesh that will be rendered
  126513. */
  126514. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126515. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  126516. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  126517. protected _writeFloat(value: number): string;
  126518. /**
  126519. * Gets the current class name e.g. "NodeMaterialBlock"
  126520. * @returns the class name
  126521. */
  126522. getClassName(): string;
  126523. /**
  126524. * Register a new input. Must be called inside a block constructor
  126525. * @param name defines the connection point name
  126526. * @param type defines the connection point type
  126527. * @param isOptional defines a boolean indicating that this input can be omitted
  126528. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126529. * @returns the current block
  126530. */
  126531. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  126532. /**
  126533. * Register a new output. Must be called inside a block constructor
  126534. * @param name defines the connection point name
  126535. * @param type defines the connection point type
  126536. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126537. * @returns the current block
  126538. */
  126539. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  126540. /**
  126541. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  126542. * @param forOutput defines an optional connection point to check compatibility with
  126543. * @returns the first available input or null
  126544. */
  126545. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  126546. /**
  126547. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  126548. * @param forBlock defines an optional block to check compatibility with
  126549. * @returns the first available input or null
  126550. */
  126551. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  126552. /**
  126553. * Gets the sibling of the given output
  126554. * @param current defines the current output
  126555. * @returns the next output in the list or null
  126556. */
  126557. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  126558. /**
  126559. * Connect current block with another block
  126560. * @param other defines the block to connect with
  126561. * @param options define the various options to help pick the right connections
  126562. * @returns the current block
  126563. */
  126564. connectTo(other: NodeMaterialBlock, options?: {
  126565. input?: string;
  126566. output?: string;
  126567. outputSwizzle?: string;
  126568. }): this | undefined;
  126569. protected _buildBlock(state: NodeMaterialBuildState): void;
  126570. /**
  126571. * Add uniforms, samplers and uniform buffers at compilation time
  126572. * @param state defines the state to update
  126573. * @param nodeMaterial defines the node material requesting the update
  126574. * @param defines defines the material defines to update
  126575. * @param uniformBuffers defines the list of uniform buffer names
  126576. */
  126577. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  126578. /**
  126579. * Add potential fallbacks if shader compilation fails
  126580. * @param mesh defines the mesh to be rendered
  126581. * @param fallbacks defines the current prioritized list of fallbacks
  126582. */
  126583. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126584. /**
  126585. * Initialize defines for shader compilation
  126586. * @param mesh defines the mesh to be rendered
  126587. * @param nodeMaterial defines the node material requesting the update
  126588. * @param defines defines the material defines to update
  126589. * @param useInstances specifies that instances should be used
  126590. */
  126591. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126592. /**
  126593. * Update defines for shader compilation
  126594. * @param mesh defines the mesh to be rendered
  126595. * @param nodeMaterial defines the node material requesting the update
  126596. * @param defines defines the material defines to update
  126597. * @param useInstances specifies that instances should be used
  126598. */
  126599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126600. /**
  126601. * Lets the block try to connect some inputs automatically
  126602. * @param material defines the hosting NodeMaterial
  126603. */
  126604. autoConfigure(material: NodeMaterial): void;
  126605. /**
  126606. * Function called when a block is declared as repeatable content generator
  126607. * @param vertexShaderState defines the current compilation state for the vertex shader
  126608. * @param fragmentShaderState defines the current compilation state for the fragment shader
  126609. * @param mesh defines the mesh to be rendered
  126610. * @param defines defines the material defines to update
  126611. */
  126612. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  126613. /**
  126614. * Checks if the block is ready
  126615. * @param mesh defines the mesh to be rendered
  126616. * @param nodeMaterial defines the node material requesting the update
  126617. * @param defines defines the material defines to update
  126618. * @param useInstances specifies that instances should be used
  126619. * @returns true if the block is ready
  126620. */
  126621. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  126622. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  126623. private _processBuild;
  126624. /**
  126625. * Compile the current node and generate the shader code
  126626. * @param state defines the current compilation state (uniforms, samplers, current string)
  126627. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  126628. * @returns true if already built
  126629. */
  126630. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  126631. protected _inputRename(name: string): string;
  126632. protected _outputRename(name: string): string;
  126633. protected _dumpPropertiesCode(): string;
  126634. /** @hidden */
  126635. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  126636. /** @hidden */
  126637. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  126638. /**
  126639. * Clone the current block to a new identical block
  126640. * @param scene defines the hosting scene
  126641. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126642. * @returns a copy of the current block
  126643. */
  126644. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  126645. /**
  126646. * Serializes this block in a JSON representation
  126647. * @returns the serialized block object
  126648. */
  126649. serialize(): any;
  126650. /** @hidden */
  126651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126652. /**
  126653. * Release resources
  126654. */
  126655. dispose(): void;
  126656. }
  126657. }
  126658. declare module BABYLON {
  126659. /**
  126660. * Enum defining the type of animations supported by InputBlock
  126661. */
  126662. export enum AnimatedInputBlockTypes {
  126663. /** No animation */
  126664. None = 0,
  126665. /** Time based animation. Will only work for floats */
  126666. Time = 1
  126667. }
  126668. }
  126669. declare module BABYLON {
  126670. /**
  126671. * Block used to expose an input value
  126672. */
  126673. export class InputBlock extends NodeMaterialBlock {
  126674. private _mode;
  126675. private _associatedVariableName;
  126676. private _storedValue;
  126677. private _valueCallback;
  126678. private _type;
  126679. private _animationType;
  126680. /** Gets or set a value used to limit the range of float values */
  126681. min: number;
  126682. /** Gets or set a value used to limit the range of float values */
  126683. max: number;
  126684. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  126685. matrixMode: number;
  126686. /** @hidden */
  126687. _systemValue: Nullable<NodeMaterialSystemValues>;
  126688. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  126689. visibleInInspector: boolean;
  126690. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  126691. isConstant: boolean;
  126692. /** Gets or sets the group to use to display this block in the Inspector */
  126693. groupInInspector: string;
  126694. /**
  126695. * Gets or sets the connection point type (default is float)
  126696. */
  126697. get type(): NodeMaterialBlockConnectionPointTypes;
  126698. /**
  126699. * Creates a new InputBlock
  126700. * @param name defines the block name
  126701. * @param target defines the target of that block (Vertex by default)
  126702. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  126703. */
  126704. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  126705. /**
  126706. * Gets the output component
  126707. */
  126708. get output(): NodeMaterialConnectionPoint;
  126709. /**
  126710. * Set the source of this connection point to a vertex attribute
  126711. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  126712. * @returns the current connection point
  126713. */
  126714. setAsAttribute(attributeName?: string): InputBlock;
  126715. /**
  126716. * Set the source of this connection point to a system value
  126717. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  126718. * @returns the current connection point
  126719. */
  126720. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  126721. /**
  126722. * Gets or sets the value of that point.
  126723. * Please note that this value will be ignored if valueCallback is defined
  126724. */
  126725. get value(): any;
  126726. set value(value: any);
  126727. /**
  126728. * Gets or sets a callback used to get the value of that point.
  126729. * Please note that setting this value will force the connection point to ignore the value property
  126730. */
  126731. get valueCallback(): () => any;
  126732. set valueCallback(value: () => any);
  126733. /**
  126734. * Gets or sets the associated variable name in the shader
  126735. */
  126736. get associatedVariableName(): string;
  126737. set associatedVariableName(value: string);
  126738. /** Gets or sets the type of animation applied to the input */
  126739. get animationType(): AnimatedInputBlockTypes;
  126740. set animationType(value: AnimatedInputBlockTypes);
  126741. /**
  126742. * Gets a boolean indicating that this connection point not defined yet
  126743. */
  126744. get isUndefined(): boolean;
  126745. /**
  126746. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  126747. * In this case the connection point name must be the name of the uniform to use.
  126748. * Can only be set on inputs
  126749. */
  126750. get isUniform(): boolean;
  126751. set isUniform(value: boolean);
  126752. /**
  126753. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  126754. * In this case the connection point name must be the name of the attribute to use
  126755. * Can only be set on inputs
  126756. */
  126757. get isAttribute(): boolean;
  126758. set isAttribute(value: boolean);
  126759. /**
  126760. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  126761. * Can only be set on exit points
  126762. */
  126763. get isVarying(): boolean;
  126764. set isVarying(value: boolean);
  126765. /**
  126766. * Gets a boolean indicating that the current connection point is a system value
  126767. */
  126768. get isSystemValue(): boolean;
  126769. /**
  126770. * Gets or sets the current well known value or null if not defined as a system value
  126771. */
  126772. get systemValue(): Nullable<NodeMaterialSystemValues>;
  126773. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  126774. /**
  126775. * Gets the current class name
  126776. * @returns the class name
  126777. */
  126778. getClassName(): string;
  126779. /**
  126780. * Animate the input if animationType !== None
  126781. * @param scene defines the rendering scene
  126782. */
  126783. animate(scene: Scene): void;
  126784. private _emitDefine;
  126785. initialize(state: NodeMaterialBuildState): void;
  126786. /**
  126787. * Set the input block to its default value (based on its type)
  126788. */
  126789. setDefaultValue(): void;
  126790. private _emitConstant;
  126791. private _emit;
  126792. /** @hidden */
  126793. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  126794. /** @hidden */
  126795. _transmit(effect: Effect, scene: Scene): void;
  126796. protected _buildBlock(state: NodeMaterialBuildState): void;
  126797. protected _dumpPropertiesCode(): string;
  126798. serialize(): any;
  126799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126800. }
  126801. }
  126802. declare module BABYLON {
  126803. /**
  126804. * Enum used to define the compatibility state between two connection points
  126805. */
  126806. export enum NodeMaterialConnectionPointCompatibilityStates {
  126807. /** Points are compatibles */
  126808. Compatible = 0,
  126809. /** Points are incompatible because of their types */
  126810. TypeIncompatible = 1,
  126811. /** Points are incompatible because of their targets (vertex vs fragment) */
  126812. TargetIncompatible = 2
  126813. }
  126814. /**
  126815. * Defines the direction of a connection point
  126816. */
  126817. export enum NodeMaterialConnectionPointDirection {
  126818. /** Input */
  126819. Input = 0,
  126820. /** Output */
  126821. Output = 1
  126822. }
  126823. /**
  126824. * Defines a connection point for a block
  126825. */
  126826. export class NodeMaterialConnectionPoint {
  126827. /** @hidden */
  126828. _ownerBlock: NodeMaterialBlock;
  126829. /** @hidden */
  126830. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  126831. private _endpoints;
  126832. private _associatedVariableName;
  126833. private _direction;
  126834. /** @hidden */
  126835. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126836. /** @hidden */
  126837. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126838. private _type;
  126839. /** @hidden */
  126840. _enforceAssociatedVariableName: boolean;
  126841. /** Gets the direction of the point */
  126842. get direction(): NodeMaterialConnectionPointDirection;
  126843. /**
  126844. * Gets or sets the additional types supported by this connection point
  126845. */
  126846. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126847. /**
  126848. * Gets or sets the additional types excluded by this connection point
  126849. */
  126850. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126851. /**
  126852. * Observable triggered when this point is connected
  126853. */
  126854. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  126855. /**
  126856. * Gets or sets the associated variable name in the shader
  126857. */
  126858. get associatedVariableName(): string;
  126859. set associatedVariableName(value: string);
  126860. /**
  126861. * Gets or sets the connection point type (default is float)
  126862. */
  126863. get type(): NodeMaterialBlockConnectionPointTypes;
  126864. set type(value: NodeMaterialBlockConnectionPointTypes);
  126865. /**
  126866. * Gets or sets the connection point name
  126867. */
  126868. name: string;
  126869. /**
  126870. * Gets or sets a boolean indicating that this connection point can be omitted
  126871. */
  126872. isOptional: boolean;
  126873. /**
  126874. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  126875. */
  126876. define: string;
  126877. /** @hidden */
  126878. _prioritizeVertex: boolean;
  126879. private _target;
  126880. /** Gets or sets the target of that connection point */
  126881. get target(): NodeMaterialBlockTargets;
  126882. set target(value: NodeMaterialBlockTargets);
  126883. /**
  126884. * Gets a boolean indicating that the current point is connected
  126885. */
  126886. get isConnected(): boolean;
  126887. /**
  126888. * Gets a boolean indicating that the current point is connected to an input block
  126889. */
  126890. get isConnectedToInputBlock(): boolean;
  126891. /**
  126892. * Gets a the connected input block (if any)
  126893. */
  126894. get connectInputBlock(): Nullable<InputBlock>;
  126895. /** Get the other side of the connection (if any) */
  126896. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  126897. /** Get the block that owns this connection point */
  126898. get ownerBlock(): NodeMaterialBlock;
  126899. /** Get the block connected on the other side of this connection (if any) */
  126900. get sourceBlock(): Nullable<NodeMaterialBlock>;
  126901. /** Get the block connected on the endpoints of this connection (if any) */
  126902. get connectedBlocks(): Array<NodeMaterialBlock>;
  126903. /** Gets the list of connected endpoints */
  126904. get endpoints(): NodeMaterialConnectionPoint[];
  126905. /** Gets a boolean indicating if that output point is connected to at least one input */
  126906. get hasEndpoints(): boolean;
  126907. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  126908. get isConnectedInVertexShader(): boolean;
  126909. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  126910. get isConnectedInFragmentShader(): boolean;
  126911. /**
  126912. * Creates a new connection point
  126913. * @param name defines the connection point name
  126914. * @param ownerBlock defines the block hosting this connection point
  126915. * @param direction defines the direction of the connection point
  126916. */
  126917. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  126918. /**
  126919. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  126920. * @returns the class name
  126921. */
  126922. getClassName(): string;
  126923. /**
  126924. * Gets a boolean indicating if the current point can be connected to another point
  126925. * @param connectionPoint defines the other connection point
  126926. * @returns a boolean
  126927. */
  126928. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  126929. /**
  126930. * Gets a number indicating if the current point can be connected to another point
  126931. * @param connectionPoint defines the other connection point
  126932. * @returns a number defining the compatibility state
  126933. */
  126934. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  126935. /**
  126936. * Connect this point to another connection point
  126937. * @param connectionPoint defines the other connection point
  126938. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  126939. * @returns the current connection point
  126940. */
  126941. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  126942. /**
  126943. * Disconnect this point from one of his endpoint
  126944. * @param endpoint defines the other connection point
  126945. * @returns the current connection point
  126946. */
  126947. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  126948. /**
  126949. * Serializes this point in a JSON representation
  126950. * @returns the serialized point object
  126951. */
  126952. serialize(): any;
  126953. /**
  126954. * Release resources
  126955. */
  126956. dispose(): void;
  126957. }
  126958. }
  126959. declare module BABYLON {
  126960. /**
  126961. * Block used to add support for vertex skinning (bones)
  126962. */
  126963. export class BonesBlock extends NodeMaterialBlock {
  126964. /**
  126965. * Creates a new BonesBlock
  126966. * @param name defines the block name
  126967. */
  126968. constructor(name: string);
  126969. /**
  126970. * Initialize the block and prepare the context for build
  126971. * @param state defines the state that will be used for the build
  126972. */
  126973. initialize(state: NodeMaterialBuildState): void;
  126974. /**
  126975. * Gets the current class name
  126976. * @returns the class name
  126977. */
  126978. getClassName(): string;
  126979. /**
  126980. * Gets the matrix indices input component
  126981. */
  126982. get matricesIndices(): NodeMaterialConnectionPoint;
  126983. /**
  126984. * Gets the matrix weights input component
  126985. */
  126986. get matricesWeights(): NodeMaterialConnectionPoint;
  126987. /**
  126988. * Gets the extra matrix indices input component
  126989. */
  126990. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  126991. /**
  126992. * Gets the extra matrix weights input component
  126993. */
  126994. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  126995. /**
  126996. * Gets the world input component
  126997. */
  126998. get world(): NodeMaterialConnectionPoint;
  126999. /**
  127000. * Gets the output component
  127001. */
  127002. get output(): NodeMaterialConnectionPoint;
  127003. autoConfigure(material: NodeMaterial): void;
  127004. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  127005. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127007. protected _buildBlock(state: NodeMaterialBuildState): this;
  127008. }
  127009. }
  127010. declare module BABYLON {
  127011. /**
  127012. * Block used to add support for instances
  127013. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  127014. */
  127015. export class InstancesBlock extends NodeMaterialBlock {
  127016. /**
  127017. * Creates a new InstancesBlock
  127018. * @param name defines the block name
  127019. */
  127020. constructor(name: string);
  127021. /**
  127022. * Gets the current class name
  127023. * @returns the class name
  127024. */
  127025. getClassName(): string;
  127026. /**
  127027. * Gets the first world row input component
  127028. */
  127029. get world0(): NodeMaterialConnectionPoint;
  127030. /**
  127031. * Gets the second world row input component
  127032. */
  127033. get world1(): NodeMaterialConnectionPoint;
  127034. /**
  127035. * Gets the third world row input component
  127036. */
  127037. get world2(): NodeMaterialConnectionPoint;
  127038. /**
  127039. * Gets the forth world row input component
  127040. */
  127041. get world3(): NodeMaterialConnectionPoint;
  127042. /**
  127043. * Gets the world input component
  127044. */
  127045. get world(): NodeMaterialConnectionPoint;
  127046. /**
  127047. * Gets the output component
  127048. */
  127049. get output(): NodeMaterialConnectionPoint;
  127050. autoConfigure(material: NodeMaterial): void;
  127051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127052. protected _buildBlock(state: NodeMaterialBuildState): this;
  127053. }
  127054. }
  127055. declare module BABYLON {
  127056. /**
  127057. * Block used to add morph targets support to vertex shader
  127058. */
  127059. export class MorphTargetsBlock extends NodeMaterialBlock {
  127060. private _repeatableContentAnchor;
  127061. private _repeatebleContentGenerated;
  127062. /**
  127063. * Create a new MorphTargetsBlock
  127064. * @param name defines the block name
  127065. */
  127066. constructor(name: string);
  127067. /**
  127068. * Gets the current class name
  127069. * @returns the class name
  127070. */
  127071. getClassName(): string;
  127072. /**
  127073. * Gets the position input component
  127074. */
  127075. get position(): NodeMaterialConnectionPoint;
  127076. /**
  127077. * Gets the normal input component
  127078. */
  127079. get normal(): NodeMaterialConnectionPoint;
  127080. /**
  127081. * Gets the tangent input component
  127082. */
  127083. get tangent(): NodeMaterialConnectionPoint;
  127084. /**
  127085. * Gets the tangent input component
  127086. */
  127087. get uv(): NodeMaterialConnectionPoint;
  127088. /**
  127089. * Gets the position output component
  127090. */
  127091. get positionOutput(): NodeMaterialConnectionPoint;
  127092. /**
  127093. * Gets the normal output component
  127094. */
  127095. get normalOutput(): NodeMaterialConnectionPoint;
  127096. /**
  127097. * Gets the tangent output component
  127098. */
  127099. get tangentOutput(): NodeMaterialConnectionPoint;
  127100. /**
  127101. * Gets the tangent output component
  127102. */
  127103. get uvOutput(): NodeMaterialConnectionPoint;
  127104. initialize(state: NodeMaterialBuildState): void;
  127105. autoConfigure(material: NodeMaterial): void;
  127106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127107. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127108. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  127109. protected _buildBlock(state: NodeMaterialBuildState): this;
  127110. }
  127111. }
  127112. declare module BABYLON {
  127113. /**
  127114. * Block used to get data information from a light
  127115. */
  127116. export class LightInformationBlock extends NodeMaterialBlock {
  127117. private _lightDataUniformName;
  127118. private _lightColorUniformName;
  127119. private _lightTypeDefineName;
  127120. /**
  127121. * Gets or sets the light associated with this block
  127122. */
  127123. light: Nullable<Light>;
  127124. /**
  127125. * Creates a new LightInformationBlock
  127126. * @param name defines the block name
  127127. */
  127128. constructor(name: string);
  127129. /**
  127130. * Gets the current class name
  127131. * @returns the class name
  127132. */
  127133. getClassName(): string;
  127134. /**
  127135. * Gets the world position input component
  127136. */
  127137. get worldPosition(): NodeMaterialConnectionPoint;
  127138. /**
  127139. * Gets the direction output component
  127140. */
  127141. get direction(): NodeMaterialConnectionPoint;
  127142. /**
  127143. * Gets the direction output component
  127144. */
  127145. get color(): NodeMaterialConnectionPoint;
  127146. /**
  127147. * Gets the direction output component
  127148. */
  127149. get intensity(): NodeMaterialConnectionPoint;
  127150. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127151. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127152. protected _buildBlock(state: NodeMaterialBuildState): this;
  127153. serialize(): any;
  127154. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127155. }
  127156. }
  127157. declare module BABYLON {
  127158. /**
  127159. * Block used to add image processing support to fragment shader
  127160. */
  127161. export class ImageProcessingBlock extends NodeMaterialBlock {
  127162. /**
  127163. * Create a new ImageProcessingBlock
  127164. * @param name defines the block name
  127165. */
  127166. constructor(name: string);
  127167. /**
  127168. * Gets the current class name
  127169. * @returns the class name
  127170. */
  127171. getClassName(): string;
  127172. /**
  127173. * Gets the color input component
  127174. */
  127175. get color(): NodeMaterialConnectionPoint;
  127176. /**
  127177. * Gets the output component
  127178. */
  127179. get output(): NodeMaterialConnectionPoint;
  127180. /**
  127181. * Initialize the block and prepare the context for build
  127182. * @param state defines the state that will be used for the build
  127183. */
  127184. initialize(state: NodeMaterialBuildState): void;
  127185. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  127186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127188. protected _buildBlock(state: NodeMaterialBuildState): this;
  127189. }
  127190. }
  127191. declare module BABYLON {
  127192. /**
  127193. * Block used to pertub normals based on a normal map
  127194. */
  127195. export class PerturbNormalBlock extends NodeMaterialBlock {
  127196. private _tangentSpaceParameterName;
  127197. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  127198. invertX: boolean;
  127199. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  127200. invertY: boolean;
  127201. /**
  127202. * Create a new PerturbNormalBlock
  127203. * @param name defines the block name
  127204. */
  127205. constructor(name: string);
  127206. /**
  127207. * Gets the current class name
  127208. * @returns the class name
  127209. */
  127210. getClassName(): string;
  127211. /**
  127212. * Gets the world position input component
  127213. */
  127214. get worldPosition(): NodeMaterialConnectionPoint;
  127215. /**
  127216. * Gets the world normal input component
  127217. */
  127218. get worldNormal(): NodeMaterialConnectionPoint;
  127219. /**
  127220. * Gets the uv input component
  127221. */
  127222. get uv(): NodeMaterialConnectionPoint;
  127223. /**
  127224. * Gets the normal map color input component
  127225. */
  127226. get normalMapColor(): NodeMaterialConnectionPoint;
  127227. /**
  127228. * Gets the strength input component
  127229. */
  127230. get strength(): NodeMaterialConnectionPoint;
  127231. /**
  127232. * Gets the output component
  127233. */
  127234. get output(): NodeMaterialConnectionPoint;
  127235. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127236. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127237. autoConfigure(material: NodeMaterial): void;
  127238. protected _buildBlock(state: NodeMaterialBuildState): this;
  127239. protected _dumpPropertiesCode(): string;
  127240. serialize(): any;
  127241. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127242. }
  127243. }
  127244. declare module BABYLON {
  127245. /**
  127246. * Block used to discard a pixel if a value is smaller than a cutoff
  127247. */
  127248. export class DiscardBlock extends NodeMaterialBlock {
  127249. /**
  127250. * Create a new DiscardBlock
  127251. * @param name defines the block name
  127252. */
  127253. constructor(name: string);
  127254. /**
  127255. * Gets the current class name
  127256. * @returns the class name
  127257. */
  127258. getClassName(): string;
  127259. /**
  127260. * Gets the color input component
  127261. */
  127262. get value(): NodeMaterialConnectionPoint;
  127263. /**
  127264. * Gets the cutoff input component
  127265. */
  127266. get cutoff(): NodeMaterialConnectionPoint;
  127267. protected _buildBlock(state: NodeMaterialBuildState): this;
  127268. }
  127269. }
  127270. declare module BABYLON {
  127271. /**
  127272. * Block used to test if the fragment shader is front facing
  127273. */
  127274. export class FrontFacingBlock extends NodeMaterialBlock {
  127275. /**
  127276. * Creates a new FrontFacingBlock
  127277. * @param name defines the block name
  127278. */
  127279. constructor(name: string);
  127280. /**
  127281. * Gets the current class name
  127282. * @returns the class name
  127283. */
  127284. getClassName(): string;
  127285. /**
  127286. * Gets the output component
  127287. */
  127288. get output(): NodeMaterialConnectionPoint;
  127289. protected _buildBlock(state: NodeMaterialBuildState): this;
  127290. }
  127291. }
  127292. declare module BABYLON {
  127293. /**
  127294. * Block used to get the derivative value on x and y of a given input
  127295. */
  127296. export class DerivativeBlock extends NodeMaterialBlock {
  127297. /**
  127298. * Create a new DerivativeBlock
  127299. * @param name defines the block name
  127300. */
  127301. constructor(name: string);
  127302. /**
  127303. * Gets the current class name
  127304. * @returns the class name
  127305. */
  127306. getClassName(): string;
  127307. /**
  127308. * Gets the input component
  127309. */
  127310. get input(): NodeMaterialConnectionPoint;
  127311. /**
  127312. * Gets the derivative output on x
  127313. */
  127314. get dx(): NodeMaterialConnectionPoint;
  127315. /**
  127316. * Gets the derivative output on y
  127317. */
  127318. get dy(): NodeMaterialConnectionPoint;
  127319. protected _buildBlock(state: NodeMaterialBuildState): this;
  127320. }
  127321. }
  127322. declare module BABYLON {
  127323. /**
  127324. * Block used to add support for scene fog
  127325. */
  127326. export class FogBlock extends NodeMaterialBlock {
  127327. private _fogDistanceName;
  127328. private _fogParameters;
  127329. /**
  127330. * Create a new FogBlock
  127331. * @param name defines the block name
  127332. */
  127333. constructor(name: string);
  127334. /**
  127335. * Gets the current class name
  127336. * @returns the class name
  127337. */
  127338. getClassName(): string;
  127339. /**
  127340. * Gets the world position input component
  127341. */
  127342. get worldPosition(): NodeMaterialConnectionPoint;
  127343. /**
  127344. * Gets the view input component
  127345. */
  127346. get view(): NodeMaterialConnectionPoint;
  127347. /**
  127348. * Gets the color input component
  127349. */
  127350. get input(): NodeMaterialConnectionPoint;
  127351. /**
  127352. * Gets the fog color input component
  127353. */
  127354. get fogColor(): NodeMaterialConnectionPoint;
  127355. /**
  127356. * Gets the output component
  127357. */
  127358. get output(): NodeMaterialConnectionPoint;
  127359. autoConfigure(material: NodeMaterial): void;
  127360. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127361. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127362. protected _buildBlock(state: NodeMaterialBuildState): this;
  127363. }
  127364. }
  127365. declare module BABYLON {
  127366. /**
  127367. * Block used to add light in the fragment shader
  127368. */
  127369. export class LightBlock extends NodeMaterialBlock {
  127370. private _lightId;
  127371. /**
  127372. * Gets or sets the light associated with this block
  127373. */
  127374. light: Nullable<Light>;
  127375. /**
  127376. * Create a new LightBlock
  127377. * @param name defines the block name
  127378. */
  127379. constructor(name: string);
  127380. /**
  127381. * Gets the current class name
  127382. * @returns the class name
  127383. */
  127384. getClassName(): string;
  127385. /**
  127386. * Gets the world position input component
  127387. */
  127388. get worldPosition(): NodeMaterialConnectionPoint;
  127389. /**
  127390. * Gets the world normal input component
  127391. */
  127392. get worldNormal(): NodeMaterialConnectionPoint;
  127393. /**
  127394. * Gets the camera (or eye) position component
  127395. */
  127396. get cameraPosition(): NodeMaterialConnectionPoint;
  127397. /**
  127398. * Gets the glossiness component
  127399. */
  127400. get glossiness(): NodeMaterialConnectionPoint;
  127401. /**
  127402. * Gets the glossinness power component
  127403. */
  127404. get glossPower(): NodeMaterialConnectionPoint;
  127405. /**
  127406. * Gets the diffuse color component
  127407. */
  127408. get diffuseColor(): NodeMaterialConnectionPoint;
  127409. /**
  127410. * Gets the specular color component
  127411. */
  127412. get specularColor(): NodeMaterialConnectionPoint;
  127413. /**
  127414. * Gets the diffuse output component
  127415. */
  127416. get diffuseOutput(): NodeMaterialConnectionPoint;
  127417. /**
  127418. * Gets the specular output component
  127419. */
  127420. get specularOutput(): NodeMaterialConnectionPoint;
  127421. /**
  127422. * Gets the shadow output component
  127423. */
  127424. get shadow(): NodeMaterialConnectionPoint;
  127425. autoConfigure(material: NodeMaterial): void;
  127426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127427. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  127428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127429. private _injectVertexCode;
  127430. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127431. serialize(): any;
  127432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127433. }
  127434. }
  127435. declare module BABYLON {
  127436. /**
  127437. * Block used to multiply 2 values
  127438. */
  127439. export class MultiplyBlock extends NodeMaterialBlock {
  127440. /**
  127441. * Creates a new MultiplyBlock
  127442. * @param name defines the block name
  127443. */
  127444. constructor(name: string);
  127445. /**
  127446. * Gets the current class name
  127447. * @returns the class name
  127448. */
  127449. getClassName(): string;
  127450. /**
  127451. * Gets the left operand input component
  127452. */
  127453. get left(): NodeMaterialConnectionPoint;
  127454. /**
  127455. * Gets the right operand input component
  127456. */
  127457. get right(): NodeMaterialConnectionPoint;
  127458. /**
  127459. * Gets the output component
  127460. */
  127461. get output(): NodeMaterialConnectionPoint;
  127462. protected _buildBlock(state: NodeMaterialBuildState): this;
  127463. }
  127464. }
  127465. declare module BABYLON {
  127466. /**
  127467. * Block used to add 2 vectors
  127468. */
  127469. export class AddBlock extends NodeMaterialBlock {
  127470. /**
  127471. * Creates a new AddBlock
  127472. * @param name defines the block name
  127473. */
  127474. constructor(name: string);
  127475. /**
  127476. * Gets the current class name
  127477. * @returns the class name
  127478. */
  127479. getClassName(): string;
  127480. /**
  127481. * Gets the left operand input component
  127482. */
  127483. get left(): NodeMaterialConnectionPoint;
  127484. /**
  127485. * Gets the right operand input component
  127486. */
  127487. get right(): NodeMaterialConnectionPoint;
  127488. /**
  127489. * Gets the output component
  127490. */
  127491. get output(): NodeMaterialConnectionPoint;
  127492. protected _buildBlock(state: NodeMaterialBuildState): this;
  127493. }
  127494. }
  127495. declare module BABYLON {
  127496. /**
  127497. * Block used to scale a vector by a float
  127498. */
  127499. export class ScaleBlock extends NodeMaterialBlock {
  127500. /**
  127501. * Creates a new ScaleBlock
  127502. * @param name defines the block name
  127503. */
  127504. constructor(name: string);
  127505. /**
  127506. * Gets the current class name
  127507. * @returns the class name
  127508. */
  127509. getClassName(): string;
  127510. /**
  127511. * Gets the input component
  127512. */
  127513. get input(): NodeMaterialConnectionPoint;
  127514. /**
  127515. * Gets the factor input component
  127516. */
  127517. get factor(): NodeMaterialConnectionPoint;
  127518. /**
  127519. * Gets the output component
  127520. */
  127521. get output(): NodeMaterialConnectionPoint;
  127522. protected _buildBlock(state: NodeMaterialBuildState): this;
  127523. }
  127524. }
  127525. declare module BABYLON {
  127526. /**
  127527. * Block used to clamp a float
  127528. */
  127529. export class ClampBlock extends NodeMaterialBlock {
  127530. /** Gets or sets the minimum range */
  127531. minimum: number;
  127532. /** Gets or sets the maximum range */
  127533. maximum: number;
  127534. /**
  127535. * Creates a new ClampBlock
  127536. * @param name defines the block name
  127537. */
  127538. constructor(name: string);
  127539. /**
  127540. * Gets the current class name
  127541. * @returns the class name
  127542. */
  127543. getClassName(): string;
  127544. /**
  127545. * Gets the value input component
  127546. */
  127547. get value(): NodeMaterialConnectionPoint;
  127548. /**
  127549. * Gets the output component
  127550. */
  127551. get output(): NodeMaterialConnectionPoint;
  127552. protected _buildBlock(state: NodeMaterialBuildState): this;
  127553. protected _dumpPropertiesCode(): string;
  127554. serialize(): any;
  127555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127556. }
  127557. }
  127558. declare module BABYLON {
  127559. /**
  127560. * Block used to apply a cross product between 2 vectors
  127561. */
  127562. export class CrossBlock extends NodeMaterialBlock {
  127563. /**
  127564. * Creates a new CrossBlock
  127565. * @param name defines the block name
  127566. */
  127567. constructor(name: string);
  127568. /**
  127569. * Gets the current class name
  127570. * @returns the class name
  127571. */
  127572. getClassName(): string;
  127573. /**
  127574. * Gets the left operand input component
  127575. */
  127576. get left(): NodeMaterialConnectionPoint;
  127577. /**
  127578. * Gets the right operand input component
  127579. */
  127580. get right(): NodeMaterialConnectionPoint;
  127581. /**
  127582. * Gets the output component
  127583. */
  127584. get output(): NodeMaterialConnectionPoint;
  127585. protected _buildBlock(state: NodeMaterialBuildState): this;
  127586. }
  127587. }
  127588. declare module BABYLON {
  127589. /**
  127590. * Block used to apply a dot product between 2 vectors
  127591. */
  127592. export class DotBlock extends NodeMaterialBlock {
  127593. /**
  127594. * Creates a new DotBlock
  127595. * @param name defines the block name
  127596. */
  127597. constructor(name: string);
  127598. /**
  127599. * Gets the current class name
  127600. * @returns the class name
  127601. */
  127602. getClassName(): string;
  127603. /**
  127604. * Gets the left operand input component
  127605. */
  127606. get left(): NodeMaterialConnectionPoint;
  127607. /**
  127608. * Gets the right operand input component
  127609. */
  127610. get right(): NodeMaterialConnectionPoint;
  127611. /**
  127612. * Gets the output component
  127613. */
  127614. get output(): NodeMaterialConnectionPoint;
  127615. protected _buildBlock(state: NodeMaterialBuildState): this;
  127616. }
  127617. }
  127618. declare module BABYLON {
  127619. /**
  127620. * Block used to remap a float from a range to a new one
  127621. */
  127622. export class RemapBlock extends NodeMaterialBlock {
  127623. /**
  127624. * Gets or sets the source range
  127625. */
  127626. sourceRange: Vector2;
  127627. /**
  127628. * Gets or sets the target range
  127629. */
  127630. targetRange: Vector2;
  127631. /**
  127632. * Creates a new RemapBlock
  127633. * @param name defines the block name
  127634. */
  127635. constructor(name: string);
  127636. /**
  127637. * Gets the current class name
  127638. * @returns the class name
  127639. */
  127640. getClassName(): string;
  127641. /**
  127642. * Gets the input component
  127643. */
  127644. get input(): NodeMaterialConnectionPoint;
  127645. /**
  127646. * Gets the source min input component
  127647. */
  127648. get sourceMin(): NodeMaterialConnectionPoint;
  127649. /**
  127650. * Gets the source max input component
  127651. */
  127652. get sourceMax(): NodeMaterialConnectionPoint;
  127653. /**
  127654. * Gets the target min input component
  127655. */
  127656. get targetMin(): NodeMaterialConnectionPoint;
  127657. /**
  127658. * Gets the target max input component
  127659. */
  127660. get targetMax(): NodeMaterialConnectionPoint;
  127661. /**
  127662. * Gets the output component
  127663. */
  127664. get output(): NodeMaterialConnectionPoint;
  127665. protected _buildBlock(state: NodeMaterialBuildState): this;
  127666. protected _dumpPropertiesCode(): string;
  127667. serialize(): any;
  127668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127669. }
  127670. }
  127671. declare module BABYLON {
  127672. /**
  127673. * Block used to normalize a vector
  127674. */
  127675. export class NormalizeBlock extends NodeMaterialBlock {
  127676. /**
  127677. * Creates a new NormalizeBlock
  127678. * @param name defines the block name
  127679. */
  127680. constructor(name: string);
  127681. /**
  127682. * Gets the current class name
  127683. * @returns the class name
  127684. */
  127685. getClassName(): string;
  127686. /**
  127687. * Gets the input component
  127688. */
  127689. get input(): NodeMaterialConnectionPoint;
  127690. /**
  127691. * Gets the output component
  127692. */
  127693. get output(): NodeMaterialConnectionPoint;
  127694. protected _buildBlock(state: NodeMaterialBuildState): this;
  127695. }
  127696. }
  127697. declare module BABYLON {
  127698. /**
  127699. * Operations supported by the Trigonometry block
  127700. */
  127701. export enum TrigonometryBlockOperations {
  127702. /** Cos */
  127703. Cos = 0,
  127704. /** Sin */
  127705. Sin = 1,
  127706. /** Abs */
  127707. Abs = 2,
  127708. /** Exp */
  127709. Exp = 3,
  127710. /** Exp2 */
  127711. Exp2 = 4,
  127712. /** Round */
  127713. Round = 5,
  127714. /** Floor */
  127715. Floor = 6,
  127716. /** Ceiling */
  127717. Ceiling = 7,
  127718. /** Square root */
  127719. Sqrt = 8,
  127720. /** Log */
  127721. Log = 9,
  127722. /** Tangent */
  127723. Tan = 10,
  127724. /** Arc tangent */
  127725. ArcTan = 11,
  127726. /** Arc cosinus */
  127727. ArcCos = 12,
  127728. /** Arc sinus */
  127729. ArcSin = 13,
  127730. /** Fraction */
  127731. Fract = 14,
  127732. /** Sign */
  127733. Sign = 15,
  127734. /** To radians (from degrees) */
  127735. Radians = 16,
  127736. /** To degrees (from radians) */
  127737. Degrees = 17
  127738. }
  127739. /**
  127740. * Block used to apply trigonometry operation to floats
  127741. */
  127742. export class TrigonometryBlock extends NodeMaterialBlock {
  127743. /**
  127744. * Gets or sets the operation applied by the block
  127745. */
  127746. operation: TrigonometryBlockOperations;
  127747. /**
  127748. * Creates a new TrigonometryBlock
  127749. * @param name defines the block name
  127750. */
  127751. constructor(name: string);
  127752. /**
  127753. * Gets the current class name
  127754. * @returns the class name
  127755. */
  127756. getClassName(): string;
  127757. /**
  127758. * Gets the input component
  127759. */
  127760. get input(): NodeMaterialConnectionPoint;
  127761. /**
  127762. * Gets the output component
  127763. */
  127764. get output(): NodeMaterialConnectionPoint;
  127765. protected _buildBlock(state: NodeMaterialBuildState): this;
  127766. serialize(): any;
  127767. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127768. protected _dumpPropertiesCode(): string;
  127769. }
  127770. }
  127771. declare module BABYLON {
  127772. /**
  127773. * Block used to create a Color3/4 out of individual inputs (one for each component)
  127774. */
  127775. export class ColorMergerBlock extends NodeMaterialBlock {
  127776. /**
  127777. * Create a new ColorMergerBlock
  127778. * @param name defines the block name
  127779. */
  127780. constructor(name: string);
  127781. /**
  127782. * Gets the current class name
  127783. * @returns the class name
  127784. */
  127785. getClassName(): string;
  127786. /**
  127787. * Gets the rgb component (input)
  127788. */
  127789. get rgbIn(): NodeMaterialConnectionPoint;
  127790. /**
  127791. * Gets the r component (input)
  127792. */
  127793. get r(): NodeMaterialConnectionPoint;
  127794. /**
  127795. * Gets the g component (input)
  127796. */
  127797. get g(): NodeMaterialConnectionPoint;
  127798. /**
  127799. * Gets the b component (input)
  127800. */
  127801. get b(): NodeMaterialConnectionPoint;
  127802. /**
  127803. * Gets the a component (input)
  127804. */
  127805. get a(): NodeMaterialConnectionPoint;
  127806. /**
  127807. * Gets the rgba component (output)
  127808. */
  127809. get rgba(): NodeMaterialConnectionPoint;
  127810. /**
  127811. * Gets the rgb component (output)
  127812. */
  127813. get rgbOut(): NodeMaterialConnectionPoint;
  127814. /**
  127815. * Gets the rgb component (output)
  127816. * @deprecated Please use rgbOut instead.
  127817. */
  127818. get rgb(): NodeMaterialConnectionPoint;
  127819. protected _buildBlock(state: NodeMaterialBuildState): this;
  127820. }
  127821. }
  127822. declare module BABYLON {
  127823. /**
  127824. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  127825. */
  127826. export class VectorMergerBlock extends NodeMaterialBlock {
  127827. /**
  127828. * Create a new VectorMergerBlock
  127829. * @param name defines the block name
  127830. */
  127831. constructor(name: string);
  127832. /**
  127833. * Gets the current class name
  127834. * @returns the class name
  127835. */
  127836. getClassName(): string;
  127837. /**
  127838. * Gets the xyz component (input)
  127839. */
  127840. get xyzIn(): NodeMaterialConnectionPoint;
  127841. /**
  127842. * Gets the xy component (input)
  127843. */
  127844. get xyIn(): NodeMaterialConnectionPoint;
  127845. /**
  127846. * Gets the x component (input)
  127847. */
  127848. get x(): NodeMaterialConnectionPoint;
  127849. /**
  127850. * Gets the y component (input)
  127851. */
  127852. get y(): NodeMaterialConnectionPoint;
  127853. /**
  127854. * Gets the z component (input)
  127855. */
  127856. get z(): NodeMaterialConnectionPoint;
  127857. /**
  127858. * Gets the w component (input)
  127859. */
  127860. get w(): NodeMaterialConnectionPoint;
  127861. /**
  127862. * Gets the xyzw component (output)
  127863. */
  127864. get xyzw(): NodeMaterialConnectionPoint;
  127865. /**
  127866. * Gets the xyz component (output)
  127867. */
  127868. get xyzOut(): NodeMaterialConnectionPoint;
  127869. /**
  127870. * Gets the xy component (output)
  127871. */
  127872. get xyOut(): NodeMaterialConnectionPoint;
  127873. /**
  127874. * Gets the xy component (output)
  127875. * @deprecated Please use xyOut instead.
  127876. */
  127877. get xy(): NodeMaterialConnectionPoint;
  127878. /**
  127879. * Gets the xyz component (output)
  127880. * @deprecated Please use xyzOut instead.
  127881. */
  127882. get xyz(): NodeMaterialConnectionPoint;
  127883. protected _buildBlock(state: NodeMaterialBuildState): this;
  127884. }
  127885. }
  127886. declare module BABYLON {
  127887. /**
  127888. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  127889. */
  127890. export class ColorSplitterBlock extends NodeMaterialBlock {
  127891. /**
  127892. * Create a new ColorSplitterBlock
  127893. * @param name defines the block name
  127894. */
  127895. constructor(name: string);
  127896. /**
  127897. * Gets the current class name
  127898. * @returns the class name
  127899. */
  127900. getClassName(): string;
  127901. /**
  127902. * Gets the rgba component (input)
  127903. */
  127904. get rgba(): NodeMaterialConnectionPoint;
  127905. /**
  127906. * Gets the rgb component (input)
  127907. */
  127908. get rgbIn(): NodeMaterialConnectionPoint;
  127909. /**
  127910. * Gets the rgb component (output)
  127911. */
  127912. get rgbOut(): NodeMaterialConnectionPoint;
  127913. /**
  127914. * Gets the r component (output)
  127915. */
  127916. get r(): NodeMaterialConnectionPoint;
  127917. /**
  127918. * Gets the g component (output)
  127919. */
  127920. get g(): NodeMaterialConnectionPoint;
  127921. /**
  127922. * Gets the b component (output)
  127923. */
  127924. get b(): NodeMaterialConnectionPoint;
  127925. /**
  127926. * Gets the a component (output)
  127927. */
  127928. get a(): NodeMaterialConnectionPoint;
  127929. protected _inputRename(name: string): string;
  127930. protected _outputRename(name: string): string;
  127931. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127932. }
  127933. }
  127934. declare module BABYLON {
  127935. /**
  127936. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  127937. */
  127938. export class VectorSplitterBlock extends NodeMaterialBlock {
  127939. /**
  127940. * Create a new VectorSplitterBlock
  127941. * @param name defines the block name
  127942. */
  127943. constructor(name: string);
  127944. /**
  127945. * Gets the current class name
  127946. * @returns the class name
  127947. */
  127948. getClassName(): string;
  127949. /**
  127950. * Gets the xyzw component (input)
  127951. */
  127952. get xyzw(): NodeMaterialConnectionPoint;
  127953. /**
  127954. * Gets the xyz component (input)
  127955. */
  127956. get xyzIn(): NodeMaterialConnectionPoint;
  127957. /**
  127958. * Gets the xy component (input)
  127959. */
  127960. get xyIn(): NodeMaterialConnectionPoint;
  127961. /**
  127962. * Gets the xyz component (output)
  127963. */
  127964. get xyzOut(): NodeMaterialConnectionPoint;
  127965. /**
  127966. * Gets the xy component (output)
  127967. */
  127968. get xyOut(): NodeMaterialConnectionPoint;
  127969. /**
  127970. * Gets the x component (output)
  127971. */
  127972. get x(): NodeMaterialConnectionPoint;
  127973. /**
  127974. * Gets the y component (output)
  127975. */
  127976. get y(): NodeMaterialConnectionPoint;
  127977. /**
  127978. * Gets the z component (output)
  127979. */
  127980. get z(): NodeMaterialConnectionPoint;
  127981. /**
  127982. * Gets the w component (output)
  127983. */
  127984. get w(): NodeMaterialConnectionPoint;
  127985. protected _inputRename(name: string): string;
  127986. protected _outputRename(name: string): string;
  127987. protected _buildBlock(state: NodeMaterialBuildState): this;
  127988. }
  127989. }
  127990. declare module BABYLON {
  127991. /**
  127992. * Block used to lerp between 2 values
  127993. */
  127994. export class LerpBlock extends NodeMaterialBlock {
  127995. /**
  127996. * Creates a new LerpBlock
  127997. * @param name defines the block name
  127998. */
  127999. constructor(name: string);
  128000. /**
  128001. * Gets the current class name
  128002. * @returns the class name
  128003. */
  128004. getClassName(): string;
  128005. /**
  128006. * Gets the left operand input component
  128007. */
  128008. get left(): NodeMaterialConnectionPoint;
  128009. /**
  128010. * Gets the right operand input component
  128011. */
  128012. get right(): NodeMaterialConnectionPoint;
  128013. /**
  128014. * Gets the gradient operand input component
  128015. */
  128016. get gradient(): NodeMaterialConnectionPoint;
  128017. /**
  128018. * Gets the output component
  128019. */
  128020. get output(): NodeMaterialConnectionPoint;
  128021. protected _buildBlock(state: NodeMaterialBuildState): this;
  128022. }
  128023. }
  128024. declare module BABYLON {
  128025. /**
  128026. * Block used to divide 2 vectors
  128027. */
  128028. export class DivideBlock extends NodeMaterialBlock {
  128029. /**
  128030. * Creates a new DivideBlock
  128031. * @param name defines the block name
  128032. */
  128033. constructor(name: string);
  128034. /**
  128035. * Gets the current class name
  128036. * @returns the class name
  128037. */
  128038. getClassName(): string;
  128039. /**
  128040. * Gets the left operand input component
  128041. */
  128042. get left(): NodeMaterialConnectionPoint;
  128043. /**
  128044. * Gets the right operand input component
  128045. */
  128046. get right(): NodeMaterialConnectionPoint;
  128047. /**
  128048. * Gets the output component
  128049. */
  128050. get output(): NodeMaterialConnectionPoint;
  128051. protected _buildBlock(state: NodeMaterialBuildState): this;
  128052. }
  128053. }
  128054. declare module BABYLON {
  128055. /**
  128056. * Block used to subtract 2 vectors
  128057. */
  128058. export class SubtractBlock extends NodeMaterialBlock {
  128059. /**
  128060. * Creates a new SubtractBlock
  128061. * @param name defines the block name
  128062. */
  128063. constructor(name: string);
  128064. /**
  128065. * Gets the current class name
  128066. * @returns the class name
  128067. */
  128068. getClassName(): string;
  128069. /**
  128070. * Gets the left operand input component
  128071. */
  128072. get left(): NodeMaterialConnectionPoint;
  128073. /**
  128074. * Gets the right operand input component
  128075. */
  128076. get right(): NodeMaterialConnectionPoint;
  128077. /**
  128078. * Gets the output component
  128079. */
  128080. get output(): NodeMaterialConnectionPoint;
  128081. protected _buildBlock(state: NodeMaterialBuildState): this;
  128082. }
  128083. }
  128084. declare module BABYLON {
  128085. /**
  128086. * Block used to step a value
  128087. */
  128088. export class StepBlock extends NodeMaterialBlock {
  128089. /**
  128090. * Creates a new StepBlock
  128091. * @param name defines the block name
  128092. */
  128093. constructor(name: string);
  128094. /**
  128095. * Gets the current class name
  128096. * @returns the class name
  128097. */
  128098. getClassName(): string;
  128099. /**
  128100. * Gets the value operand input component
  128101. */
  128102. get value(): NodeMaterialConnectionPoint;
  128103. /**
  128104. * Gets the edge operand input component
  128105. */
  128106. get edge(): NodeMaterialConnectionPoint;
  128107. /**
  128108. * Gets the output component
  128109. */
  128110. get output(): NodeMaterialConnectionPoint;
  128111. protected _buildBlock(state: NodeMaterialBuildState): this;
  128112. }
  128113. }
  128114. declare module BABYLON {
  128115. /**
  128116. * Block used to get the opposite (1 - x) of a value
  128117. */
  128118. export class OneMinusBlock extends NodeMaterialBlock {
  128119. /**
  128120. * Creates a new OneMinusBlock
  128121. * @param name defines the block name
  128122. */
  128123. constructor(name: string);
  128124. /**
  128125. * Gets the current class name
  128126. * @returns the class name
  128127. */
  128128. getClassName(): string;
  128129. /**
  128130. * Gets the input component
  128131. */
  128132. get input(): NodeMaterialConnectionPoint;
  128133. /**
  128134. * Gets the output component
  128135. */
  128136. get output(): NodeMaterialConnectionPoint;
  128137. protected _buildBlock(state: NodeMaterialBuildState): this;
  128138. }
  128139. }
  128140. declare module BABYLON {
  128141. /**
  128142. * Block used to get the view direction
  128143. */
  128144. export class ViewDirectionBlock extends NodeMaterialBlock {
  128145. /**
  128146. * Creates a new ViewDirectionBlock
  128147. * @param name defines the block name
  128148. */
  128149. constructor(name: string);
  128150. /**
  128151. * Gets the current class name
  128152. * @returns the class name
  128153. */
  128154. getClassName(): string;
  128155. /**
  128156. * Gets the world position component
  128157. */
  128158. get worldPosition(): NodeMaterialConnectionPoint;
  128159. /**
  128160. * Gets the camera position component
  128161. */
  128162. get cameraPosition(): NodeMaterialConnectionPoint;
  128163. /**
  128164. * Gets the output component
  128165. */
  128166. get output(): NodeMaterialConnectionPoint;
  128167. autoConfigure(material: NodeMaterial): void;
  128168. protected _buildBlock(state: NodeMaterialBuildState): this;
  128169. }
  128170. }
  128171. declare module BABYLON {
  128172. /**
  128173. * Block used to compute fresnel value
  128174. */
  128175. export class FresnelBlock extends NodeMaterialBlock {
  128176. /**
  128177. * Create a new FresnelBlock
  128178. * @param name defines the block name
  128179. */
  128180. constructor(name: string);
  128181. /**
  128182. * Gets the current class name
  128183. * @returns the class name
  128184. */
  128185. getClassName(): string;
  128186. /**
  128187. * Gets the world normal input component
  128188. */
  128189. get worldNormal(): NodeMaterialConnectionPoint;
  128190. /**
  128191. * Gets the view direction input component
  128192. */
  128193. get viewDirection(): NodeMaterialConnectionPoint;
  128194. /**
  128195. * Gets the bias input component
  128196. */
  128197. get bias(): NodeMaterialConnectionPoint;
  128198. /**
  128199. * Gets the camera (or eye) position component
  128200. */
  128201. get power(): NodeMaterialConnectionPoint;
  128202. /**
  128203. * Gets the fresnel output component
  128204. */
  128205. get fresnel(): NodeMaterialConnectionPoint;
  128206. autoConfigure(material: NodeMaterial): void;
  128207. protected _buildBlock(state: NodeMaterialBuildState): this;
  128208. }
  128209. }
  128210. declare module BABYLON {
  128211. /**
  128212. * Block used to get the max of 2 values
  128213. */
  128214. export class MaxBlock extends NodeMaterialBlock {
  128215. /**
  128216. * Creates a new MaxBlock
  128217. * @param name defines the block name
  128218. */
  128219. constructor(name: string);
  128220. /**
  128221. * Gets the current class name
  128222. * @returns the class name
  128223. */
  128224. getClassName(): string;
  128225. /**
  128226. * Gets the left operand input component
  128227. */
  128228. get left(): NodeMaterialConnectionPoint;
  128229. /**
  128230. * Gets the right operand input component
  128231. */
  128232. get right(): NodeMaterialConnectionPoint;
  128233. /**
  128234. * Gets the output component
  128235. */
  128236. get output(): NodeMaterialConnectionPoint;
  128237. protected _buildBlock(state: NodeMaterialBuildState): this;
  128238. }
  128239. }
  128240. declare module BABYLON {
  128241. /**
  128242. * Block used to get the min of 2 values
  128243. */
  128244. export class MinBlock extends NodeMaterialBlock {
  128245. /**
  128246. * Creates a new MinBlock
  128247. * @param name defines the block name
  128248. */
  128249. constructor(name: string);
  128250. /**
  128251. * Gets the current class name
  128252. * @returns the class name
  128253. */
  128254. getClassName(): string;
  128255. /**
  128256. * Gets the left operand input component
  128257. */
  128258. get left(): NodeMaterialConnectionPoint;
  128259. /**
  128260. * Gets the right operand input component
  128261. */
  128262. get right(): NodeMaterialConnectionPoint;
  128263. /**
  128264. * Gets the output component
  128265. */
  128266. get output(): NodeMaterialConnectionPoint;
  128267. protected _buildBlock(state: NodeMaterialBuildState): this;
  128268. }
  128269. }
  128270. declare module BABYLON {
  128271. /**
  128272. * Block used to get the distance between 2 values
  128273. */
  128274. export class DistanceBlock extends NodeMaterialBlock {
  128275. /**
  128276. * Creates a new DistanceBlock
  128277. * @param name defines the block name
  128278. */
  128279. constructor(name: string);
  128280. /**
  128281. * Gets the current class name
  128282. * @returns the class name
  128283. */
  128284. getClassName(): string;
  128285. /**
  128286. * Gets the left operand input component
  128287. */
  128288. get left(): NodeMaterialConnectionPoint;
  128289. /**
  128290. * Gets the right operand input component
  128291. */
  128292. get right(): NodeMaterialConnectionPoint;
  128293. /**
  128294. * Gets the output component
  128295. */
  128296. get output(): NodeMaterialConnectionPoint;
  128297. protected _buildBlock(state: NodeMaterialBuildState): this;
  128298. }
  128299. }
  128300. declare module BABYLON {
  128301. /**
  128302. * Block used to get the length of a vector
  128303. */
  128304. export class LengthBlock extends NodeMaterialBlock {
  128305. /**
  128306. * Creates a new LengthBlock
  128307. * @param name defines the block name
  128308. */
  128309. constructor(name: string);
  128310. /**
  128311. * Gets the current class name
  128312. * @returns the class name
  128313. */
  128314. getClassName(): string;
  128315. /**
  128316. * Gets the value input component
  128317. */
  128318. get value(): NodeMaterialConnectionPoint;
  128319. /**
  128320. * Gets the output component
  128321. */
  128322. get output(): NodeMaterialConnectionPoint;
  128323. protected _buildBlock(state: NodeMaterialBuildState): this;
  128324. }
  128325. }
  128326. declare module BABYLON {
  128327. /**
  128328. * Block used to get negative version of a value (i.e. x * -1)
  128329. */
  128330. export class NegateBlock extends NodeMaterialBlock {
  128331. /**
  128332. * Creates a new NegateBlock
  128333. * @param name defines the block name
  128334. */
  128335. constructor(name: string);
  128336. /**
  128337. * Gets the current class name
  128338. * @returns the class name
  128339. */
  128340. getClassName(): string;
  128341. /**
  128342. * Gets the value input component
  128343. */
  128344. get value(): NodeMaterialConnectionPoint;
  128345. /**
  128346. * Gets the output component
  128347. */
  128348. get output(): NodeMaterialConnectionPoint;
  128349. protected _buildBlock(state: NodeMaterialBuildState): this;
  128350. }
  128351. }
  128352. declare module BABYLON {
  128353. /**
  128354. * Block used to get the value of the first parameter raised to the power of the second
  128355. */
  128356. export class PowBlock extends NodeMaterialBlock {
  128357. /**
  128358. * Creates a new PowBlock
  128359. * @param name defines the block name
  128360. */
  128361. constructor(name: string);
  128362. /**
  128363. * Gets the current class name
  128364. * @returns the class name
  128365. */
  128366. getClassName(): string;
  128367. /**
  128368. * Gets the value operand input component
  128369. */
  128370. get value(): NodeMaterialConnectionPoint;
  128371. /**
  128372. * Gets the power operand input component
  128373. */
  128374. get power(): NodeMaterialConnectionPoint;
  128375. /**
  128376. * Gets the output component
  128377. */
  128378. get output(): NodeMaterialConnectionPoint;
  128379. protected _buildBlock(state: NodeMaterialBuildState): this;
  128380. }
  128381. }
  128382. declare module BABYLON {
  128383. /**
  128384. * Block used to get a random number
  128385. */
  128386. export class RandomNumberBlock extends NodeMaterialBlock {
  128387. /**
  128388. * Creates a new RandomNumberBlock
  128389. * @param name defines the block name
  128390. */
  128391. constructor(name: string);
  128392. /**
  128393. * Gets the current class name
  128394. * @returns the class name
  128395. */
  128396. getClassName(): string;
  128397. /**
  128398. * Gets the seed input component
  128399. */
  128400. get seed(): NodeMaterialConnectionPoint;
  128401. /**
  128402. * Gets the output component
  128403. */
  128404. get output(): NodeMaterialConnectionPoint;
  128405. protected _buildBlock(state: NodeMaterialBuildState): this;
  128406. }
  128407. }
  128408. declare module BABYLON {
  128409. /**
  128410. * Block used to compute arc tangent of 2 values
  128411. */
  128412. export class ArcTan2Block extends NodeMaterialBlock {
  128413. /**
  128414. * Creates a new ArcTan2Block
  128415. * @param name defines the block name
  128416. */
  128417. constructor(name: string);
  128418. /**
  128419. * Gets the current class name
  128420. * @returns the class name
  128421. */
  128422. getClassName(): string;
  128423. /**
  128424. * Gets the x operand input component
  128425. */
  128426. get x(): NodeMaterialConnectionPoint;
  128427. /**
  128428. * Gets the y operand input component
  128429. */
  128430. get y(): NodeMaterialConnectionPoint;
  128431. /**
  128432. * Gets the output component
  128433. */
  128434. get output(): NodeMaterialConnectionPoint;
  128435. protected _buildBlock(state: NodeMaterialBuildState): this;
  128436. }
  128437. }
  128438. declare module BABYLON {
  128439. /**
  128440. * Block used to smooth step a value
  128441. */
  128442. export class SmoothStepBlock extends NodeMaterialBlock {
  128443. /**
  128444. * Creates a new SmoothStepBlock
  128445. * @param name defines the block name
  128446. */
  128447. constructor(name: string);
  128448. /**
  128449. * Gets the current class name
  128450. * @returns the class name
  128451. */
  128452. getClassName(): string;
  128453. /**
  128454. * Gets the value operand input component
  128455. */
  128456. get value(): NodeMaterialConnectionPoint;
  128457. /**
  128458. * Gets the first edge operand input component
  128459. */
  128460. get edge0(): NodeMaterialConnectionPoint;
  128461. /**
  128462. * Gets the second edge operand input component
  128463. */
  128464. get edge1(): NodeMaterialConnectionPoint;
  128465. /**
  128466. * Gets the output component
  128467. */
  128468. get output(): NodeMaterialConnectionPoint;
  128469. protected _buildBlock(state: NodeMaterialBuildState): this;
  128470. }
  128471. }
  128472. declare module BABYLON {
  128473. /**
  128474. * Block used to get the reciprocal (1 / x) of a value
  128475. */
  128476. export class ReciprocalBlock extends NodeMaterialBlock {
  128477. /**
  128478. * Creates a new ReciprocalBlock
  128479. * @param name defines the block name
  128480. */
  128481. constructor(name: string);
  128482. /**
  128483. * Gets the current class name
  128484. * @returns the class name
  128485. */
  128486. getClassName(): string;
  128487. /**
  128488. * Gets the input component
  128489. */
  128490. get input(): NodeMaterialConnectionPoint;
  128491. /**
  128492. * Gets the output component
  128493. */
  128494. get output(): NodeMaterialConnectionPoint;
  128495. protected _buildBlock(state: NodeMaterialBuildState): this;
  128496. }
  128497. }
  128498. declare module BABYLON {
  128499. /**
  128500. * Block used to replace a color by another one
  128501. */
  128502. export class ReplaceColorBlock extends NodeMaterialBlock {
  128503. /**
  128504. * Creates a new ReplaceColorBlock
  128505. * @param name defines the block name
  128506. */
  128507. constructor(name: string);
  128508. /**
  128509. * Gets the current class name
  128510. * @returns the class name
  128511. */
  128512. getClassName(): string;
  128513. /**
  128514. * Gets the value input component
  128515. */
  128516. get value(): NodeMaterialConnectionPoint;
  128517. /**
  128518. * Gets the reference input component
  128519. */
  128520. get reference(): NodeMaterialConnectionPoint;
  128521. /**
  128522. * Gets the distance input component
  128523. */
  128524. get distance(): NodeMaterialConnectionPoint;
  128525. /**
  128526. * Gets the replacement input component
  128527. */
  128528. get replacement(): NodeMaterialConnectionPoint;
  128529. /**
  128530. * Gets the output component
  128531. */
  128532. get output(): NodeMaterialConnectionPoint;
  128533. protected _buildBlock(state: NodeMaterialBuildState): this;
  128534. }
  128535. }
  128536. declare module BABYLON {
  128537. /**
  128538. * Block used to posterize a value
  128539. * @see https://en.wikipedia.org/wiki/Posterization
  128540. */
  128541. export class PosterizeBlock extends NodeMaterialBlock {
  128542. /**
  128543. * Creates a new PosterizeBlock
  128544. * @param name defines the block name
  128545. */
  128546. constructor(name: string);
  128547. /**
  128548. * Gets the current class name
  128549. * @returns the class name
  128550. */
  128551. getClassName(): string;
  128552. /**
  128553. * Gets the value input component
  128554. */
  128555. get value(): NodeMaterialConnectionPoint;
  128556. /**
  128557. * Gets the steps input component
  128558. */
  128559. get steps(): NodeMaterialConnectionPoint;
  128560. /**
  128561. * Gets the output component
  128562. */
  128563. get output(): NodeMaterialConnectionPoint;
  128564. protected _buildBlock(state: NodeMaterialBuildState): this;
  128565. }
  128566. }
  128567. declare module BABYLON {
  128568. /**
  128569. * Operations supported by the Wave block
  128570. */
  128571. export enum WaveBlockKind {
  128572. /** SawTooth */
  128573. SawTooth = 0,
  128574. /** Square */
  128575. Square = 1,
  128576. /** Triangle */
  128577. Triangle = 2
  128578. }
  128579. /**
  128580. * Block used to apply wave operation to floats
  128581. */
  128582. export class WaveBlock extends NodeMaterialBlock {
  128583. /**
  128584. * Gets or sets the kibnd of wave to be applied by the block
  128585. */
  128586. kind: WaveBlockKind;
  128587. /**
  128588. * Creates a new WaveBlock
  128589. * @param name defines the block name
  128590. */
  128591. constructor(name: string);
  128592. /**
  128593. * Gets the current class name
  128594. * @returns the class name
  128595. */
  128596. getClassName(): string;
  128597. /**
  128598. * Gets the input component
  128599. */
  128600. get input(): NodeMaterialConnectionPoint;
  128601. /**
  128602. * Gets the output component
  128603. */
  128604. get output(): NodeMaterialConnectionPoint;
  128605. protected _buildBlock(state: NodeMaterialBuildState): this;
  128606. serialize(): any;
  128607. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128608. }
  128609. }
  128610. declare module BABYLON {
  128611. /**
  128612. * Class used to store a color step for the GradientBlock
  128613. */
  128614. export class GradientBlockColorStep {
  128615. /**
  128616. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128617. */
  128618. step: number;
  128619. /**
  128620. * Gets or sets the color associated with this step
  128621. */
  128622. color: Color3;
  128623. /**
  128624. * Creates a new GradientBlockColorStep
  128625. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  128626. * @param color defines the color associated with this step
  128627. */
  128628. constructor(
  128629. /**
  128630. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128631. */
  128632. step: number,
  128633. /**
  128634. * Gets or sets the color associated with this step
  128635. */
  128636. color: Color3);
  128637. }
  128638. /**
  128639. * Block used to return a color from a gradient based on an input value between 0 and 1
  128640. */
  128641. export class GradientBlock extends NodeMaterialBlock {
  128642. /**
  128643. * Gets or sets the list of color steps
  128644. */
  128645. colorSteps: GradientBlockColorStep[];
  128646. /**
  128647. * Creates a new GradientBlock
  128648. * @param name defines the block name
  128649. */
  128650. constructor(name: string);
  128651. /**
  128652. * Gets the current class name
  128653. * @returns the class name
  128654. */
  128655. getClassName(): string;
  128656. /**
  128657. * Gets the gradient input component
  128658. */
  128659. get gradient(): NodeMaterialConnectionPoint;
  128660. /**
  128661. * Gets the output component
  128662. */
  128663. get output(): NodeMaterialConnectionPoint;
  128664. private _writeColorConstant;
  128665. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128666. serialize(): any;
  128667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128668. protected _dumpPropertiesCode(): string;
  128669. }
  128670. }
  128671. declare module BABYLON {
  128672. /**
  128673. * Block used to normalize lerp between 2 values
  128674. */
  128675. export class NLerpBlock extends NodeMaterialBlock {
  128676. /**
  128677. * Creates a new NLerpBlock
  128678. * @param name defines the block name
  128679. */
  128680. constructor(name: string);
  128681. /**
  128682. * Gets the current class name
  128683. * @returns the class name
  128684. */
  128685. getClassName(): string;
  128686. /**
  128687. * Gets the left operand input component
  128688. */
  128689. get left(): NodeMaterialConnectionPoint;
  128690. /**
  128691. * Gets the right operand input component
  128692. */
  128693. get right(): NodeMaterialConnectionPoint;
  128694. /**
  128695. * Gets the gradient operand input component
  128696. */
  128697. get gradient(): NodeMaterialConnectionPoint;
  128698. /**
  128699. * Gets the output component
  128700. */
  128701. get output(): NodeMaterialConnectionPoint;
  128702. protected _buildBlock(state: NodeMaterialBuildState): this;
  128703. }
  128704. }
  128705. declare module BABYLON {
  128706. /**
  128707. * block used to Generate a Worley Noise 3D Noise Pattern
  128708. */
  128709. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  128710. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128711. manhattanDistance: boolean;
  128712. /**
  128713. * Creates a new WorleyNoise3DBlock
  128714. * @param name defines the block name
  128715. */
  128716. constructor(name: string);
  128717. /**
  128718. * Gets the current class name
  128719. * @returns the class name
  128720. */
  128721. getClassName(): string;
  128722. /**
  128723. * Gets the seed input component
  128724. */
  128725. get seed(): NodeMaterialConnectionPoint;
  128726. /**
  128727. * Gets the jitter input component
  128728. */
  128729. get jitter(): NodeMaterialConnectionPoint;
  128730. /**
  128731. * Gets the output component
  128732. */
  128733. get output(): NodeMaterialConnectionPoint;
  128734. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128735. /**
  128736. * Exposes the properties to the UI?
  128737. */
  128738. protected _dumpPropertiesCode(): string;
  128739. /**
  128740. * Exposes the properties to the Seralize?
  128741. */
  128742. serialize(): any;
  128743. /**
  128744. * Exposes the properties to the deseralize?
  128745. */
  128746. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128747. }
  128748. }
  128749. declare module BABYLON {
  128750. /**
  128751. * block used to Generate a Simplex Perlin 3d Noise Pattern
  128752. */
  128753. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  128754. /**
  128755. * Creates a new SimplexPerlin3DBlock
  128756. * @param name defines the block name
  128757. */
  128758. constructor(name: string);
  128759. /**
  128760. * Gets the current class name
  128761. * @returns the class name
  128762. */
  128763. getClassName(): string;
  128764. /**
  128765. * Gets the seed operand input component
  128766. */
  128767. get seed(): NodeMaterialConnectionPoint;
  128768. /**
  128769. * Gets the output component
  128770. */
  128771. get output(): NodeMaterialConnectionPoint;
  128772. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128773. }
  128774. }
  128775. declare module BABYLON {
  128776. /**
  128777. * Block used to blend normals
  128778. */
  128779. export class NormalBlendBlock extends NodeMaterialBlock {
  128780. /**
  128781. * Creates a new NormalBlendBlock
  128782. * @param name defines the block name
  128783. */
  128784. constructor(name: string);
  128785. /**
  128786. * Gets the current class name
  128787. * @returns the class name
  128788. */
  128789. getClassName(): string;
  128790. /**
  128791. * Gets the first input component
  128792. */
  128793. get normalMap0(): NodeMaterialConnectionPoint;
  128794. /**
  128795. * Gets the second input component
  128796. */
  128797. get normalMap1(): NodeMaterialConnectionPoint;
  128798. /**
  128799. * Gets the output component
  128800. */
  128801. get output(): NodeMaterialConnectionPoint;
  128802. protected _buildBlock(state: NodeMaterialBuildState): this;
  128803. }
  128804. }
  128805. declare module BABYLON {
  128806. /**
  128807. * Block used to rotate a 2d vector by a given angle
  128808. */
  128809. export class Rotate2dBlock extends NodeMaterialBlock {
  128810. /**
  128811. * Creates a new Rotate2dBlock
  128812. * @param name defines the block name
  128813. */
  128814. constructor(name: string);
  128815. /**
  128816. * Gets the current class name
  128817. * @returns the class name
  128818. */
  128819. getClassName(): string;
  128820. /**
  128821. * Gets the input vector
  128822. */
  128823. get input(): NodeMaterialConnectionPoint;
  128824. /**
  128825. * Gets the input angle
  128826. */
  128827. get angle(): NodeMaterialConnectionPoint;
  128828. /**
  128829. * Gets the output component
  128830. */
  128831. get output(): NodeMaterialConnectionPoint;
  128832. autoConfigure(material: NodeMaterial): void;
  128833. protected _buildBlock(state: NodeMaterialBuildState): this;
  128834. }
  128835. }
  128836. declare module BABYLON {
  128837. /**
  128838. * Block used to get the reflected vector from a direction and a normal
  128839. */
  128840. export class ReflectBlock extends NodeMaterialBlock {
  128841. /**
  128842. * Creates a new ReflectBlock
  128843. * @param name defines the block name
  128844. */
  128845. constructor(name: string);
  128846. /**
  128847. * Gets the current class name
  128848. * @returns the class name
  128849. */
  128850. getClassName(): string;
  128851. /**
  128852. * Gets the incident component
  128853. */
  128854. get incident(): NodeMaterialConnectionPoint;
  128855. /**
  128856. * Gets the normal component
  128857. */
  128858. get normal(): NodeMaterialConnectionPoint;
  128859. /**
  128860. * Gets the output component
  128861. */
  128862. get output(): NodeMaterialConnectionPoint;
  128863. protected _buildBlock(state: NodeMaterialBuildState): this;
  128864. }
  128865. }
  128866. declare module BABYLON {
  128867. /**
  128868. * Block used to get the refracted vector from a direction and a normal
  128869. */
  128870. export class RefractBlock extends NodeMaterialBlock {
  128871. /**
  128872. * Creates a new RefractBlock
  128873. * @param name defines the block name
  128874. */
  128875. constructor(name: string);
  128876. /**
  128877. * Gets the current class name
  128878. * @returns the class name
  128879. */
  128880. getClassName(): string;
  128881. /**
  128882. * Gets the incident component
  128883. */
  128884. get incident(): NodeMaterialConnectionPoint;
  128885. /**
  128886. * Gets the normal component
  128887. */
  128888. get normal(): NodeMaterialConnectionPoint;
  128889. /**
  128890. * Gets the index of refraction component
  128891. */
  128892. get ior(): NodeMaterialConnectionPoint;
  128893. /**
  128894. * Gets the output component
  128895. */
  128896. get output(): NodeMaterialConnectionPoint;
  128897. protected _buildBlock(state: NodeMaterialBuildState): this;
  128898. }
  128899. }
  128900. declare module BABYLON {
  128901. /**
  128902. * Block used to desaturate a color
  128903. */
  128904. export class DesaturateBlock extends NodeMaterialBlock {
  128905. /**
  128906. * Creates a new DesaturateBlock
  128907. * @param name defines the block name
  128908. */
  128909. constructor(name: string);
  128910. /**
  128911. * Gets the current class name
  128912. * @returns the class name
  128913. */
  128914. getClassName(): string;
  128915. /**
  128916. * Gets the color operand input component
  128917. */
  128918. get color(): NodeMaterialConnectionPoint;
  128919. /**
  128920. * Gets the level operand input component
  128921. */
  128922. get level(): NodeMaterialConnectionPoint;
  128923. /**
  128924. * Gets the output component
  128925. */
  128926. get output(): NodeMaterialConnectionPoint;
  128927. protected _buildBlock(state: NodeMaterialBuildState): this;
  128928. }
  128929. }
  128930. declare module BABYLON {
  128931. /**
  128932. * Effect Render Options
  128933. */
  128934. export interface IEffectRendererOptions {
  128935. /**
  128936. * Defines the vertices positions.
  128937. */
  128938. positions?: number[];
  128939. /**
  128940. * Defines the indices.
  128941. */
  128942. indices?: number[];
  128943. }
  128944. /**
  128945. * Helper class to render one or more effects
  128946. */
  128947. export class EffectRenderer {
  128948. private engine;
  128949. private static _DefaultOptions;
  128950. private _vertexBuffers;
  128951. private _indexBuffer;
  128952. private _ringBufferIndex;
  128953. private _ringScreenBuffer;
  128954. private _fullscreenViewport;
  128955. private _getNextFrameBuffer;
  128956. /**
  128957. * Creates an effect renderer
  128958. * @param engine the engine to use for rendering
  128959. * @param options defines the options of the effect renderer
  128960. */
  128961. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  128962. /**
  128963. * Sets the current viewport in normalized coordinates 0-1
  128964. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  128965. */
  128966. setViewport(viewport?: Viewport): void;
  128967. /**
  128968. * Binds the embedded attributes buffer to the effect.
  128969. * @param effect Defines the effect to bind the attributes for
  128970. */
  128971. bindBuffers(effect: Effect): void;
  128972. /**
  128973. * Sets the current effect wrapper to use during draw.
  128974. * The effect needs to be ready before calling this api.
  128975. * This also sets the default full screen position attribute.
  128976. * @param effectWrapper Defines the effect to draw with
  128977. */
  128978. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  128979. /**
  128980. * Draws a full screen quad.
  128981. */
  128982. draw(): void;
  128983. /**
  128984. * renders one or more effects to a specified texture
  128985. * @param effectWrappers list of effects to renderer
  128986. * @param outputTexture texture to draw to, if null it will render to the screen
  128987. */
  128988. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  128989. /**
  128990. * Disposes of the effect renderer
  128991. */
  128992. dispose(): void;
  128993. }
  128994. /**
  128995. * Options to create an EffectWrapper
  128996. */
  128997. interface EffectWrapperCreationOptions {
  128998. /**
  128999. * Engine to use to create the effect
  129000. */
  129001. engine: ThinEngine;
  129002. /**
  129003. * Fragment shader for the effect
  129004. */
  129005. fragmentShader: string;
  129006. /**
  129007. * Vertex shader for the effect
  129008. */
  129009. vertexShader?: string;
  129010. /**
  129011. * Attributes to use in the shader
  129012. */
  129013. attributeNames?: Array<string>;
  129014. /**
  129015. * Uniforms to use in the shader
  129016. */
  129017. uniformNames?: Array<string>;
  129018. /**
  129019. * Texture sampler names to use in the shader
  129020. */
  129021. samplerNames?: Array<string>;
  129022. /**
  129023. * The friendly name of the effect displayed in Spector.
  129024. */
  129025. name?: string;
  129026. }
  129027. /**
  129028. * Wraps an effect to be used for rendering
  129029. */
  129030. export class EffectWrapper {
  129031. /**
  129032. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  129033. */
  129034. onApplyObservable: Observable<{}>;
  129035. /**
  129036. * The underlying effect
  129037. */
  129038. effect: Effect;
  129039. /**
  129040. * Creates an effect to be renderer
  129041. * @param creationOptions options to create the effect
  129042. */
  129043. constructor(creationOptions: EffectWrapperCreationOptions);
  129044. /**
  129045. * Disposes of the effect wrapper
  129046. */
  129047. dispose(): void;
  129048. }
  129049. }
  129050. declare module BABYLON {
  129051. /**
  129052. * Helper class to push actions to a pool of workers.
  129053. */
  129054. export class WorkerPool implements IDisposable {
  129055. private _workerInfos;
  129056. private _pendingActions;
  129057. /**
  129058. * Constructor
  129059. * @param workers Array of workers to use for actions
  129060. */
  129061. constructor(workers: Array<Worker>);
  129062. /**
  129063. * Terminates all workers and clears any pending actions.
  129064. */
  129065. dispose(): void;
  129066. /**
  129067. * Pushes an action to the worker pool. If all the workers are active, the action will be
  129068. * pended until a worker has completed its action.
  129069. * @param action The action to perform. Call onComplete when the action is complete.
  129070. */
  129071. push(action: (worker: Worker, onComplete: () => void) => void): void;
  129072. private _execute;
  129073. }
  129074. }
  129075. declare module BABYLON {
  129076. /**
  129077. * Configuration for Draco compression
  129078. */
  129079. export interface IDracoCompressionConfiguration {
  129080. /**
  129081. * Configuration for the decoder.
  129082. */
  129083. decoder: {
  129084. /**
  129085. * The url to the WebAssembly module.
  129086. */
  129087. wasmUrl?: string;
  129088. /**
  129089. * The url to the WebAssembly binary.
  129090. */
  129091. wasmBinaryUrl?: string;
  129092. /**
  129093. * The url to the fallback JavaScript module.
  129094. */
  129095. fallbackUrl?: string;
  129096. };
  129097. }
  129098. /**
  129099. * Draco compression (https://google.github.io/draco/)
  129100. *
  129101. * This class wraps the Draco module.
  129102. *
  129103. * **Encoder**
  129104. *
  129105. * The encoder is not currently implemented.
  129106. *
  129107. * **Decoder**
  129108. *
  129109. * 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.
  129110. *
  129111. * To update the configuration, use the following code:
  129112. * ```javascript
  129113. * DracoCompression.Configuration = {
  129114. * decoder: {
  129115. * wasmUrl: "<url to the WebAssembly library>",
  129116. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  129117. * fallbackUrl: "<url to the fallback JavaScript library>",
  129118. * }
  129119. * };
  129120. * ```
  129121. *
  129122. * 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.
  129123. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  129124. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  129125. *
  129126. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  129127. * ```javascript
  129128. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  129129. * ```
  129130. *
  129131. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  129132. */
  129133. export class DracoCompression implements IDisposable {
  129134. private _workerPoolPromise?;
  129135. private _decoderModulePromise?;
  129136. /**
  129137. * The configuration. Defaults to the following urls:
  129138. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  129139. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  129140. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  129141. */
  129142. static Configuration: IDracoCompressionConfiguration;
  129143. /**
  129144. * Returns true if the decoder configuration is available.
  129145. */
  129146. static get DecoderAvailable(): boolean;
  129147. /**
  129148. * Default number of workers to create when creating the draco compression object.
  129149. */
  129150. static DefaultNumWorkers: number;
  129151. private static GetDefaultNumWorkers;
  129152. private static _Default;
  129153. /**
  129154. * Default instance for the draco compression object.
  129155. */
  129156. static get Default(): DracoCompression;
  129157. /**
  129158. * Constructor
  129159. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  129160. */
  129161. constructor(numWorkers?: number);
  129162. /**
  129163. * Stop all async operations and release resources.
  129164. */
  129165. dispose(): void;
  129166. /**
  129167. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  129168. * @returns a promise that resolves when ready
  129169. */
  129170. whenReadyAsync(): Promise<void>;
  129171. /**
  129172. * Decode Draco compressed mesh data to vertex data.
  129173. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  129174. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  129175. * @returns A promise that resolves with the decoded vertex data
  129176. */
  129177. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  129178. [kind: string]: number;
  129179. }): Promise<VertexData>;
  129180. }
  129181. }
  129182. declare module BABYLON {
  129183. /**
  129184. * Class for building Constructive Solid Geometry
  129185. */
  129186. export class CSG {
  129187. private polygons;
  129188. /**
  129189. * The world matrix
  129190. */
  129191. matrix: Matrix;
  129192. /**
  129193. * Stores the position
  129194. */
  129195. position: Vector3;
  129196. /**
  129197. * Stores the rotation
  129198. */
  129199. rotation: Vector3;
  129200. /**
  129201. * Stores the rotation quaternion
  129202. */
  129203. rotationQuaternion: Nullable<Quaternion>;
  129204. /**
  129205. * Stores the scaling vector
  129206. */
  129207. scaling: Vector3;
  129208. /**
  129209. * Convert the Mesh to CSG
  129210. * @param mesh The Mesh to convert to CSG
  129211. * @returns A new CSG from the Mesh
  129212. */
  129213. static FromMesh(mesh: Mesh): CSG;
  129214. /**
  129215. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  129216. * @param polygons Polygons used to construct a CSG solid
  129217. */
  129218. private static FromPolygons;
  129219. /**
  129220. * Clones, or makes a deep copy, of the CSG
  129221. * @returns A new CSG
  129222. */
  129223. clone(): CSG;
  129224. /**
  129225. * Unions this CSG with another CSG
  129226. * @param csg The CSG to union against this CSG
  129227. * @returns The unioned CSG
  129228. */
  129229. union(csg: CSG): CSG;
  129230. /**
  129231. * Unions this CSG with another CSG in place
  129232. * @param csg The CSG to union against this CSG
  129233. */
  129234. unionInPlace(csg: CSG): void;
  129235. /**
  129236. * Subtracts this CSG with another CSG
  129237. * @param csg The CSG to subtract against this CSG
  129238. * @returns A new CSG
  129239. */
  129240. subtract(csg: CSG): CSG;
  129241. /**
  129242. * Subtracts this CSG with another CSG in place
  129243. * @param csg The CSG to subtact against this CSG
  129244. */
  129245. subtractInPlace(csg: CSG): void;
  129246. /**
  129247. * Intersect this CSG with another CSG
  129248. * @param csg The CSG to intersect against this CSG
  129249. * @returns A new CSG
  129250. */
  129251. intersect(csg: CSG): CSG;
  129252. /**
  129253. * Intersects this CSG with another CSG in place
  129254. * @param csg The CSG to intersect against this CSG
  129255. */
  129256. intersectInPlace(csg: CSG): void;
  129257. /**
  129258. * Return a new CSG solid with solid and empty space switched. This solid is
  129259. * not modified.
  129260. * @returns A new CSG solid with solid and empty space switched
  129261. */
  129262. inverse(): CSG;
  129263. /**
  129264. * Inverses the CSG in place
  129265. */
  129266. inverseInPlace(): void;
  129267. /**
  129268. * This is used to keep meshes transformations so they can be restored
  129269. * when we build back a Babylon Mesh
  129270. * NB : All CSG operations are performed in world coordinates
  129271. * @param csg The CSG to copy the transform attributes from
  129272. * @returns This CSG
  129273. */
  129274. copyTransformAttributes(csg: CSG): CSG;
  129275. /**
  129276. * Build Raw mesh from CSG
  129277. * Coordinates here are in world space
  129278. * @param name The name of the mesh geometry
  129279. * @param scene The Scene
  129280. * @param keepSubMeshes Specifies if the submeshes should be kept
  129281. * @returns A new Mesh
  129282. */
  129283. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129284. /**
  129285. * Build Mesh from CSG taking material and transforms into account
  129286. * @param name The name of the Mesh
  129287. * @param material The material of the Mesh
  129288. * @param scene The Scene
  129289. * @param keepSubMeshes Specifies if submeshes should be kept
  129290. * @returns The new Mesh
  129291. */
  129292. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129293. }
  129294. }
  129295. declare module BABYLON {
  129296. /**
  129297. * Class used to create a trail following a mesh
  129298. */
  129299. export class TrailMesh extends Mesh {
  129300. private _generator;
  129301. private _autoStart;
  129302. private _running;
  129303. private _diameter;
  129304. private _length;
  129305. private _sectionPolygonPointsCount;
  129306. private _sectionVectors;
  129307. private _sectionNormalVectors;
  129308. private _beforeRenderObserver;
  129309. /**
  129310. * @constructor
  129311. * @param name The value used by scene.getMeshByName() to do a lookup.
  129312. * @param generator The mesh to generate a trail.
  129313. * @param scene The scene to add this mesh to.
  129314. * @param diameter Diameter of trailing mesh. Default is 1.
  129315. * @param length Length of trailing mesh. Default is 60.
  129316. * @param autoStart Automatically start trailing mesh. Default true.
  129317. */
  129318. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  129319. /**
  129320. * "TrailMesh"
  129321. * @returns "TrailMesh"
  129322. */
  129323. getClassName(): string;
  129324. private _createMesh;
  129325. /**
  129326. * Start trailing mesh.
  129327. */
  129328. start(): void;
  129329. /**
  129330. * Stop trailing mesh.
  129331. */
  129332. stop(): void;
  129333. /**
  129334. * Update trailing mesh geometry.
  129335. */
  129336. update(): void;
  129337. /**
  129338. * Returns a new TrailMesh object.
  129339. * @param name is a string, the name given to the new mesh
  129340. * @param newGenerator use new generator object for cloned trail mesh
  129341. * @returns a new mesh
  129342. */
  129343. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  129344. /**
  129345. * Serializes this trail mesh
  129346. * @param serializationObject object to write serialization to
  129347. */
  129348. serialize(serializationObject: any): void;
  129349. /**
  129350. * Parses a serialized trail mesh
  129351. * @param parsedMesh the serialized mesh
  129352. * @param scene the scene to create the trail mesh in
  129353. * @returns the created trail mesh
  129354. */
  129355. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  129356. }
  129357. }
  129358. declare module BABYLON {
  129359. /**
  129360. * Class containing static functions to help procedurally build meshes
  129361. */
  129362. export class TiledBoxBuilder {
  129363. /**
  129364. * Creates a box mesh
  129365. * 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)
  129366. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129370. * @param name defines the name of the mesh
  129371. * @param options defines the options used to create the mesh
  129372. * @param scene defines the hosting scene
  129373. * @returns the box mesh
  129374. */
  129375. static CreateTiledBox(name: string, options: {
  129376. pattern?: number;
  129377. width?: number;
  129378. height?: number;
  129379. depth?: number;
  129380. tileSize?: number;
  129381. tileWidth?: number;
  129382. tileHeight?: number;
  129383. alignHorizontal?: number;
  129384. alignVertical?: number;
  129385. faceUV?: Vector4[];
  129386. faceColors?: Color4[];
  129387. sideOrientation?: number;
  129388. updatable?: boolean;
  129389. }, scene?: Nullable<Scene>): Mesh;
  129390. }
  129391. }
  129392. declare module BABYLON {
  129393. /**
  129394. * Class containing static functions to help procedurally build meshes
  129395. */
  129396. export class TorusKnotBuilder {
  129397. /**
  129398. * Creates a torus knot mesh
  129399. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129400. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129401. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129402. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129406. * @param name defines the name of the mesh
  129407. * @param options defines the options used to create the mesh
  129408. * @param scene defines the hosting scene
  129409. * @returns the torus knot mesh
  129410. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129411. */
  129412. static CreateTorusKnot(name: string, options: {
  129413. radius?: number;
  129414. tube?: number;
  129415. radialSegments?: number;
  129416. tubularSegments?: number;
  129417. p?: number;
  129418. q?: number;
  129419. updatable?: boolean;
  129420. sideOrientation?: number;
  129421. frontUVs?: Vector4;
  129422. backUVs?: Vector4;
  129423. }, scene: any): Mesh;
  129424. }
  129425. }
  129426. declare module BABYLON {
  129427. /**
  129428. * Polygon
  129429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  129430. */
  129431. export class Polygon {
  129432. /**
  129433. * Creates a rectangle
  129434. * @param xmin bottom X coord
  129435. * @param ymin bottom Y coord
  129436. * @param xmax top X coord
  129437. * @param ymax top Y coord
  129438. * @returns points that make the resulting rectation
  129439. */
  129440. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  129441. /**
  129442. * Creates a circle
  129443. * @param radius radius of circle
  129444. * @param cx scale in x
  129445. * @param cy scale in y
  129446. * @param numberOfSides number of sides that make up the circle
  129447. * @returns points that make the resulting circle
  129448. */
  129449. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  129450. /**
  129451. * Creates a polygon from input string
  129452. * @param input Input polygon data
  129453. * @returns the parsed points
  129454. */
  129455. static Parse(input: string): Vector2[];
  129456. /**
  129457. * Starts building a polygon from x and y coordinates
  129458. * @param x x coordinate
  129459. * @param y y coordinate
  129460. * @returns the started path2
  129461. */
  129462. static StartingAt(x: number, y: number): Path2;
  129463. }
  129464. /**
  129465. * Builds a polygon
  129466. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  129467. */
  129468. export class PolygonMeshBuilder {
  129469. private _points;
  129470. private _outlinepoints;
  129471. private _holes;
  129472. private _name;
  129473. private _scene;
  129474. private _epoints;
  129475. private _eholes;
  129476. private _addToepoint;
  129477. /**
  129478. * Babylon reference to the earcut plugin.
  129479. */
  129480. bjsEarcut: any;
  129481. /**
  129482. * Creates a PolygonMeshBuilder
  129483. * @param name name of the builder
  129484. * @param contours Path of the polygon
  129485. * @param scene scene to add to when creating the mesh
  129486. * @param earcutInjection can be used to inject your own earcut reference
  129487. */
  129488. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  129489. /**
  129490. * Adds a whole within the polygon
  129491. * @param hole Array of points defining the hole
  129492. * @returns this
  129493. */
  129494. addHole(hole: Vector2[]): PolygonMeshBuilder;
  129495. /**
  129496. * Creates the polygon
  129497. * @param updatable If the mesh should be updatable
  129498. * @param depth The depth of the mesh created
  129499. * @returns the created mesh
  129500. */
  129501. build(updatable?: boolean, depth?: number): Mesh;
  129502. /**
  129503. * Creates the polygon
  129504. * @param depth The depth of the mesh created
  129505. * @returns the created VertexData
  129506. */
  129507. buildVertexData(depth?: number): VertexData;
  129508. /**
  129509. * Adds a side to the polygon
  129510. * @param positions points that make the polygon
  129511. * @param normals normals of the polygon
  129512. * @param uvs uvs of the polygon
  129513. * @param indices indices of the polygon
  129514. * @param bounds bounds of the polygon
  129515. * @param points points of the polygon
  129516. * @param depth depth of the polygon
  129517. * @param flip flip of the polygon
  129518. */
  129519. private addSide;
  129520. }
  129521. }
  129522. declare module BABYLON {
  129523. /**
  129524. * Class containing static functions to help procedurally build meshes
  129525. */
  129526. export class PolygonBuilder {
  129527. /**
  129528. * Creates a polygon mesh
  129529. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  129530. * * 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
  129531. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  129534. * * Remember you can only change the shape positions, not their number when updating a polygon
  129535. * @param name defines the name of the mesh
  129536. * @param options defines the options used to create the mesh
  129537. * @param scene defines the hosting scene
  129538. * @param earcutInjection can be used to inject your own earcut reference
  129539. * @returns the polygon mesh
  129540. */
  129541. static CreatePolygon(name: string, options: {
  129542. shape: Vector3[];
  129543. holes?: Vector3[][];
  129544. depth?: number;
  129545. faceUV?: Vector4[];
  129546. faceColors?: Color4[];
  129547. updatable?: boolean;
  129548. sideOrientation?: number;
  129549. frontUVs?: Vector4;
  129550. backUVs?: Vector4;
  129551. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129552. /**
  129553. * Creates an extruded polygon mesh, with depth in the Y direction.
  129554. * * 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)
  129555. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129556. * @param name defines the name of the mesh
  129557. * @param options defines the options used to create the mesh
  129558. * @param scene defines the hosting scene
  129559. * @param earcutInjection can be used to inject your own earcut reference
  129560. * @returns the polygon mesh
  129561. */
  129562. static ExtrudePolygon(name: string, options: {
  129563. shape: Vector3[];
  129564. holes?: Vector3[][];
  129565. depth?: number;
  129566. faceUV?: Vector4[];
  129567. faceColors?: Color4[];
  129568. updatable?: boolean;
  129569. sideOrientation?: number;
  129570. frontUVs?: Vector4;
  129571. backUVs?: Vector4;
  129572. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129573. }
  129574. }
  129575. declare module BABYLON {
  129576. /**
  129577. * Class containing static functions to help procedurally build meshes
  129578. */
  129579. export class LatheBuilder {
  129580. /**
  129581. * Creates lathe mesh.
  129582. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  129583. * * 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
  129584. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  129585. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  129586. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  129587. * * 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
  129588. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  129589. * * 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
  129590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129594. * @param name defines the name of the mesh
  129595. * @param options defines the options used to create the mesh
  129596. * @param scene defines the hosting scene
  129597. * @returns the lathe mesh
  129598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  129599. */
  129600. static CreateLathe(name: string, options: {
  129601. shape: Vector3[];
  129602. radius?: number;
  129603. tessellation?: number;
  129604. clip?: number;
  129605. arc?: number;
  129606. closed?: boolean;
  129607. updatable?: boolean;
  129608. sideOrientation?: number;
  129609. frontUVs?: Vector4;
  129610. backUVs?: Vector4;
  129611. cap?: number;
  129612. invertUV?: boolean;
  129613. }, scene?: Nullable<Scene>): Mesh;
  129614. }
  129615. }
  129616. declare module BABYLON {
  129617. /**
  129618. * Class containing static functions to help procedurally build meshes
  129619. */
  129620. export class TiledPlaneBuilder {
  129621. /**
  129622. * Creates a tiled plane mesh
  129623. * * The parameter `pattern` will, depending on value, do nothing or
  129624. * * * flip (reflect about central vertical) alternate tiles across and up
  129625. * * * flip every tile on alternate rows
  129626. * * * rotate (180 degs) alternate tiles across and up
  129627. * * * rotate every tile on alternate rows
  129628. * * * flip and rotate alternate tiles across and up
  129629. * * * flip and rotate every tile on alternate rows
  129630. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  129631. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  129632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129634. * * 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)
  129635. * * 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)
  129636. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129637. * @param name defines the name of the mesh
  129638. * @param options defines the options used to create the mesh
  129639. * @param scene defines the hosting scene
  129640. * @returns the box mesh
  129641. */
  129642. static CreateTiledPlane(name: string, options: {
  129643. pattern?: number;
  129644. tileSize?: number;
  129645. tileWidth?: number;
  129646. tileHeight?: number;
  129647. size?: number;
  129648. width?: number;
  129649. height?: number;
  129650. alignHorizontal?: number;
  129651. alignVertical?: number;
  129652. sideOrientation?: number;
  129653. frontUVs?: Vector4;
  129654. backUVs?: Vector4;
  129655. updatable?: boolean;
  129656. }, scene?: Nullable<Scene>): Mesh;
  129657. }
  129658. }
  129659. declare module BABYLON {
  129660. /**
  129661. * Class containing static functions to help procedurally build meshes
  129662. */
  129663. export class TubeBuilder {
  129664. /**
  129665. * Creates a tube mesh.
  129666. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129667. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  129668. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  129669. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  129670. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  129671. * * 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)
  129672. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  129673. * * 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
  129674. * * 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
  129675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129679. * @param name defines the name of the mesh
  129680. * @param options defines the options used to create the mesh
  129681. * @param scene defines the hosting scene
  129682. * @returns the tube mesh
  129683. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129684. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  129685. */
  129686. static CreateTube(name: string, options: {
  129687. path: Vector3[];
  129688. radius?: number;
  129689. tessellation?: number;
  129690. radiusFunction?: {
  129691. (i: number, distance: number): number;
  129692. };
  129693. cap?: number;
  129694. arc?: number;
  129695. updatable?: boolean;
  129696. sideOrientation?: number;
  129697. frontUVs?: Vector4;
  129698. backUVs?: Vector4;
  129699. instance?: Mesh;
  129700. invertUV?: boolean;
  129701. }, scene?: Nullable<Scene>): Mesh;
  129702. }
  129703. }
  129704. declare module BABYLON {
  129705. /**
  129706. * Class containing static functions to help procedurally build meshes
  129707. */
  129708. export class IcoSphereBuilder {
  129709. /**
  129710. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129711. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129712. * * 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`)
  129713. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129714. * * 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
  129715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129718. * @param name defines the name of the mesh
  129719. * @param options defines the options used to create the mesh
  129720. * @param scene defines the hosting scene
  129721. * @returns the icosahedron mesh
  129722. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129723. */
  129724. static CreateIcoSphere(name: string, options: {
  129725. radius?: number;
  129726. radiusX?: number;
  129727. radiusY?: number;
  129728. radiusZ?: number;
  129729. flat?: boolean;
  129730. subdivisions?: number;
  129731. sideOrientation?: number;
  129732. frontUVs?: Vector4;
  129733. backUVs?: Vector4;
  129734. updatable?: boolean;
  129735. }, scene?: Nullable<Scene>): Mesh;
  129736. }
  129737. }
  129738. declare module BABYLON {
  129739. /**
  129740. * Class containing static functions to help procedurally build meshes
  129741. */
  129742. export class DecalBuilder {
  129743. /**
  129744. * Creates a decal mesh.
  129745. * 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
  129746. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  129747. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  129748. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  129749. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  129750. * @param name defines the name of the mesh
  129751. * @param sourceMesh defines the mesh where the decal must be applied
  129752. * @param options defines the options used to create the mesh
  129753. * @param scene defines the hosting scene
  129754. * @returns the decal mesh
  129755. * @see https://doc.babylonjs.com/how_to/decals
  129756. */
  129757. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  129758. position?: Vector3;
  129759. normal?: Vector3;
  129760. size?: Vector3;
  129761. angle?: number;
  129762. }): Mesh;
  129763. }
  129764. }
  129765. declare module BABYLON {
  129766. /**
  129767. * Class containing static functions to help procedurally build meshes
  129768. */
  129769. export class MeshBuilder {
  129770. /**
  129771. * Creates a box mesh
  129772. * * The parameter `size` sets the size (float) of each box side (default 1)
  129773. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129774. * * 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)
  129775. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129779. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129780. * @param name defines the name of the mesh
  129781. * @param options defines the options used to create the mesh
  129782. * @param scene defines the hosting scene
  129783. * @returns the box mesh
  129784. */
  129785. static CreateBox(name: string, options: {
  129786. size?: number;
  129787. width?: number;
  129788. height?: number;
  129789. depth?: number;
  129790. faceUV?: Vector4[];
  129791. faceColors?: Color4[];
  129792. sideOrientation?: number;
  129793. frontUVs?: Vector4;
  129794. backUVs?: Vector4;
  129795. updatable?: boolean;
  129796. }, scene?: Nullable<Scene>): Mesh;
  129797. /**
  129798. * Creates a tiled box mesh
  129799. * * faceTiles sets the pattern, tile size and number of tiles for a face
  129800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129801. * @param name defines the name of the mesh
  129802. * @param options defines the options used to create the mesh
  129803. * @param scene defines the hosting scene
  129804. * @returns the tiled box mesh
  129805. */
  129806. static CreateTiledBox(name: string, options: {
  129807. pattern?: number;
  129808. size?: number;
  129809. width?: number;
  129810. height?: number;
  129811. depth: number;
  129812. tileSize?: number;
  129813. tileWidth?: number;
  129814. tileHeight?: number;
  129815. faceUV?: Vector4[];
  129816. faceColors?: Color4[];
  129817. alignHorizontal?: number;
  129818. alignVertical?: number;
  129819. sideOrientation?: number;
  129820. updatable?: boolean;
  129821. }, scene?: Nullable<Scene>): Mesh;
  129822. /**
  129823. * Creates a sphere mesh
  129824. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  129825. * * 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`)
  129826. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  129827. * * 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
  129828. * * 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)
  129829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129832. * @param name defines the name of the mesh
  129833. * @param options defines the options used to create the mesh
  129834. * @param scene defines the hosting scene
  129835. * @returns the sphere mesh
  129836. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  129837. */
  129838. static CreateSphere(name: string, options: {
  129839. segments?: number;
  129840. diameter?: number;
  129841. diameterX?: number;
  129842. diameterY?: number;
  129843. diameterZ?: number;
  129844. arc?: number;
  129845. slice?: number;
  129846. sideOrientation?: number;
  129847. frontUVs?: Vector4;
  129848. backUVs?: Vector4;
  129849. updatable?: boolean;
  129850. }, scene?: Nullable<Scene>): Mesh;
  129851. /**
  129852. * Creates a plane polygonal mesh. By default, this is a disc
  129853. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  129854. * * 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
  129855. * * 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
  129856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129859. * @param name defines the name of the mesh
  129860. * @param options defines the options used to create the mesh
  129861. * @param scene defines the hosting scene
  129862. * @returns the plane polygonal mesh
  129863. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  129864. */
  129865. static CreateDisc(name: string, options: {
  129866. radius?: number;
  129867. tessellation?: number;
  129868. arc?: number;
  129869. updatable?: boolean;
  129870. sideOrientation?: number;
  129871. frontUVs?: Vector4;
  129872. backUVs?: Vector4;
  129873. }, scene?: Nullable<Scene>): Mesh;
  129874. /**
  129875. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129876. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129877. * * 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`)
  129878. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129879. * * 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
  129880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129883. * @param name defines the name of the mesh
  129884. * @param options defines the options used to create the mesh
  129885. * @param scene defines the hosting scene
  129886. * @returns the icosahedron mesh
  129887. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129888. */
  129889. static CreateIcoSphere(name: string, options: {
  129890. radius?: number;
  129891. radiusX?: number;
  129892. radiusY?: number;
  129893. radiusZ?: number;
  129894. flat?: boolean;
  129895. subdivisions?: number;
  129896. sideOrientation?: number;
  129897. frontUVs?: Vector4;
  129898. backUVs?: Vector4;
  129899. updatable?: boolean;
  129900. }, scene?: Nullable<Scene>): Mesh;
  129901. /**
  129902. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129903. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129904. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129905. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129906. * * 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
  129907. * * 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
  129908. * * 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
  129909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129911. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129912. * * 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
  129913. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129914. * * 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
  129915. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129917. * @param name defines the name of the mesh
  129918. * @param options defines the options used to create the mesh
  129919. * @param scene defines the hosting scene
  129920. * @returns the ribbon mesh
  129921. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129923. */
  129924. static CreateRibbon(name: string, options: {
  129925. pathArray: Vector3[][];
  129926. closeArray?: boolean;
  129927. closePath?: boolean;
  129928. offset?: number;
  129929. updatable?: boolean;
  129930. sideOrientation?: number;
  129931. frontUVs?: Vector4;
  129932. backUVs?: Vector4;
  129933. instance?: Mesh;
  129934. invertUV?: boolean;
  129935. uvs?: Vector2[];
  129936. colors?: Color4[];
  129937. }, scene?: Nullable<Scene>): Mesh;
  129938. /**
  129939. * Creates a cylinder or a cone mesh
  129940. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  129941. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  129942. * * 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.
  129943. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  129944. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  129945. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  129946. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  129947. * * 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).
  129948. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  129949. * * 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).
  129950. * * 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
  129951. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  129952. * * 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
  129953. * * 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.
  129954. * * If `enclose` is false, a ring surface is one element.
  129955. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  129956. * * 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
  129957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129960. * @param name defines the name of the mesh
  129961. * @param options defines the options used to create the mesh
  129962. * @param scene defines the hosting scene
  129963. * @returns the cylinder mesh
  129964. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  129965. */
  129966. static CreateCylinder(name: string, options: {
  129967. height?: number;
  129968. diameterTop?: number;
  129969. diameterBottom?: number;
  129970. diameter?: number;
  129971. tessellation?: number;
  129972. subdivisions?: number;
  129973. arc?: number;
  129974. faceColors?: Color4[];
  129975. faceUV?: Vector4[];
  129976. updatable?: boolean;
  129977. hasRings?: boolean;
  129978. enclose?: boolean;
  129979. cap?: number;
  129980. sideOrientation?: number;
  129981. frontUVs?: Vector4;
  129982. backUVs?: Vector4;
  129983. }, scene?: Nullable<Scene>): Mesh;
  129984. /**
  129985. * Creates a torus mesh
  129986. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  129987. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  129988. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  129989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129992. * @param name defines the name of the mesh
  129993. * @param options defines the options used to create the mesh
  129994. * @param scene defines the hosting scene
  129995. * @returns the torus mesh
  129996. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  129997. */
  129998. static CreateTorus(name: string, options: {
  129999. diameter?: number;
  130000. thickness?: number;
  130001. tessellation?: number;
  130002. updatable?: boolean;
  130003. sideOrientation?: number;
  130004. frontUVs?: Vector4;
  130005. backUVs?: Vector4;
  130006. }, scene?: Nullable<Scene>): Mesh;
  130007. /**
  130008. * Creates a torus knot mesh
  130009. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  130010. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  130011. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  130012. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  130013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130016. * @param name defines the name of the mesh
  130017. * @param options defines the options used to create the mesh
  130018. * @param scene defines the hosting scene
  130019. * @returns the torus knot mesh
  130020. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  130021. */
  130022. static CreateTorusKnot(name: string, options: {
  130023. radius?: number;
  130024. tube?: number;
  130025. radialSegments?: number;
  130026. tubularSegments?: number;
  130027. p?: number;
  130028. q?: number;
  130029. updatable?: boolean;
  130030. sideOrientation?: number;
  130031. frontUVs?: Vector4;
  130032. backUVs?: Vector4;
  130033. }, scene?: Nullable<Scene>): Mesh;
  130034. /**
  130035. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  130036. * * 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
  130037. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  130038. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  130039. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  130040. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  130041. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  130042. * * 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
  130043. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  130044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  130046. * @param name defines the name of the new line system
  130047. * @param options defines the options used to create the line system
  130048. * @param scene defines the hosting scene
  130049. * @returns a new line system mesh
  130050. */
  130051. static CreateLineSystem(name: string, options: {
  130052. lines: Vector3[][];
  130053. updatable?: boolean;
  130054. instance?: Nullable<LinesMesh>;
  130055. colors?: Nullable<Color4[][]>;
  130056. useVertexAlpha?: boolean;
  130057. }, scene: Nullable<Scene>): LinesMesh;
  130058. /**
  130059. * Creates a line mesh
  130060. * 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
  130061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130062. * * The parameter `points` is an array successive Vector3
  130063. * * 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
  130064. * * The optional parameter `colors` is an array of successive Color4, one per line point
  130065. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  130066. * * When updating an instance, remember that only point positions can change, not the number of points
  130067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  130069. * @param name defines the name of the new line system
  130070. * @param options defines the options used to create the line system
  130071. * @param scene defines the hosting scene
  130072. * @returns a new line mesh
  130073. */
  130074. static CreateLines(name: string, options: {
  130075. points: Vector3[];
  130076. updatable?: boolean;
  130077. instance?: Nullable<LinesMesh>;
  130078. colors?: Color4[];
  130079. useVertexAlpha?: boolean;
  130080. }, scene?: Nullable<Scene>): LinesMesh;
  130081. /**
  130082. * Creates a dashed line mesh
  130083. * * 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
  130084. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130085. * * The parameter `points` is an array successive Vector3
  130086. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  130087. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  130088. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  130089. * * 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
  130090. * * When updating an instance, remember that only point positions can change, not the number of points
  130091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130092. * @param name defines the name of the mesh
  130093. * @param options defines the options used to create the mesh
  130094. * @param scene defines the hosting scene
  130095. * @returns the dashed line mesh
  130096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  130097. */
  130098. static CreateDashedLines(name: string, options: {
  130099. points: Vector3[];
  130100. dashSize?: number;
  130101. gapSize?: number;
  130102. dashNb?: number;
  130103. updatable?: boolean;
  130104. instance?: LinesMesh;
  130105. }, scene?: Nullable<Scene>): LinesMesh;
  130106. /**
  130107. * 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.
  130108. * * 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.
  130109. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130110. * * 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.
  130111. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130112. * * 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
  130113. * * 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
  130114. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130117. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130119. * @param name defines the name of the mesh
  130120. * @param options defines the options used to create the mesh
  130121. * @param scene defines the hosting scene
  130122. * @returns the extruded shape mesh
  130123. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130125. */
  130126. static ExtrudeShape(name: string, options: {
  130127. shape: Vector3[];
  130128. path: Vector3[];
  130129. scale?: number;
  130130. rotation?: number;
  130131. cap?: number;
  130132. updatable?: boolean;
  130133. sideOrientation?: number;
  130134. frontUVs?: Vector4;
  130135. backUVs?: Vector4;
  130136. instance?: Mesh;
  130137. invertUV?: boolean;
  130138. }, scene?: Nullable<Scene>): Mesh;
  130139. /**
  130140. * Creates an custom extruded shape mesh.
  130141. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130142. * * 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.
  130143. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130144. * * 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
  130145. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130146. * * 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
  130147. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130148. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130149. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130150. * * 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
  130151. * * 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
  130152. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130157. * @param name defines the name of the mesh
  130158. * @param options defines the options used to create the mesh
  130159. * @param scene defines the hosting scene
  130160. * @returns the custom extruded shape mesh
  130161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130162. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130163. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130164. */
  130165. static ExtrudeShapeCustom(name: string, options: {
  130166. shape: Vector3[];
  130167. path: Vector3[];
  130168. scaleFunction?: any;
  130169. rotationFunction?: any;
  130170. ribbonCloseArray?: boolean;
  130171. ribbonClosePath?: boolean;
  130172. cap?: number;
  130173. updatable?: boolean;
  130174. sideOrientation?: number;
  130175. frontUVs?: Vector4;
  130176. backUVs?: Vector4;
  130177. instance?: Mesh;
  130178. invertUV?: boolean;
  130179. }, scene?: Nullable<Scene>): Mesh;
  130180. /**
  130181. * Creates lathe mesh.
  130182. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  130183. * * 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
  130184. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  130185. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  130186. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  130187. * * 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
  130188. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  130189. * * 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
  130190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130194. * @param name defines the name of the mesh
  130195. * @param options defines the options used to create the mesh
  130196. * @param scene defines the hosting scene
  130197. * @returns the lathe mesh
  130198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  130199. */
  130200. static CreateLathe(name: string, options: {
  130201. shape: Vector3[];
  130202. radius?: number;
  130203. tessellation?: number;
  130204. clip?: number;
  130205. arc?: number;
  130206. closed?: boolean;
  130207. updatable?: boolean;
  130208. sideOrientation?: number;
  130209. frontUVs?: Vector4;
  130210. backUVs?: Vector4;
  130211. cap?: number;
  130212. invertUV?: boolean;
  130213. }, scene?: Nullable<Scene>): Mesh;
  130214. /**
  130215. * Creates a tiled plane mesh
  130216. * * You can set a limited pattern arrangement with the tiles
  130217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130220. * @param name defines the name of the mesh
  130221. * @param options defines the options used to create the mesh
  130222. * @param scene defines the hosting scene
  130223. * @returns the plane mesh
  130224. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130225. */
  130226. static CreateTiledPlane(name: string, options: {
  130227. pattern?: number;
  130228. tileSize?: number;
  130229. tileWidth?: number;
  130230. tileHeight?: number;
  130231. size?: number;
  130232. width?: number;
  130233. height?: number;
  130234. alignHorizontal?: number;
  130235. alignVertical?: number;
  130236. sideOrientation?: number;
  130237. frontUVs?: Vector4;
  130238. backUVs?: Vector4;
  130239. updatable?: boolean;
  130240. }, scene?: Nullable<Scene>): Mesh;
  130241. /**
  130242. * Creates a plane mesh
  130243. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  130244. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  130245. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  130246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130249. * @param name defines the name of the mesh
  130250. * @param options defines the options used to create the mesh
  130251. * @param scene defines the hosting scene
  130252. * @returns the plane mesh
  130253. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130254. */
  130255. static CreatePlane(name: string, options: {
  130256. size?: number;
  130257. width?: number;
  130258. height?: number;
  130259. sideOrientation?: number;
  130260. frontUVs?: Vector4;
  130261. backUVs?: Vector4;
  130262. updatable?: boolean;
  130263. sourcePlane?: Plane;
  130264. }, scene?: Nullable<Scene>): Mesh;
  130265. /**
  130266. * Creates a ground mesh
  130267. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130268. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130270. * @param name defines the name of the mesh
  130271. * @param options defines the options used to create the mesh
  130272. * @param scene defines the hosting scene
  130273. * @returns the ground mesh
  130274. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130275. */
  130276. static CreateGround(name: string, options: {
  130277. width?: number;
  130278. height?: number;
  130279. subdivisions?: number;
  130280. subdivisionsX?: number;
  130281. subdivisionsY?: number;
  130282. updatable?: boolean;
  130283. }, scene?: Nullable<Scene>): Mesh;
  130284. /**
  130285. * Creates a tiled ground mesh
  130286. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130287. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130288. * * 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
  130289. * * 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
  130290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130291. * @param name defines the name of the mesh
  130292. * @param options defines the options used to create the mesh
  130293. * @param scene defines the hosting scene
  130294. * @returns the tiled ground mesh
  130295. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130296. */
  130297. static CreateTiledGround(name: string, options: {
  130298. xmin: number;
  130299. zmin: number;
  130300. xmax: number;
  130301. zmax: number;
  130302. subdivisions?: {
  130303. w: number;
  130304. h: number;
  130305. };
  130306. precision?: {
  130307. w: number;
  130308. h: number;
  130309. };
  130310. updatable?: boolean;
  130311. }, scene?: Nullable<Scene>): Mesh;
  130312. /**
  130313. * Creates a ground mesh from a height map
  130314. * * The parameter `url` sets the URL of the height map image resource.
  130315. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130316. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130317. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130318. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130319. * * 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.
  130320. * * 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).
  130321. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130323. * @param name defines the name of the mesh
  130324. * @param url defines the url to the height map
  130325. * @param options defines the options used to create the mesh
  130326. * @param scene defines the hosting scene
  130327. * @returns the ground mesh
  130328. * @see https://doc.babylonjs.com/babylon101/height_map
  130329. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130330. */
  130331. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130332. width?: number;
  130333. height?: number;
  130334. subdivisions?: number;
  130335. minHeight?: number;
  130336. maxHeight?: number;
  130337. colorFilter?: Color3;
  130338. alphaFilter?: number;
  130339. updatable?: boolean;
  130340. onReady?: (mesh: GroundMesh) => void;
  130341. }, scene?: Nullable<Scene>): GroundMesh;
  130342. /**
  130343. * Creates a polygon mesh
  130344. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  130345. * * 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
  130346. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  130347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  130349. * * Remember you can only change the shape positions, not their number when updating a polygon
  130350. * @param name defines the name of the mesh
  130351. * @param options defines the options used to create the mesh
  130352. * @param scene defines the hosting scene
  130353. * @param earcutInjection can be used to inject your own earcut reference
  130354. * @returns the polygon mesh
  130355. */
  130356. static CreatePolygon(name: string, options: {
  130357. shape: Vector3[];
  130358. holes?: Vector3[][];
  130359. depth?: number;
  130360. faceUV?: Vector4[];
  130361. faceColors?: Color4[];
  130362. updatable?: boolean;
  130363. sideOrientation?: number;
  130364. frontUVs?: Vector4;
  130365. backUVs?: Vector4;
  130366. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130367. /**
  130368. * Creates an extruded polygon mesh, with depth in the Y direction.
  130369. * * 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)
  130370. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130371. * @param name defines the name of the mesh
  130372. * @param options defines the options used to create the mesh
  130373. * @param scene defines the hosting scene
  130374. * @param earcutInjection can be used to inject your own earcut reference
  130375. * @returns the polygon mesh
  130376. */
  130377. static ExtrudePolygon(name: string, options: {
  130378. shape: Vector3[];
  130379. holes?: Vector3[][];
  130380. depth?: number;
  130381. faceUV?: Vector4[];
  130382. faceColors?: Color4[];
  130383. updatable?: boolean;
  130384. sideOrientation?: number;
  130385. frontUVs?: Vector4;
  130386. backUVs?: Vector4;
  130387. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130388. /**
  130389. * Creates a tube mesh.
  130390. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130391. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  130392. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  130393. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  130394. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  130395. * * 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)
  130396. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  130397. * * 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
  130398. * * 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
  130399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130403. * @param name defines the name of the mesh
  130404. * @param options defines the options used to create the mesh
  130405. * @param scene defines the hosting scene
  130406. * @returns the tube mesh
  130407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130408. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  130409. */
  130410. static CreateTube(name: string, options: {
  130411. path: Vector3[];
  130412. radius?: number;
  130413. tessellation?: number;
  130414. radiusFunction?: {
  130415. (i: number, distance: number): number;
  130416. };
  130417. cap?: number;
  130418. arc?: number;
  130419. updatable?: boolean;
  130420. sideOrientation?: number;
  130421. frontUVs?: Vector4;
  130422. backUVs?: Vector4;
  130423. instance?: Mesh;
  130424. invertUV?: boolean;
  130425. }, scene?: Nullable<Scene>): Mesh;
  130426. /**
  130427. * Creates a polyhedron mesh
  130428. * * 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
  130429. * * The parameter `size` (positive float, default 1) sets the polygon size
  130430. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130431. * * 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`
  130432. * * 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
  130433. * * 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)`)
  130434. * * 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
  130435. * * 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
  130436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130439. * @param name defines the name of the mesh
  130440. * @param options defines the options used to create the mesh
  130441. * @param scene defines the hosting scene
  130442. * @returns the polyhedron mesh
  130443. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130444. */
  130445. static CreatePolyhedron(name: string, options: {
  130446. type?: number;
  130447. size?: number;
  130448. sizeX?: number;
  130449. sizeY?: number;
  130450. sizeZ?: number;
  130451. custom?: any;
  130452. faceUV?: Vector4[];
  130453. faceColors?: Color4[];
  130454. flat?: boolean;
  130455. updatable?: boolean;
  130456. sideOrientation?: number;
  130457. frontUVs?: Vector4;
  130458. backUVs?: Vector4;
  130459. }, scene?: Nullable<Scene>): Mesh;
  130460. /**
  130461. * Creates a decal mesh.
  130462. * 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
  130463. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  130464. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  130465. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  130466. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  130467. * @param name defines the name of the mesh
  130468. * @param sourceMesh defines the mesh where the decal must be applied
  130469. * @param options defines the options used to create the mesh
  130470. * @param scene defines the hosting scene
  130471. * @returns the decal mesh
  130472. * @see https://doc.babylonjs.com/how_to/decals
  130473. */
  130474. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  130475. position?: Vector3;
  130476. normal?: Vector3;
  130477. size?: Vector3;
  130478. angle?: number;
  130479. }): Mesh;
  130480. }
  130481. }
  130482. declare module BABYLON {
  130483. /**
  130484. * A simplifier interface for future simplification implementations
  130485. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130486. */
  130487. export interface ISimplifier {
  130488. /**
  130489. * Simplification of a given mesh according to the given settings.
  130490. * Since this requires computation, it is assumed that the function runs async.
  130491. * @param settings The settings of the simplification, including quality and distance
  130492. * @param successCallback A callback that will be called after the mesh was simplified.
  130493. * @param errorCallback in case of an error, this callback will be called. optional.
  130494. */
  130495. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  130496. }
  130497. /**
  130498. * Expected simplification settings.
  130499. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  130500. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130501. */
  130502. export interface ISimplificationSettings {
  130503. /**
  130504. * Gets or sets the expected quality
  130505. */
  130506. quality: number;
  130507. /**
  130508. * Gets or sets the distance when this optimized version should be used
  130509. */
  130510. distance: number;
  130511. /**
  130512. * Gets an already optimized mesh
  130513. */
  130514. optimizeMesh?: boolean;
  130515. }
  130516. /**
  130517. * Class used to specify simplification options
  130518. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130519. */
  130520. export class SimplificationSettings implements ISimplificationSettings {
  130521. /** expected quality */
  130522. quality: number;
  130523. /** distance when this optimized version should be used */
  130524. distance: number;
  130525. /** already optimized mesh */
  130526. optimizeMesh?: boolean | undefined;
  130527. /**
  130528. * Creates a SimplificationSettings
  130529. * @param quality expected quality
  130530. * @param distance distance when this optimized version should be used
  130531. * @param optimizeMesh already optimized mesh
  130532. */
  130533. constructor(
  130534. /** expected quality */
  130535. quality: number,
  130536. /** distance when this optimized version should be used */
  130537. distance: number,
  130538. /** already optimized mesh */
  130539. optimizeMesh?: boolean | undefined);
  130540. }
  130541. /**
  130542. * Interface used to define a simplification task
  130543. */
  130544. export interface ISimplificationTask {
  130545. /**
  130546. * Array of settings
  130547. */
  130548. settings: Array<ISimplificationSettings>;
  130549. /**
  130550. * Simplification type
  130551. */
  130552. simplificationType: SimplificationType;
  130553. /**
  130554. * Mesh to simplify
  130555. */
  130556. mesh: Mesh;
  130557. /**
  130558. * Callback called on success
  130559. */
  130560. successCallback?: () => void;
  130561. /**
  130562. * Defines if parallel processing can be used
  130563. */
  130564. parallelProcessing: boolean;
  130565. }
  130566. /**
  130567. * Queue used to order the simplification tasks
  130568. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130569. */
  130570. export class SimplificationQueue {
  130571. private _simplificationArray;
  130572. /**
  130573. * Gets a boolean indicating that the process is still running
  130574. */
  130575. running: boolean;
  130576. /**
  130577. * Creates a new queue
  130578. */
  130579. constructor();
  130580. /**
  130581. * Adds a new simplification task
  130582. * @param task defines a task to add
  130583. */
  130584. addTask(task: ISimplificationTask): void;
  130585. /**
  130586. * Execute next task
  130587. */
  130588. executeNext(): void;
  130589. /**
  130590. * Execute a simplification task
  130591. * @param task defines the task to run
  130592. */
  130593. runSimplification(task: ISimplificationTask): void;
  130594. private getSimplifier;
  130595. }
  130596. /**
  130597. * The implemented types of simplification
  130598. * At the moment only Quadratic Error Decimation is implemented
  130599. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130600. */
  130601. export enum SimplificationType {
  130602. /** Quadratic error decimation */
  130603. QUADRATIC = 0
  130604. }
  130605. }
  130606. declare module BABYLON {
  130607. interface Scene {
  130608. /** @hidden (Backing field) */
  130609. _simplificationQueue: SimplificationQueue;
  130610. /**
  130611. * Gets or sets the simplification queue attached to the scene
  130612. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130613. */
  130614. simplificationQueue: SimplificationQueue;
  130615. }
  130616. interface Mesh {
  130617. /**
  130618. * Simplify the mesh according to the given array of settings.
  130619. * Function will return immediately and will simplify async
  130620. * @param settings a collection of simplification settings
  130621. * @param parallelProcessing should all levels calculate parallel or one after the other
  130622. * @param simplificationType the type of simplification to run
  130623. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  130624. * @returns the current mesh
  130625. */
  130626. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  130627. }
  130628. /**
  130629. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  130630. * created in a scene
  130631. */
  130632. export class SimplicationQueueSceneComponent implements ISceneComponent {
  130633. /**
  130634. * The component name helpfull to identify the component in the list of scene components.
  130635. */
  130636. readonly name: string;
  130637. /**
  130638. * The scene the component belongs to.
  130639. */
  130640. scene: Scene;
  130641. /**
  130642. * Creates a new instance of the component for the given scene
  130643. * @param scene Defines the scene to register the component in
  130644. */
  130645. constructor(scene: Scene);
  130646. /**
  130647. * Registers the component in a given scene
  130648. */
  130649. register(): void;
  130650. /**
  130651. * Rebuilds the elements related to this component in case of
  130652. * context lost for instance.
  130653. */
  130654. rebuild(): void;
  130655. /**
  130656. * Disposes the component and the associated ressources
  130657. */
  130658. dispose(): void;
  130659. private _beforeCameraUpdate;
  130660. }
  130661. }
  130662. declare module BABYLON {
  130663. /**
  130664. * Navigation plugin interface to add navigation constrained by a navigation mesh
  130665. */
  130666. export interface INavigationEnginePlugin {
  130667. /**
  130668. * plugin name
  130669. */
  130670. name: string;
  130671. /**
  130672. * Creates a navigation mesh
  130673. * @param meshes array of all the geometry used to compute the navigatio mesh
  130674. * @param parameters bunch of parameters used to filter geometry
  130675. */
  130676. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130677. /**
  130678. * Create a navigation mesh debug mesh
  130679. * @param scene is where the mesh will be added
  130680. * @returns debug display mesh
  130681. */
  130682. createDebugNavMesh(scene: Scene): Mesh;
  130683. /**
  130684. * Get a navigation mesh constrained position, closest to the parameter position
  130685. * @param position world position
  130686. * @returns the closest point to position constrained by the navigation mesh
  130687. */
  130688. getClosestPoint(position: Vector3): Vector3;
  130689. /**
  130690. * Get a navigation mesh constrained position, within a particular radius
  130691. * @param position world position
  130692. * @param maxRadius the maximum distance to the constrained world position
  130693. * @returns the closest point to position constrained by the navigation mesh
  130694. */
  130695. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130696. /**
  130697. * Compute the final position from a segment made of destination-position
  130698. * @param position world position
  130699. * @param destination world position
  130700. * @returns the resulting point along the navmesh
  130701. */
  130702. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130703. /**
  130704. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130705. * @param start world position
  130706. * @param end world position
  130707. * @returns array containing world position composing the path
  130708. */
  130709. computePath(start: Vector3, end: Vector3): Vector3[];
  130710. /**
  130711. * If this plugin is supported
  130712. * @returns true if plugin is supported
  130713. */
  130714. isSupported(): boolean;
  130715. /**
  130716. * Create a new Crowd so you can add agents
  130717. * @param maxAgents the maximum agent count in the crowd
  130718. * @param maxAgentRadius the maximum radius an agent can have
  130719. * @param scene to attach the crowd to
  130720. * @returns the crowd you can add agents to
  130721. */
  130722. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130723. /**
  130724. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130725. * The queries will try to find a solution within those bounds
  130726. * default is (1,1,1)
  130727. * @param extent x,y,z value that define the extent around the queries point of reference
  130728. */
  130729. setDefaultQueryExtent(extent: Vector3): void;
  130730. /**
  130731. * Get the Bounding box extent specified by setDefaultQueryExtent
  130732. * @returns the box extent values
  130733. */
  130734. getDefaultQueryExtent(): Vector3;
  130735. /**
  130736. * Release all resources
  130737. */
  130738. dispose(): void;
  130739. }
  130740. /**
  130741. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  130742. */
  130743. export interface ICrowd {
  130744. /**
  130745. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130746. * You can attach anything to that node. The node position is updated in the scene update tick.
  130747. * @param pos world position that will be constrained by the navigation mesh
  130748. * @param parameters agent parameters
  130749. * @param transform hooked to the agent that will be update by the scene
  130750. * @returns agent index
  130751. */
  130752. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130753. /**
  130754. * Returns the agent position in world space
  130755. * @param index agent index returned by addAgent
  130756. * @returns world space position
  130757. */
  130758. getAgentPosition(index: number): Vector3;
  130759. /**
  130760. * Gets the agent velocity in world space
  130761. * @param index agent index returned by addAgent
  130762. * @returns world space velocity
  130763. */
  130764. getAgentVelocity(index: number): Vector3;
  130765. /**
  130766. * remove a particular agent previously created
  130767. * @param index agent index returned by addAgent
  130768. */
  130769. removeAgent(index: number): void;
  130770. /**
  130771. * get the list of all agents attached to this crowd
  130772. * @returns list of agent indices
  130773. */
  130774. getAgents(): number[];
  130775. /**
  130776. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  130777. * @param deltaTime in seconds
  130778. */
  130779. update(deltaTime: number): void;
  130780. /**
  130781. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  130782. * @param index agent index returned by addAgent
  130783. * @param destination targeted world position
  130784. */
  130785. agentGoto(index: number, destination: Vector3): void;
  130786. /**
  130787. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130788. * The queries will try to find a solution within those bounds
  130789. * default is (1,1,1)
  130790. * @param extent x,y,z value that define the extent around the queries point of reference
  130791. */
  130792. setDefaultQueryExtent(extent: Vector3): void;
  130793. /**
  130794. * Get the Bounding box extent specified by setDefaultQueryExtent
  130795. * @returns the box extent values
  130796. */
  130797. getDefaultQueryExtent(): Vector3;
  130798. /**
  130799. * Release all resources
  130800. */
  130801. dispose(): void;
  130802. }
  130803. /**
  130804. * Configures an agent
  130805. */
  130806. export interface IAgentParameters {
  130807. /**
  130808. * Agent radius. [Limit: >= 0]
  130809. */
  130810. radius: number;
  130811. /**
  130812. * Agent height. [Limit: > 0]
  130813. */
  130814. height: number;
  130815. /**
  130816. * Maximum allowed acceleration. [Limit: >= 0]
  130817. */
  130818. maxAcceleration: number;
  130819. /**
  130820. * Maximum allowed speed. [Limit: >= 0]
  130821. */
  130822. maxSpeed: number;
  130823. /**
  130824. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  130825. */
  130826. collisionQueryRange: number;
  130827. /**
  130828. * The path visibility optimization range. [Limit: > 0]
  130829. */
  130830. pathOptimizationRange: number;
  130831. /**
  130832. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  130833. */
  130834. separationWeight: number;
  130835. }
  130836. /**
  130837. * Configures the navigation mesh creation
  130838. */
  130839. export interface INavMeshParameters {
  130840. /**
  130841. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  130842. */
  130843. cs: number;
  130844. /**
  130845. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  130846. */
  130847. ch: number;
  130848. /**
  130849. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  130850. */
  130851. walkableSlopeAngle: number;
  130852. /**
  130853. * Minimum floor to 'ceiling' height that will still allow the floor area to
  130854. * be considered walkable. [Limit: >= 3] [Units: vx]
  130855. */
  130856. walkableHeight: number;
  130857. /**
  130858. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  130859. */
  130860. walkableClimb: number;
  130861. /**
  130862. * The distance to erode/shrink the walkable area of the heightfield away from
  130863. * obstructions. [Limit: >=0] [Units: vx]
  130864. */
  130865. walkableRadius: number;
  130866. /**
  130867. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  130868. */
  130869. maxEdgeLen: number;
  130870. /**
  130871. * The maximum distance a simplfied contour's border edges should deviate
  130872. * the original raw contour. [Limit: >=0] [Units: vx]
  130873. */
  130874. maxSimplificationError: number;
  130875. /**
  130876. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  130877. */
  130878. minRegionArea: number;
  130879. /**
  130880. * Any regions with a span count smaller than this value will, if possible,
  130881. * be merged with larger regions. [Limit: >=0] [Units: vx]
  130882. */
  130883. mergeRegionArea: number;
  130884. /**
  130885. * The maximum number of vertices allowed for polygons generated during the
  130886. * contour to polygon conversion process. [Limit: >= 3]
  130887. */
  130888. maxVertsPerPoly: number;
  130889. /**
  130890. * Sets the sampling distance to use when generating the detail mesh.
  130891. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  130892. */
  130893. detailSampleDist: number;
  130894. /**
  130895. * The maximum distance the detail mesh surface should deviate from heightfield
  130896. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  130897. */
  130898. detailSampleMaxError: number;
  130899. }
  130900. }
  130901. declare module BABYLON {
  130902. /**
  130903. * RecastJS navigation plugin
  130904. */
  130905. export class RecastJSPlugin implements INavigationEnginePlugin {
  130906. /**
  130907. * Reference to the Recast library
  130908. */
  130909. bjsRECAST: any;
  130910. /**
  130911. * plugin name
  130912. */
  130913. name: string;
  130914. /**
  130915. * the first navmesh created. We might extend this to support multiple navmeshes
  130916. */
  130917. navMesh: any;
  130918. /**
  130919. * Initializes the recastJS plugin
  130920. * @param recastInjection can be used to inject your own recast reference
  130921. */
  130922. constructor(recastInjection?: any);
  130923. /**
  130924. * Creates a navigation mesh
  130925. * @param meshes array of all the geometry used to compute the navigatio mesh
  130926. * @param parameters bunch of parameters used to filter geometry
  130927. */
  130928. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130929. /**
  130930. * Create a navigation mesh debug mesh
  130931. * @param scene is where the mesh will be added
  130932. * @returns debug display mesh
  130933. */
  130934. createDebugNavMesh(scene: Scene): Mesh;
  130935. /**
  130936. * Get a navigation mesh constrained position, closest to the parameter position
  130937. * @param position world position
  130938. * @returns the closest point to position constrained by the navigation mesh
  130939. */
  130940. getClosestPoint(position: Vector3): Vector3;
  130941. /**
  130942. * Get a navigation mesh constrained position, within a particular radius
  130943. * @param position world position
  130944. * @param maxRadius the maximum distance to the constrained world position
  130945. * @returns the closest point to position constrained by the navigation mesh
  130946. */
  130947. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130948. /**
  130949. * Compute the final position from a segment made of destination-position
  130950. * @param position world position
  130951. * @param destination world position
  130952. * @returns the resulting point along the navmesh
  130953. */
  130954. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130955. /**
  130956. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130957. * @param start world position
  130958. * @param end world position
  130959. * @returns array containing world position composing the path
  130960. */
  130961. computePath(start: Vector3, end: Vector3): Vector3[];
  130962. /**
  130963. * Create a new Crowd so you can add agents
  130964. * @param maxAgents the maximum agent count in the crowd
  130965. * @param maxAgentRadius the maximum radius an agent can have
  130966. * @param scene to attach the crowd to
  130967. * @returns the crowd you can add agents to
  130968. */
  130969. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130970. /**
  130971. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130972. * The queries will try to find a solution within those bounds
  130973. * default is (1,1,1)
  130974. * @param extent x,y,z value that define the extent around the queries point of reference
  130975. */
  130976. setDefaultQueryExtent(extent: Vector3): void;
  130977. /**
  130978. * Get the Bounding box extent specified by setDefaultQueryExtent
  130979. * @returns the box extent values
  130980. */
  130981. getDefaultQueryExtent(): Vector3;
  130982. /**
  130983. * Disposes
  130984. */
  130985. dispose(): void;
  130986. /**
  130987. * If this plugin is supported
  130988. * @returns true if plugin is supported
  130989. */
  130990. isSupported(): boolean;
  130991. }
  130992. /**
  130993. * Recast detour crowd implementation
  130994. */
  130995. export class RecastJSCrowd implements ICrowd {
  130996. /**
  130997. * Recast/detour plugin
  130998. */
  130999. bjsRECASTPlugin: RecastJSPlugin;
  131000. /**
  131001. * Link to the detour crowd
  131002. */
  131003. recastCrowd: any;
  131004. /**
  131005. * One transform per agent
  131006. */
  131007. transforms: TransformNode[];
  131008. /**
  131009. * All agents created
  131010. */
  131011. agents: number[];
  131012. /**
  131013. * Link to the scene is kept to unregister the crowd from the scene
  131014. */
  131015. private _scene;
  131016. /**
  131017. * Observer for crowd updates
  131018. */
  131019. private _onBeforeAnimationsObserver;
  131020. /**
  131021. * Constructor
  131022. * @param plugin recastJS plugin
  131023. * @param maxAgents the maximum agent count in the crowd
  131024. * @param maxAgentRadius the maximum radius an agent can have
  131025. * @param scene to attach the crowd to
  131026. * @returns the crowd you can add agents to
  131027. */
  131028. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  131029. /**
  131030. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  131031. * You can attach anything to that node. The node position is updated in the scene update tick.
  131032. * @param pos world position that will be constrained by the navigation mesh
  131033. * @param parameters agent parameters
  131034. * @param transform hooked to the agent that will be update by the scene
  131035. * @returns agent index
  131036. */
  131037. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  131038. /**
  131039. * Returns the agent position in world space
  131040. * @param index agent index returned by addAgent
  131041. * @returns world space position
  131042. */
  131043. getAgentPosition(index: number): Vector3;
  131044. /**
  131045. * Returns the agent velocity in world space
  131046. * @param index agent index returned by addAgent
  131047. * @returns world space velocity
  131048. */
  131049. getAgentVelocity(index: number): Vector3;
  131050. /**
  131051. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  131052. * @param index agent index returned by addAgent
  131053. * @param destination targeted world position
  131054. */
  131055. agentGoto(index: number, destination: Vector3): void;
  131056. /**
  131057. * remove a particular agent previously created
  131058. * @param index agent index returned by addAgent
  131059. */
  131060. removeAgent(index: number): void;
  131061. /**
  131062. * get the list of all agents attached to this crowd
  131063. * @returns list of agent indices
  131064. */
  131065. getAgents(): number[];
  131066. /**
  131067. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  131068. * @param deltaTime in seconds
  131069. */
  131070. update(deltaTime: number): void;
  131071. /**
  131072. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131073. * The queries will try to find a solution within those bounds
  131074. * default is (1,1,1)
  131075. * @param extent x,y,z value that define the extent around the queries point of reference
  131076. */
  131077. setDefaultQueryExtent(extent: Vector3): void;
  131078. /**
  131079. * Get the Bounding box extent specified by setDefaultQueryExtent
  131080. * @returns the box extent values
  131081. */
  131082. getDefaultQueryExtent(): Vector3;
  131083. /**
  131084. * Release all resources
  131085. */
  131086. dispose(): void;
  131087. }
  131088. }
  131089. declare module BABYLON {
  131090. /**
  131091. * Class used to enable access to IndexedDB
  131092. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131093. */
  131094. export class Database implements IOfflineProvider {
  131095. private _callbackManifestChecked;
  131096. private _currentSceneUrl;
  131097. private _db;
  131098. private _enableSceneOffline;
  131099. private _enableTexturesOffline;
  131100. private _manifestVersionFound;
  131101. private _mustUpdateRessources;
  131102. private _hasReachedQuota;
  131103. private _isSupported;
  131104. private _idbFactory;
  131105. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  131106. private static IsUASupportingBlobStorage;
  131107. /**
  131108. * Gets a boolean indicating if Database storate is enabled (off by default)
  131109. */
  131110. static IDBStorageEnabled: boolean;
  131111. /**
  131112. * Gets a boolean indicating if scene must be saved in the database
  131113. */
  131114. get enableSceneOffline(): boolean;
  131115. /**
  131116. * Gets a boolean indicating if textures must be saved in the database
  131117. */
  131118. get enableTexturesOffline(): boolean;
  131119. /**
  131120. * Creates a new Database
  131121. * @param urlToScene defines the url to load the scene
  131122. * @param callbackManifestChecked defines the callback to use when manifest is checked
  131123. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  131124. */
  131125. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  131126. private static _ParseURL;
  131127. private static _ReturnFullUrlLocation;
  131128. private _checkManifestFile;
  131129. /**
  131130. * Open the database and make it available
  131131. * @param successCallback defines the callback to call on success
  131132. * @param errorCallback defines the callback to call on error
  131133. */
  131134. open(successCallback: () => void, errorCallback: () => void): void;
  131135. /**
  131136. * Loads an image from the database
  131137. * @param url defines the url to load from
  131138. * @param image defines the target DOM image
  131139. */
  131140. loadImage(url: string, image: HTMLImageElement): void;
  131141. private _loadImageFromDBAsync;
  131142. private _saveImageIntoDBAsync;
  131143. private _checkVersionFromDB;
  131144. private _loadVersionFromDBAsync;
  131145. private _saveVersionIntoDBAsync;
  131146. /**
  131147. * Loads a file from database
  131148. * @param url defines the URL to load from
  131149. * @param sceneLoaded defines a callback to call on success
  131150. * @param progressCallBack defines a callback to call when progress changed
  131151. * @param errorCallback defines a callback to call on error
  131152. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  131153. */
  131154. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  131155. private _loadFileAsync;
  131156. private _saveFileAsync;
  131157. /**
  131158. * Validates if xhr data is correct
  131159. * @param xhr defines the request to validate
  131160. * @param dataType defines the expected data type
  131161. * @returns true if data is correct
  131162. */
  131163. private static _ValidateXHRData;
  131164. }
  131165. }
  131166. declare module BABYLON {
  131167. /** @hidden */
  131168. export var gpuUpdateParticlesPixelShader: {
  131169. name: string;
  131170. shader: string;
  131171. };
  131172. }
  131173. declare module BABYLON {
  131174. /** @hidden */
  131175. export var gpuUpdateParticlesVertexShader: {
  131176. name: string;
  131177. shader: string;
  131178. };
  131179. }
  131180. declare module BABYLON {
  131181. /** @hidden */
  131182. export var clipPlaneFragmentDeclaration2: {
  131183. name: string;
  131184. shader: string;
  131185. };
  131186. }
  131187. declare module BABYLON {
  131188. /** @hidden */
  131189. export var gpuRenderParticlesPixelShader: {
  131190. name: string;
  131191. shader: string;
  131192. };
  131193. }
  131194. declare module BABYLON {
  131195. /** @hidden */
  131196. export var clipPlaneVertexDeclaration2: {
  131197. name: string;
  131198. shader: string;
  131199. };
  131200. }
  131201. declare module BABYLON {
  131202. /** @hidden */
  131203. export var gpuRenderParticlesVertexShader: {
  131204. name: string;
  131205. shader: string;
  131206. };
  131207. }
  131208. declare module BABYLON {
  131209. /**
  131210. * This represents a GPU particle system in Babylon
  131211. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  131212. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  131213. */
  131214. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  131215. /**
  131216. * The layer mask we are rendering the particles through.
  131217. */
  131218. layerMask: number;
  131219. private _capacity;
  131220. private _activeCount;
  131221. private _currentActiveCount;
  131222. private _accumulatedCount;
  131223. private _renderEffect;
  131224. private _updateEffect;
  131225. private _buffer0;
  131226. private _buffer1;
  131227. private _spriteBuffer;
  131228. private _updateVAO;
  131229. private _renderVAO;
  131230. private _targetIndex;
  131231. private _sourceBuffer;
  131232. private _targetBuffer;
  131233. private _engine;
  131234. private _currentRenderId;
  131235. private _started;
  131236. private _stopped;
  131237. private _timeDelta;
  131238. private _randomTexture;
  131239. private _randomTexture2;
  131240. private _attributesStrideSize;
  131241. private _updateEffectOptions;
  131242. private _randomTextureSize;
  131243. private _actualFrame;
  131244. private readonly _rawTextureWidth;
  131245. /**
  131246. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  131247. */
  131248. static get IsSupported(): boolean;
  131249. /**
  131250. * An event triggered when the system is disposed.
  131251. */
  131252. onDisposeObservable: Observable<GPUParticleSystem>;
  131253. /**
  131254. * Gets the maximum number of particles active at the same time.
  131255. * @returns The max number of active particles.
  131256. */
  131257. getCapacity(): number;
  131258. /**
  131259. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  131260. * to override the particles.
  131261. */
  131262. forceDepthWrite: boolean;
  131263. /**
  131264. * Gets or set the number of active particles
  131265. */
  131266. get activeParticleCount(): number;
  131267. set activeParticleCount(value: number);
  131268. private _preWarmDone;
  131269. /**
  131270. * Is this system ready to be used/rendered
  131271. * @return true if the system is ready
  131272. */
  131273. isReady(): boolean;
  131274. /**
  131275. * Gets if the system has been started. (Note: this will still be true after stop is called)
  131276. * @returns True if it has been started, otherwise false.
  131277. */
  131278. isStarted(): boolean;
  131279. /**
  131280. * Starts the particle system and begins to emit
  131281. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  131282. */
  131283. start(delay?: number): void;
  131284. /**
  131285. * Stops the particle system.
  131286. */
  131287. stop(): void;
  131288. /**
  131289. * Remove all active particles
  131290. */
  131291. reset(): void;
  131292. /**
  131293. * Returns the string "GPUParticleSystem"
  131294. * @returns a string containing the class name
  131295. */
  131296. getClassName(): string;
  131297. private _colorGradientsTexture;
  131298. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  131299. /**
  131300. * Adds a new color gradient
  131301. * @param gradient defines the gradient to use (between 0 and 1)
  131302. * @param color1 defines the color to affect to the specified gradient
  131303. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  131304. * @returns the current particle system
  131305. */
  131306. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  131307. /**
  131308. * Remove a specific color gradient
  131309. * @param gradient defines the gradient to remove
  131310. * @returns the current particle system
  131311. */
  131312. removeColorGradient(gradient: number): GPUParticleSystem;
  131313. private _angularSpeedGradientsTexture;
  131314. private _sizeGradientsTexture;
  131315. private _velocityGradientsTexture;
  131316. private _limitVelocityGradientsTexture;
  131317. private _dragGradientsTexture;
  131318. private _addFactorGradient;
  131319. /**
  131320. * Adds a new size gradient
  131321. * @param gradient defines the gradient to use (between 0 and 1)
  131322. * @param factor defines the size factor to affect to the specified gradient
  131323. * @returns the current particle system
  131324. */
  131325. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  131326. /**
  131327. * Remove a specific size gradient
  131328. * @param gradient defines the gradient to remove
  131329. * @returns the current particle system
  131330. */
  131331. removeSizeGradient(gradient: number): GPUParticleSystem;
  131332. /**
  131333. * Adds a new angular speed gradient
  131334. * @param gradient defines the gradient to use (between 0 and 1)
  131335. * @param factor defines the angular speed to affect to the specified gradient
  131336. * @returns the current particle system
  131337. */
  131338. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  131339. /**
  131340. * Remove a specific angular speed gradient
  131341. * @param gradient defines the gradient to remove
  131342. * @returns the current particle system
  131343. */
  131344. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  131345. /**
  131346. * Adds a new velocity gradient
  131347. * @param gradient defines the gradient to use (between 0 and 1)
  131348. * @param factor defines the velocity to affect to the specified gradient
  131349. * @returns the current particle system
  131350. */
  131351. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131352. /**
  131353. * Remove a specific velocity gradient
  131354. * @param gradient defines the gradient to remove
  131355. * @returns the current particle system
  131356. */
  131357. removeVelocityGradient(gradient: number): GPUParticleSystem;
  131358. /**
  131359. * Adds a new limit velocity gradient
  131360. * @param gradient defines the gradient to use (between 0 and 1)
  131361. * @param factor defines the limit velocity value to affect to the specified gradient
  131362. * @returns the current particle system
  131363. */
  131364. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131365. /**
  131366. * Remove a specific limit velocity gradient
  131367. * @param gradient defines the gradient to remove
  131368. * @returns the current particle system
  131369. */
  131370. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  131371. /**
  131372. * Adds a new drag gradient
  131373. * @param gradient defines the gradient to use (between 0 and 1)
  131374. * @param factor defines the drag value to affect to the specified gradient
  131375. * @returns the current particle system
  131376. */
  131377. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  131378. /**
  131379. * Remove a specific drag gradient
  131380. * @param gradient defines the gradient to remove
  131381. * @returns the current particle system
  131382. */
  131383. removeDragGradient(gradient: number): GPUParticleSystem;
  131384. /**
  131385. * Not supported by GPUParticleSystem
  131386. * @param gradient defines the gradient to use (between 0 and 1)
  131387. * @param factor defines the emit rate value to affect to the specified gradient
  131388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131389. * @returns the current particle system
  131390. */
  131391. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131392. /**
  131393. * Not supported by GPUParticleSystem
  131394. * @param gradient defines the gradient to remove
  131395. * @returns the current particle system
  131396. */
  131397. removeEmitRateGradient(gradient: number): IParticleSystem;
  131398. /**
  131399. * Not supported by GPUParticleSystem
  131400. * @param gradient defines the gradient to use (between 0 and 1)
  131401. * @param factor defines the start size value to affect to the specified gradient
  131402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131403. * @returns the current particle system
  131404. */
  131405. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131406. /**
  131407. * Not supported by GPUParticleSystem
  131408. * @param gradient defines the gradient to remove
  131409. * @returns the current particle system
  131410. */
  131411. removeStartSizeGradient(gradient: number): IParticleSystem;
  131412. /**
  131413. * Not supported by GPUParticleSystem
  131414. * @param gradient defines the gradient to use (between 0 and 1)
  131415. * @param min defines the color remap minimal range
  131416. * @param max defines the color remap maximal range
  131417. * @returns the current particle system
  131418. */
  131419. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131420. /**
  131421. * Not supported by GPUParticleSystem
  131422. * @param gradient defines the gradient to remove
  131423. * @returns the current particle system
  131424. */
  131425. removeColorRemapGradient(): IParticleSystem;
  131426. /**
  131427. * Not supported by GPUParticleSystem
  131428. * @param gradient defines the gradient to use (between 0 and 1)
  131429. * @param min defines the alpha remap minimal range
  131430. * @param max defines the alpha remap maximal range
  131431. * @returns the current particle system
  131432. */
  131433. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131434. /**
  131435. * Not supported by GPUParticleSystem
  131436. * @param gradient defines the gradient to remove
  131437. * @returns the current particle system
  131438. */
  131439. removeAlphaRemapGradient(): IParticleSystem;
  131440. /**
  131441. * Not supported by GPUParticleSystem
  131442. * @param gradient defines the gradient to use (between 0 and 1)
  131443. * @param color defines the color to affect to the specified gradient
  131444. * @returns the current particle system
  131445. */
  131446. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  131447. /**
  131448. * Not supported by GPUParticleSystem
  131449. * @param gradient defines the gradient to remove
  131450. * @returns the current particle system
  131451. */
  131452. removeRampGradient(): IParticleSystem;
  131453. /**
  131454. * Not supported by GPUParticleSystem
  131455. * @returns the list of ramp gradients
  131456. */
  131457. getRampGradients(): Nullable<Array<Color3Gradient>>;
  131458. /**
  131459. * Not supported by GPUParticleSystem
  131460. * Gets or sets a boolean indicating that ramp gradients must be used
  131461. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  131462. */
  131463. get useRampGradients(): boolean;
  131464. set useRampGradients(value: boolean);
  131465. /**
  131466. * Not supported by GPUParticleSystem
  131467. * @param gradient defines the gradient to use (between 0 and 1)
  131468. * @param factor defines the life time factor to affect to the specified gradient
  131469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131470. * @returns the current particle system
  131471. */
  131472. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131473. /**
  131474. * Not supported by GPUParticleSystem
  131475. * @param gradient defines the gradient to remove
  131476. * @returns the current particle system
  131477. */
  131478. removeLifeTimeGradient(gradient: number): IParticleSystem;
  131479. /**
  131480. * Instantiates a GPU particle system.
  131481. * 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.
  131482. * @param name The name of the particle system
  131483. * @param options The options used to create the system
  131484. * @param scene The scene the particle system belongs to
  131485. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  131486. */
  131487. constructor(name: string, options: Partial<{
  131488. capacity: number;
  131489. randomTextureSize: number;
  131490. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  131491. protected _reset(): void;
  131492. private _createUpdateVAO;
  131493. private _createRenderVAO;
  131494. private _initialize;
  131495. /** @hidden */
  131496. _recreateUpdateEffect(): void;
  131497. /** @hidden */
  131498. _recreateRenderEffect(): void;
  131499. /**
  131500. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  131501. * @param preWarm defines if we are in the pre-warmimg phase
  131502. */
  131503. animate(preWarm?: boolean): void;
  131504. private _createFactorGradientTexture;
  131505. private _createSizeGradientTexture;
  131506. private _createAngularSpeedGradientTexture;
  131507. private _createVelocityGradientTexture;
  131508. private _createLimitVelocityGradientTexture;
  131509. private _createDragGradientTexture;
  131510. private _createColorGradientTexture;
  131511. /**
  131512. * Renders the particle system in its current state
  131513. * @param preWarm defines if the system should only update the particles but not render them
  131514. * @returns the current number of particles
  131515. */
  131516. render(preWarm?: boolean): number;
  131517. /**
  131518. * Rebuilds the particle system
  131519. */
  131520. rebuild(): void;
  131521. private _releaseBuffers;
  131522. private _releaseVAOs;
  131523. /**
  131524. * Disposes the particle system and free the associated resources
  131525. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  131526. */
  131527. dispose(disposeTexture?: boolean): void;
  131528. /**
  131529. * Clones the particle system.
  131530. * @param name The name of the cloned object
  131531. * @param newEmitter The new emitter to use
  131532. * @returns the cloned particle system
  131533. */
  131534. clone(name: string, newEmitter: any): GPUParticleSystem;
  131535. /**
  131536. * Serializes the particle system to a JSON object.
  131537. * @returns the JSON object
  131538. */
  131539. serialize(): any;
  131540. /**
  131541. * Parses a JSON object to create a GPU particle system.
  131542. * @param parsedParticleSystem The JSON object to parse
  131543. * @param scene The scene to create the particle system in
  131544. * @param rootUrl The root url to use to load external dependencies like texture
  131545. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  131546. * @returns the parsed GPU particle system
  131547. */
  131548. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  131549. }
  131550. }
  131551. declare module BABYLON {
  131552. /**
  131553. * Represents a set of particle systems working together to create a specific effect
  131554. */
  131555. export class ParticleSystemSet implements IDisposable {
  131556. /**
  131557. * Gets or sets base Assets URL
  131558. */
  131559. static BaseAssetsUrl: string;
  131560. private _emitterCreationOptions;
  131561. private _emitterNode;
  131562. /**
  131563. * Gets the particle system list
  131564. */
  131565. systems: IParticleSystem[];
  131566. /**
  131567. * Gets the emitter node used with this set
  131568. */
  131569. get emitterNode(): Nullable<TransformNode>;
  131570. /**
  131571. * Creates a new emitter mesh as a sphere
  131572. * @param options defines the options used to create the sphere
  131573. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  131574. * @param scene defines the hosting scene
  131575. */
  131576. setEmitterAsSphere(options: {
  131577. diameter: number;
  131578. segments: number;
  131579. color: Color3;
  131580. }, renderingGroupId: number, scene: Scene): void;
  131581. /**
  131582. * Starts all particle systems of the set
  131583. * @param emitter defines an optional mesh to use as emitter for the particle systems
  131584. */
  131585. start(emitter?: AbstractMesh): void;
  131586. /**
  131587. * Release all associated resources
  131588. */
  131589. dispose(): void;
  131590. /**
  131591. * Serialize the set into a JSON compatible object
  131592. * @returns a JSON compatible representation of the set
  131593. */
  131594. serialize(): any;
  131595. /**
  131596. * Parse a new ParticleSystemSet from a serialized source
  131597. * @param data defines a JSON compatible representation of the set
  131598. * @param scene defines the hosting scene
  131599. * @param gpu defines if we want GPU particles or CPU particles
  131600. * @returns a new ParticleSystemSet
  131601. */
  131602. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  131603. }
  131604. }
  131605. declare module BABYLON {
  131606. /**
  131607. * This class is made for on one-liner static method to help creating particle system set.
  131608. */
  131609. export class ParticleHelper {
  131610. /**
  131611. * Gets or sets base Assets URL
  131612. */
  131613. static BaseAssetsUrl: string;
  131614. /**
  131615. * Create a default particle system that you can tweak
  131616. * @param emitter defines the emitter to use
  131617. * @param capacity defines the system capacity (default is 500 particles)
  131618. * @param scene defines the hosting scene
  131619. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  131620. * @returns the new Particle system
  131621. */
  131622. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  131623. /**
  131624. * This is the main static method (one-liner) of this helper to create different particle systems
  131625. * @param type This string represents the type to the particle system to create
  131626. * @param scene The scene where the particle system should live
  131627. * @param gpu If the system will use gpu
  131628. * @returns the ParticleSystemSet created
  131629. */
  131630. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  131631. /**
  131632. * Static function used to export a particle system to a ParticleSystemSet variable.
  131633. * Please note that the emitter shape is not exported
  131634. * @param systems defines the particle systems to export
  131635. * @returns the created particle system set
  131636. */
  131637. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  131638. }
  131639. }
  131640. declare module BABYLON {
  131641. interface Engine {
  131642. /**
  131643. * Create an effect to use with particle systems.
  131644. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  131645. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  131646. * @param uniformsNames defines a list of attribute names
  131647. * @param samplers defines an array of string used to represent textures
  131648. * @param defines defines the string containing the defines to use to compile the shaders
  131649. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  131650. * @param onCompiled defines a function to call when the effect creation is successful
  131651. * @param onError defines a function to call when the effect creation has failed
  131652. * @returns the new Effect
  131653. */
  131654. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  131655. }
  131656. interface Mesh {
  131657. /**
  131658. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  131659. * @returns an array of IParticleSystem
  131660. */
  131661. getEmittedParticleSystems(): IParticleSystem[];
  131662. /**
  131663. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  131664. * @returns an array of IParticleSystem
  131665. */
  131666. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  131667. }
  131668. /**
  131669. * @hidden
  131670. */
  131671. export var _IDoNeedToBeInTheBuild: number;
  131672. }
  131673. declare module BABYLON {
  131674. /** Defines the 4 color options */
  131675. export enum PointColor {
  131676. /** color value */
  131677. Color = 2,
  131678. /** uv value */
  131679. UV = 1,
  131680. /** random value */
  131681. Random = 0,
  131682. /** stated value */
  131683. Stated = 3
  131684. }
  131685. /**
  131686. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  131687. * 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.
  131688. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  131689. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  131690. *
  131691. * Full documentation here : TO BE ENTERED
  131692. */
  131693. export class PointsCloudSystem implements IDisposable {
  131694. /**
  131695. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  131696. * Example : var p = SPS.particles[i];
  131697. */
  131698. particles: CloudPoint[];
  131699. /**
  131700. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  131701. */
  131702. nbParticles: number;
  131703. /**
  131704. * This a counter for your own usage. It's not set by any SPS functions.
  131705. */
  131706. counter: number;
  131707. /**
  131708. * The PCS name. This name is also given to the underlying mesh.
  131709. */
  131710. name: string;
  131711. /**
  131712. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  131713. */
  131714. mesh: Mesh;
  131715. /**
  131716. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  131717. * Please read :
  131718. */
  131719. vars: any;
  131720. /**
  131721. * @hidden
  131722. */
  131723. _size: number;
  131724. private _scene;
  131725. private _promises;
  131726. private _positions;
  131727. private _indices;
  131728. private _normals;
  131729. private _colors;
  131730. private _uvs;
  131731. private _indices32;
  131732. private _positions32;
  131733. private _colors32;
  131734. private _uvs32;
  131735. private _updatable;
  131736. private _isVisibilityBoxLocked;
  131737. private _alwaysVisible;
  131738. private _groups;
  131739. private _groupCounter;
  131740. private _computeParticleColor;
  131741. private _computeParticleTexture;
  131742. private _computeParticleRotation;
  131743. private _computeBoundingBox;
  131744. private _isReady;
  131745. /**
  131746. * Creates a PCS (Points Cloud System) object
  131747. * @param name (String) is the PCS name, this will be the underlying mesh name
  131748. * @param pointSize (number) is the size for each point
  131749. * @param scene (Scene) is the scene in which the PCS is added
  131750. * @param options defines the options of the PCS e.g.
  131751. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  131752. */
  131753. constructor(name: string, pointSize: number, scene: Scene, options?: {
  131754. updatable?: boolean;
  131755. });
  131756. /**
  131757. * Builds the PCS underlying mesh. Returns a standard Mesh.
  131758. * If no points were added to the PCS, the returned mesh is just a single point.
  131759. * @returns a promise for the created mesh
  131760. */
  131761. buildMeshAsync(): Promise<Mesh>;
  131762. /**
  131763. * @hidden
  131764. */
  131765. private _buildMesh;
  131766. private _addParticle;
  131767. private _randomUnitVector;
  131768. private _getColorIndicesForCoord;
  131769. private _setPointsColorOrUV;
  131770. private _colorFromTexture;
  131771. private _calculateDensity;
  131772. /**
  131773. * Adds points to the PCS in random positions within a unit sphere
  131774. * @param nb (positive integer) the number of particles to be created from this model
  131775. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  131776. * @returns the number of groups in the system
  131777. */
  131778. addPoints(nb: number, pointFunction?: any): number;
  131779. /**
  131780. * Adds points to the PCS from the surface of the model shape
  131781. * @param mesh is any Mesh object that will be used as a surface model for the points
  131782. * @param nb (positive integer) the number of particles to be created from this model
  131783. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131784. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131785. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131786. * @returns the number of groups in the system
  131787. */
  131788. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131789. /**
  131790. * Adds points to the PCS inside the model shape
  131791. * @param mesh is any Mesh object that will be used as a surface model for the points
  131792. * @param nb (positive integer) the number of particles to be created from this model
  131793. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131794. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131795. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131796. * @returns the number of groups in the system
  131797. */
  131798. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131799. /**
  131800. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  131801. * This method calls `updateParticle()` for each particle of the SPS.
  131802. * For an animated SPS, it is usually called within the render loop.
  131803. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  131804. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  131805. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  131806. * @returns the PCS.
  131807. */
  131808. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  131809. /**
  131810. * Disposes the PCS.
  131811. */
  131812. dispose(): void;
  131813. /**
  131814. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  131815. * doc :
  131816. * @returns the PCS.
  131817. */
  131818. refreshVisibleSize(): PointsCloudSystem;
  131819. /**
  131820. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  131821. * @param size the size (float) of the visibility box
  131822. * note : this doesn't lock the PCS mesh bounding box.
  131823. * doc :
  131824. */
  131825. setVisibilityBox(size: number): void;
  131826. /**
  131827. * Gets whether the PCS is always visible or not
  131828. * doc :
  131829. */
  131830. get isAlwaysVisible(): boolean;
  131831. /**
  131832. * Sets the PCS as always visible or not
  131833. * doc :
  131834. */
  131835. set isAlwaysVisible(val: boolean);
  131836. /**
  131837. * Tells to `setParticles()` to compute the particle rotations or not
  131838. * Default value : false. The PCS is faster when it's set to false
  131839. * Note : particle rotations are only applied to parent particles
  131840. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  131841. */
  131842. set computeParticleRotation(val: boolean);
  131843. /**
  131844. * Tells to `setParticles()` to compute the particle colors or not.
  131845. * Default value : true. The PCS is faster when it's set to false.
  131846. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131847. */
  131848. set computeParticleColor(val: boolean);
  131849. set computeParticleTexture(val: boolean);
  131850. /**
  131851. * Gets if `setParticles()` computes the particle colors or not.
  131852. * Default value : false. The PCS is faster when it's set to false.
  131853. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131854. */
  131855. get computeParticleColor(): boolean;
  131856. /**
  131857. * Gets if `setParticles()` computes the particle textures or not.
  131858. * Default value : false. The PCS is faster when it's set to false.
  131859. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  131860. */
  131861. get computeParticleTexture(): boolean;
  131862. /**
  131863. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  131864. */
  131865. set computeBoundingBox(val: boolean);
  131866. /**
  131867. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  131868. */
  131869. get computeBoundingBox(): boolean;
  131870. /**
  131871. * This function does nothing. It may be overwritten to set all the particle first values.
  131872. * The PCS doesn't call this function, you may have to call it by your own.
  131873. * doc :
  131874. */
  131875. initParticles(): void;
  131876. /**
  131877. * This function does nothing. It may be overwritten to recycle a particle
  131878. * The PCS doesn't call this function, you can to call it
  131879. * doc :
  131880. * @param particle The particle to recycle
  131881. * @returns the recycled particle
  131882. */
  131883. recycleParticle(particle: CloudPoint): CloudPoint;
  131884. /**
  131885. * Updates a particle : this function should be overwritten by the user.
  131886. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  131887. * doc :
  131888. * @example : just set a particle position or velocity and recycle conditions
  131889. * @param particle The particle to update
  131890. * @returns the updated particle
  131891. */
  131892. updateParticle(particle: CloudPoint): CloudPoint;
  131893. /**
  131894. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  131895. * This does nothing and may be overwritten by the user.
  131896. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  131897. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  131898. * @param update the boolean update value actually passed to setParticles()
  131899. */
  131900. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  131901. /**
  131902. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  131903. * This will be passed three parameters.
  131904. * This does nothing and may be overwritten by the user.
  131905. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  131906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  131907. * @param update the boolean update value actually passed to setParticles()
  131908. */
  131909. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  131910. }
  131911. }
  131912. declare module BABYLON {
  131913. /**
  131914. * Represents one particle of a points cloud system.
  131915. */
  131916. export class CloudPoint {
  131917. /**
  131918. * particle global index
  131919. */
  131920. idx: number;
  131921. /**
  131922. * The color of the particle
  131923. */
  131924. color: Nullable<Color4>;
  131925. /**
  131926. * The world space position of the particle.
  131927. */
  131928. position: Vector3;
  131929. /**
  131930. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  131931. */
  131932. rotation: Vector3;
  131933. /**
  131934. * The world space rotation quaternion of the particle.
  131935. */
  131936. rotationQuaternion: Nullable<Quaternion>;
  131937. /**
  131938. * The uv of the particle.
  131939. */
  131940. uv: Nullable<Vector2>;
  131941. /**
  131942. * The current speed of the particle.
  131943. */
  131944. velocity: Vector3;
  131945. /**
  131946. * The pivot point in the particle local space.
  131947. */
  131948. pivot: Vector3;
  131949. /**
  131950. * Must the particle be translated from its pivot point in its local space ?
  131951. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  131952. * Default : false
  131953. */
  131954. translateFromPivot: boolean;
  131955. /**
  131956. * Index of this particle in the global "positions" array (Internal use)
  131957. * @hidden
  131958. */
  131959. _pos: number;
  131960. /**
  131961. * @hidden Index of this particle in the global "indices" array (Internal use)
  131962. */
  131963. _ind: number;
  131964. /**
  131965. * Group this particle belongs to
  131966. */
  131967. _group: PointsGroup;
  131968. /**
  131969. * Group id of this particle
  131970. */
  131971. groupId: number;
  131972. /**
  131973. * Index of the particle in its group id (Internal use)
  131974. */
  131975. idxInGroup: number;
  131976. /**
  131977. * @hidden Particle BoundingInfo object (Internal use)
  131978. */
  131979. _boundingInfo: BoundingInfo;
  131980. /**
  131981. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  131982. */
  131983. _pcs: PointsCloudSystem;
  131984. /**
  131985. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  131986. */
  131987. _stillInvisible: boolean;
  131988. /**
  131989. * @hidden Last computed particle rotation matrix
  131990. */
  131991. _rotationMatrix: number[];
  131992. /**
  131993. * Parent particle Id, if any.
  131994. * Default null.
  131995. */
  131996. parentId: Nullable<number>;
  131997. /**
  131998. * @hidden Internal global position in the PCS.
  131999. */
  132000. _globalPosition: Vector3;
  132001. /**
  132002. * Creates a Point Cloud object.
  132003. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  132004. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  132005. * @param group (PointsGroup) is the group the particle belongs to
  132006. * @param groupId (integer) is the group identifier in the PCS.
  132007. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  132008. * @param pcs defines the PCS it is associated to
  132009. */
  132010. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  132011. /**
  132012. * get point size
  132013. */
  132014. get size(): Vector3;
  132015. /**
  132016. * Set point size
  132017. */
  132018. set size(scale: Vector3);
  132019. /**
  132020. * Legacy support, changed quaternion to rotationQuaternion
  132021. */
  132022. get quaternion(): Nullable<Quaternion>;
  132023. /**
  132024. * Legacy support, changed quaternion to rotationQuaternion
  132025. */
  132026. set quaternion(q: Nullable<Quaternion>);
  132027. /**
  132028. * Returns a boolean. True if the particle intersects a mesh, else false
  132029. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  132030. * @param target is the object (point or mesh) what the intersection is computed against
  132031. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  132032. * @returns true if it intersects
  132033. */
  132034. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  132035. /**
  132036. * get the rotation matrix of the particle
  132037. * @hidden
  132038. */
  132039. getRotationMatrix(m: Matrix): void;
  132040. }
  132041. /**
  132042. * Represents a group of points in a points cloud system
  132043. * * PCS internal tool, don't use it manually.
  132044. */
  132045. export class PointsGroup {
  132046. /**
  132047. * The group id
  132048. * @hidden
  132049. */
  132050. groupID: number;
  132051. /**
  132052. * image data for group (internal use)
  132053. * @hidden
  132054. */
  132055. _groupImageData: Nullable<ArrayBufferView>;
  132056. /**
  132057. * Image Width (internal use)
  132058. * @hidden
  132059. */
  132060. _groupImgWidth: number;
  132061. /**
  132062. * Image Height (internal use)
  132063. * @hidden
  132064. */
  132065. _groupImgHeight: number;
  132066. /**
  132067. * Custom position function (internal use)
  132068. * @hidden
  132069. */
  132070. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  132071. /**
  132072. * density per facet for surface points
  132073. * @hidden
  132074. */
  132075. _groupDensity: number[];
  132076. /**
  132077. * Only when points are colored by texture carries pointer to texture list array
  132078. * @hidden
  132079. */
  132080. _textureNb: number;
  132081. /**
  132082. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  132083. * PCS internal tool, don't use it manually.
  132084. * @hidden
  132085. */
  132086. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  132087. }
  132088. }
  132089. declare module BABYLON {
  132090. interface Scene {
  132091. /** @hidden (Backing field) */
  132092. _physicsEngine: Nullable<IPhysicsEngine>;
  132093. /** @hidden */
  132094. _physicsTimeAccumulator: number;
  132095. /**
  132096. * Gets the current physics engine
  132097. * @returns a IPhysicsEngine or null if none attached
  132098. */
  132099. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  132100. /**
  132101. * Enables physics to the current scene
  132102. * @param gravity defines the scene's gravity for the physics engine
  132103. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  132104. * @return a boolean indicating if the physics engine was initialized
  132105. */
  132106. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  132107. /**
  132108. * Disables and disposes the physics engine associated with the scene
  132109. */
  132110. disablePhysicsEngine(): void;
  132111. /**
  132112. * Gets a boolean indicating if there is an active physics engine
  132113. * @returns a boolean indicating if there is an active physics engine
  132114. */
  132115. isPhysicsEnabled(): boolean;
  132116. /**
  132117. * Deletes a physics compound impostor
  132118. * @param compound defines the compound to delete
  132119. */
  132120. deleteCompoundImpostor(compound: any): void;
  132121. /**
  132122. * An event triggered when physic simulation is about to be run
  132123. */
  132124. onBeforePhysicsObservable: Observable<Scene>;
  132125. /**
  132126. * An event triggered when physic simulation has been done
  132127. */
  132128. onAfterPhysicsObservable: Observable<Scene>;
  132129. }
  132130. interface AbstractMesh {
  132131. /** @hidden */
  132132. _physicsImpostor: Nullable<PhysicsImpostor>;
  132133. /**
  132134. * Gets or sets impostor used for physic simulation
  132135. * @see http://doc.babylonjs.com/features/physics_engine
  132136. */
  132137. physicsImpostor: Nullable<PhysicsImpostor>;
  132138. /**
  132139. * Gets the current physics impostor
  132140. * @see http://doc.babylonjs.com/features/physics_engine
  132141. * @returns a physics impostor or null
  132142. */
  132143. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  132144. /** Apply a physic impulse to the mesh
  132145. * @param force defines the force to apply
  132146. * @param contactPoint defines where to apply the force
  132147. * @returns the current mesh
  132148. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  132149. */
  132150. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  132151. /**
  132152. * Creates a physic joint between two meshes
  132153. * @param otherMesh defines the other mesh to use
  132154. * @param pivot1 defines the pivot to use on this mesh
  132155. * @param pivot2 defines the pivot to use on the other mesh
  132156. * @param options defines additional options (can be plugin dependent)
  132157. * @returns the current mesh
  132158. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  132159. */
  132160. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  132161. /** @hidden */
  132162. _disposePhysicsObserver: Nullable<Observer<Node>>;
  132163. }
  132164. /**
  132165. * Defines the physics engine scene component responsible to manage a physics engine
  132166. */
  132167. export class PhysicsEngineSceneComponent implements ISceneComponent {
  132168. /**
  132169. * The component name helpful to identify the component in the list of scene components.
  132170. */
  132171. readonly name: string;
  132172. /**
  132173. * The scene the component belongs to.
  132174. */
  132175. scene: Scene;
  132176. /**
  132177. * Creates a new instance of the component for the given scene
  132178. * @param scene Defines the scene to register the component in
  132179. */
  132180. constructor(scene: Scene);
  132181. /**
  132182. * Registers the component in a given scene
  132183. */
  132184. register(): void;
  132185. /**
  132186. * Rebuilds the elements related to this component in case of
  132187. * context lost for instance.
  132188. */
  132189. rebuild(): void;
  132190. /**
  132191. * Disposes the component and the associated ressources
  132192. */
  132193. dispose(): void;
  132194. }
  132195. }
  132196. declare module BABYLON {
  132197. /**
  132198. * A helper for physics simulations
  132199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132200. */
  132201. export class PhysicsHelper {
  132202. private _scene;
  132203. private _physicsEngine;
  132204. /**
  132205. * Initializes the Physics helper
  132206. * @param scene Babylon.js scene
  132207. */
  132208. constructor(scene: Scene);
  132209. /**
  132210. * Applies a radial explosion impulse
  132211. * @param origin the origin of the explosion
  132212. * @param radiusOrEventOptions the radius or the options of radial explosion
  132213. * @param strength the explosion strength
  132214. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132215. * @returns A physics radial explosion event, or null
  132216. */
  132217. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132218. /**
  132219. * Applies a radial explosion force
  132220. * @param origin the origin of the explosion
  132221. * @param radiusOrEventOptions the radius or the options of radial explosion
  132222. * @param strength the explosion strength
  132223. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132224. * @returns A physics radial explosion event, or null
  132225. */
  132226. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132227. /**
  132228. * Creates a gravitational field
  132229. * @param origin the origin of the explosion
  132230. * @param radiusOrEventOptions the radius or the options of radial explosion
  132231. * @param strength the explosion strength
  132232. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132233. * @returns A physics gravitational field event, or null
  132234. */
  132235. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  132236. /**
  132237. * Creates a physics updraft event
  132238. * @param origin the origin of the updraft
  132239. * @param radiusOrEventOptions the radius or the options of the updraft
  132240. * @param strength the strength of the updraft
  132241. * @param height the height of the updraft
  132242. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  132243. * @returns A physics updraft event, or null
  132244. */
  132245. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  132246. /**
  132247. * Creates a physics vortex event
  132248. * @param origin the of the vortex
  132249. * @param radiusOrEventOptions the radius or the options of the vortex
  132250. * @param strength the strength of the vortex
  132251. * @param height the height of the vortex
  132252. * @returns a Physics vortex event, or null
  132253. * A physics vortex event or null
  132254. */
  132255. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  132256. }
  132257. /**
  132258. * Represents a physics radial explosion event
  132259. */
  132260. class PhysicsRadialExplosionEvent {
  132261. private _scene;
  132262. private _options;
  132263. private _sphere;
  132264. private _dataFetched;
  132265. /**
  132266. * Initializes a radial explosioin event
  132267. * @param _scene BabylonJS scene
  132268. * @param _options The options for the vortex event
  132269. */
  132270. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  132271. /**
  132272. * Returns the data related to the radial explosion event (sphere).
  132273. * @returns The radial explosion event data
  132274. */
  132275. getData(): PhysicsRadialExplosionEventData;
  132276. /**
  132277. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  132278. * @param impostor A physics imposter
  132279. * @param origin the origin of the explosion
  132280. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  132281. */
  132282. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  132283. /**
  132284. * Triggers affecterd impostors callbacks
  132285. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  132286. */
  132287. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  132288. /**
  132289. * Disposes the sphere.
  132290. * @param force Specifies if the sphere should be disposed by force
  132291. */
  132292. dispose(force?: boolean): void;
  132293. /*** Helpers ***/
  132294. private _prepareSphere;
  132295. private _intersectsWithSphere;
  132296. }
  132297. /**
  132298. * Represents a gravitational field event
  132299. */
  132300. class PhysicsGravitationalFieldEvent {
  132301. private _physicsHelper;
  132302. private _scene;
  132303. private _origin;
  132304. private _options;
  132305. private _tickCallback;
  132306. private _sphere;
  132307. private _dataFetched;
  132308. /**
  132309. * Initializes the physics gravitational field event
  132310. * @param _physicsHelper A physics helper
  132311. * @param _scene BabylonJS scene
  132312. * @param _origin The origin position of the gravitational field event
  132313. * @param _options The options for the vortex event
  132314. */
  132315. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  132316. /**
  132317. * Returns the data related to the gravitational field event (sphere).
  132318. * @returns A gravitational field event
  132319. */
  132320. getData(): PhysicsGravitationalFieldEventData;
  132321. /**
  132322. * Enables the gravitational field.
  132323. */
  132324. enable(): void;
  132325. /**
  132326. * Disables the gravitational field.
  132327. */
  132328. disable(): void;
  132329. /**
  132330. * Disposes the sphere.
  132331. * @param force The force to dispose from the gravitational field event
  132332. */
  132333. dispose(force?: boolean): void;
  132334. private _tick;
  132335. }
  132336. /**
  132337. * Represents a physics updraft event
  132338. */
  132339. class PhysicsUpdraftEvent {
  132340. private _scene;
  132341. private _origin;
  132342. private _options;
  132343. private _physicsEngine;
  132344. private _originTop;
  132345. private _originDirection;
  132346. private _tickCallback;
  132347. private _cylinder;
  132348. private _cylinderPosition;
  132349. private _dataFetched;
  132350. /**
  132351. * Initializes the physics updraft event
  132352. * @param _scene BabylonJS scene
  132353. * @param _origin The origin position of the updraft
  132354. * @param _options The options for the updraft event
  132355. */
  132356. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  132357. /**
  132358. * Returns the data related to the updraft event (cylinder).
  132359. * @returns A physics updraft event
  132360. */
  132361. getData(): PhysicsUpdraftEventData;
  132362. /**
  132363. * Enables the updraft.
  132364. */
  132365. enable(): void;
  132366. /**
  132367. * Disables the updraft.
  132368. */
  132369. disable(): void;
  132370. /**
  132371. * Disposes the cylinder.
  132372. * @param force Specifies if the updraft should be disposed by force
  132373. */
  132374. dispose(force?: boolean): void;
  132375. private getImpostorHitData;
  132376. private _tick;
  132377. /*** Helpers ***/
  132378. private _prepareCylinder;
  132379. private _intersectsWithCylinder;
  132380. }
  132381. /**
  132382. * Represents a physics vortex event
  132383. */
  132384. class PhysicsVortexEvent {
  132385. private _scene;
  132386. private _origin;
  132387. private _options;
  132388. private _physicsEngine;
  132389. private _originTop;
  132390. private _tickCallback;
  132391. private _cylinder;
  132392. private _cylinderPosition;
  132393. private _dataFetched;
  132394. /**
  132395. * Initializes the physics vortex event
  132396. * @param _scene The BabylonJS scene
  132397. * @param _origin The origin position of the vortex
  132398. * @param _options The options for the vortex event
  132399. */
  132400. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  132401. /**
  132402. * Returns the data related to the vortex event (cylinder).
  132403. * @returns The physics vortex event data
  132404. */
  132405. getData(): PhysicsVortexEventData;
  132406. /**
  132407. * Enables the vortex.
  132408. */
  132409. enable(): void;
  132410. /**
  132411. * Disables the cortex.
  132412. */
  132413. disable(): void;
  132414. /**
  132415. * Disposes the sphere.
  132416. * @param force
  132417. */
  132418. dispose(force?: boolean): void;
  132419. private getImpostorHitData;
  132420. private _tick;
  132421. /*** Helpers ***/
  132422. private _prepareCylinder;
  132423. private _intersectsWithCylinder;
  132424. }
  132425. /**
  132426. * Options fot the radial explosion event
  132427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132428. */
  132429. export class PhysicsRadialExplosionEventOptions {
  132430. /**
  132431. * The radius of the sphere for the radial explosion.
  132432. */
  132433. radius: number;
  132434. /**
  132435. * The strenth of the explosion.
  132436. */
  132437. strength: number;
  132438. /**
  132439. * The strenght of the force in correspondence to the distance of the affected object
  132440. */
  132441. falloff: PhysicsRadialImpulseFalloff;
  132442. /**
  132443. * Sphere options for the radial explosion.
  132444. */
  132445. sphere: {
  132446. segments: number;
  132447. diameter: number;
  132448. };
  132449. /**
  132450. * Sphere options for the radial explosion.
  132451. */
  132452. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  132453. }
  132454. /**
  132455. * Options fot the updraft event
  132456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132457. */
  132458. export class PhysicsUpdraftEventOptions {
  132459. /**
  132460. * The radius of the cylinder for the vortex
  132461. */
  132462. radius: number;
  132463. /**
  132464. * The strenth of the updraft.
  132465. */
  132466. strength: number;
  132467. /**
  132468. * The height of the cylinder for the updraft.
  132469. */
  132470. height: number;
  132471. /**
  132472. * The mode for the the updraft.
  132473. */
  132474. updraftMode: PhysicsUpdraftMode;
  132475. }
  132476. /**
  132477. * Options fot the vortex event
  132478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132479. */
  132480. export class PhysicsVortexEventOptions {
  132481. /**
  132482. * The radius of the cylinder for the vortex
  132483. */
  132484. radius: number;
  132485. /**
  132486. * The strenth of the vortex.
  132487. */
  132488. strength: number;
  132489. /**
  132490. * The height of the cylinder for the vortex.
  132491. */
  132492. height: number;
  132493. /**
  132494. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  132495. */
  132496. centripetalForceThreshold: number;
  132497. /**
  132498. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  132499. */
  132500. centripetalForceMultiplier: number;
  132501. /**
  132502. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  132503. */
  132504. centrifugalForceMultiplier: number;
  132505. /**
  132506. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  132507. */
  132508. updraftForceMultiplier: number;
  132509. }
  132510. /**
  132511. * The strenght of the force in correspondence to the distance of the affected object
  132512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132513. */
  132514. export enum PhysicsRadialImpulseFalloff {
  132515. /** Defines that impulse is constant in strength across it's whole radius */
  132516. Constant = 0,
  132517. /** Defines that impulse gets weaker if it's further from the origin */
  132518. Linear = 1
  132519. }
  132520. /**
  132521. * The strength of the force in correspondence to the distance of the affected object
  132522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132523. */
  132524. export enum PhysicsUpdraftMode {
  132525. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  132526. Center = 0,
  132527. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  132528. Perpendicular = 1
  132529. }
  132530. /**
  132531. * Interface for a physics hit data
  132532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132533. */
  132534. export interface PhysicsHitData {
  132535. /**
  132536. * The force applied at the contact point
  132537. */
  132538. force: Vector3;
  132539. /**
  132540. * The contact point
  132541. */
  132542. contactPoint: Vector3;
  132543. /**
  132544. * The distance from the origin to the contact point
  132545. */
  132546. distanceFromOrigin: number;
  132547. }
  132548. /**
  132549. * Interface for radial explosion event data
  132550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132551. */
  132552. export interface PhysicsRadialExplosionEventData {
  132553. /**
  132554. * A sphere used for the radial explosion event
  132555. */
  132556. sphere: Mesh;
  132557. }
  132558. /**
  132559. * Interface for gravitational field event data
  132560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132561. */
  132562. export interface PhysicsGravitationalFieldEventData {
  132563. /**
  132564. * A sphere mesh used for the gravitational field event
  132565. */
  132566. sphere: Mesh;
  132567. }
  132568. /**
  132569. * Interface for updraft event data
  132570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132571. */
  132572. export interface PhysicsUpdraftEventData {
  132573. /**
  132574. * A cylinder used for the updraft event
  132575. */
  132576. cylinder: Mesh;
  132577. }
  132578. /**
  132579. * Interface for vortex event data
  132580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132581. */
  132582. export interface PhysicsVortexEventData {
  132583. /**
  132584. * A cylinder used for the vortex event
  132585. */
  132586. cylinder: Mesh;
  132587. }
  132588. /**
  132589. * Interface for an affected physics impostor
  132590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132591. */
  132592. export interface PhysicsAffectedImpostorWithData {
  132593. /**
  132594. * The impostor affected by the effect
  132595. */
  132596. impostor: PhysicsImpostor;
  132597. /**
  132598. * The data about the hit/horce from the explosion
  132599. */
  132600. hitData: PhysicsHitData;
  132601. }
  132602. }
  132603. declare module BABYLON {
  132604. /** @hidden */
  132605. export var blackAndWhitePixelShader: {
  132606. name: string;
  132607. shader: string;
  132608. };
  132609. }
  132610. declare module BABYLON {
  132611. /**
  132612. * Post process used to render in black and white
  132613. */
  132614. export class BlackAndWhitePostProcess extends PostProcess {
  132615. /**
  132616. * Linear about to convert he result to black and white (default: 1)
  132617. */
  132618. degree: number;
  132619. /**
  132620. * Creates a black and white post process
  132621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  132622. * @param name The name of the effect.
  132623. * @param options The required width/height ratio to downsize to before computing the render pass.
  132624. * @param camera The camera to apply the render pass to.
  132625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132626. * @param engine The engine which the post process will be applied. (default: current engine)
  132627. * @param reusable If the post process can be reused on the same frame. (default: false)
  132628. */
  132629. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132630. }
  132631. }
  132632. declare module BABYLON {
  132633. /**
  132634. * This represents a set of one or more post processes in Babylon.
  132635. * A post process can be used to apply a shader to a texture after it is rendered.
  132636. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132637. */
  132638. export class PostProcessRenderEffect {
  132639. private _postProcesses;
  132640. private _getPostProcesses;
  132641. private _singleInstance;
  132642. private _cameras;
  132643. private _indicesForCamera;
  132644. /**
  132645. * Name of the effect
  132646. * @hidden
  132647. */
  132648. _name: string;
  132649. /**
  132650. * Instantiates a post process render effect.
  132651. * A post process can be used to apply a shader to a texture after it is rendered.
  132652. * @param engine The engine the effect is tied to
  132653. * @param name The name of the effect
  132654. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  132655. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  132656. */
  132657. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  132658. /**
  132659. * Checks if all the post processes in the effect are supported.
  132660. */
  132661. get isSupported(): boolean;
  132662. /**
  132663. * Updates the current state of the effect
  132664. * @hidden
  132665. */
  132666. _update(): void;
  132667. /**
  132668. * Attaches the effect on cameras
  132669. * @param cameras The camera to attach to.
  132670. * @hidden
  132671. */
  132672. _attachCameras(cameras: Camera): void;
  132673. /**
  132674. * Attaches the effect on cameras
  132675. * @param cameras The camera to attach to.
  132676. * @hidden
  132677. */
  132678. _attachCameras(cameras: Camera[]): void;
  132679. /**
  132680. * Detaches the effect on cameras
  132681. * @param cameras The camera to detatch from.
  132682. * @hidden
  132683. */
  132684. _detachCameras(cameras: Camera): void;
  132685. /**
  132686. * Detatches the effect on cameras
  132687. * @param cameras The camera to detatch from.
  132688. * @hidden
  132689. */
  132690. _detachCameras(cameras: Camera[]): void;
  132691. /**
  132692. * Enables the effect on given cameras
  132693. * @param cameras The camera to enable.
  132694. * @hidden
  132695. */
  132696. _enable(cameras: Camera): void;
  132697. /**
  132698. * Enables the effect on given cameras
  132699. * @param cameras The camera to enable.
  132700. * @hidden
  132701. */
  132702. _enable(cameras: Nullable<Camera[]>): void;
  132703. /**
  132704. * Disables the effect on the given cameras
  132705. * @param cameras The camera to disable.
  132706. * @hidden
  132707. */
  132708. _disable(cameras: Camera): void;
  132709. /**
  132710. * Disables the effect on the given cameras
  132711. * @param cameras The camera to disable.
  132712. * @hidden
  132713. */
  132714. _disable(cameras: Nullable<Camera[]>): void;
  132715. /**
  132716. * Gets a list of the post processes contained in the effect.
  132717. * @param camera The camera to get the post processes on.
  132718. * @returns The list of the post processes in the effect.
  132719. */
  132720. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  132721. }
  132722. }
  132723. declare module BABYLON {
  132724. /** @hidden */
  132725. export var extractHighlightsPixelShader: {
  132726. name: string;
  132727. shader: string;
  132728. };
  132729. }
  132730. declare module BABYLON {
  132731. /**
  132732. * 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.
  132733. */
  132734. export class ExtractHighlightsPostProcess extends PostProcess {
  132735. /**
  132736. * The luminance threshold, pixels below this value will be set to black.
  132737. */
  132738. threshold: number;
  132739. /** @hidden */
  132740. _exposure: number;
  132741. /**
  132742. * Post process which has the input texture to be used when performing highlight extraction
  132743. * @hidden
  132744. */
  132745. _inputPostProcess: Nullable<PostProcess>;
  132746. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132747. }
  132748. }
  132749. declare module BABYLON {
  132750. /** @hidden */
  132751. export var bloomMergePixelShader: {
  132752. name: string;
  132753. shader: string;
  132754. };
  132755. }
  132756. declare module BABYLON {
  132757. /**
  132758. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  132759. */
  132760. export class BloomMergePostProcess extends PostProcess {
  132761. /** Weight of the bloom to be added to the original input. */
  132762. weight: number;
  132763. /**
  132764. * Creates a new instance of @see BloomMergePostProcess
  132765. * @param name The name of the effect.
  132766. * @param originalFromInput Post process which's input will be used for the merge.
  132767. * @param blurred Blurred highlights post process which's output will be used.
  132768. * @param weight Weight of the bloom to be added to the original input.
  132769. * @param options The required width/height ratio to downsize to before computing the render pass.
  132770. * @param camera The camera to apply the render pass to.
  132771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132772. * @param engine The engine which the post process will be applied. (default: current engine)
  132773. * @param reusable If the post process can be reused on the same frame. (default: false)
  132774. * @param textureType Type of textures used when performing the post process. (default: 0)
  132775. * @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)
  132776. */
  132777. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  132778. /** Weight of the bloom to be added to the original input. */
  132779. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132780. }
  132781. }
  132782. declare module BABYLON {
  132783. /**
  132784. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  132785. */
  132786. export class BloomEffect extends PostProcessRenderEffect {
  132787. private bloomScale;
  132788. /**
  132789. * @hidden Internal
  132790. */
  132791. _effects: Array<PostProcess>;
  132792. /**
  132793. * @hidden Internal
  132794. */
  132795. _downscale: ExtractHighlightsPostProcess;
  132796. private _blurX;
  132797. private _blurY;
  132798. private _merge;
  132799. /**
  132800. * The luminance threshold to find bright areas of the image to bloom.
  132801. */
  132802. get threshold(): number;
  132803. set threshold(value: number);
  132804. /**
  132805. * The strength of the bloom.
  132806. */
  132807. get weight(): number;
  132808. set weight(value: number);
  132809. /**
  132810. * Specifies the size of the bloom blur kernel, relative to the final output size
  132811. */
  132812. get kernel(): number;
  132813. set kernel(value: number);
  132814. /**
  132815. * Creates a new instance of @see BloomEffect
  132816. * @param scene The scene the effect belongs to.
  132817. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  132818. * @param bloomKernel The size of the kernel to be used when applying the blur.
  132819. * @param bloomWeight The the strength of bloom.
  132820. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  132821. * @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)
  132822. */
  132823. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  132824. /**
  132825. * Disposes each of the internal effects for a given camera.
  132826. * @param camera The camera to dispose the effect on.
  132827. */
  132828. disposeEffects(camera: Camera): void;
  132829. /**
  132830. * @hidden Internal
  132831. */
  132832. _updateEffects(): void;
  132833. /**
  132834. * Internal
  132835. * @returns if all the contained post processes are ready.
  132836. * @hidden
  132837. */
  132838. _isReady(): boolean;
  132839. }
  132840. }
  132841. declare module BABYLON {
  132842. /** @hidden */
  132843. export var chromaticAberrationPixelShader: {
  132844. name: string;
  132845. shader: string;
  132846. };
  132847. }
  132848. declare module BABYLON {
  132849. /**
  132850. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  132851. */
  132852. export class ChromaticAberrationPostProcess extends PostProcess {
  132853. /**
  132854. * The amount of seperation of rgb channels (default: 30)
  132855. */
  132856. aberrationAmount: number;
  132857. /**
  132858. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  132859. */
  132860. radialIntensity: number;
  132861. /**
  132862. * 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))
  132863. */
  132864. direction: Vector2;
  132865. /**
  132866. * 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))
  132867. */
  132868. centerPosition: Vector2;
  132869. /**
  132870. * Creates a new instance ChromaticAberrationPostProcess
  132871. * @param name The name of the effect.
  132872. * @param screenWidth The width of the screen to apply the effect on.
  132873. * @param screenHeight The height of the screen to apply the effect on.
  132874. * @param options The required width/height ratio to downsize to before computing the render pass.
  132875. * @param camera The camera to apply the render pass to.
  132876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132877. * @param engine The engine which the post process will be applied. (default: current engine)
  132878. * @param reusable If the post process can be reused on the same frame. (default: false)
  132879. * @param textureType Type of textures used when performing the post process. (default: 0)
  132880. * @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)
  132881. */
  132882. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132883. }
  132884. }
  132885. declare module BABYLON {
  132886. /** @hidden */
  132887. export var circleOfConfusionPixelShader: {
  132888. name: string;
  132889. shader: string;
  132890. };
  132891. }
  132892. declare module BABYLON {
  132893. /**
  132894. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  132895. */
  132896. export class CircleOfConfusionPostProcess extends PostProcess {
  132897. /**
  132898. * 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.
  132899. */
  132900. lensSize: number;
  132901. /**
  132902. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  132903. */
  132904. fStop: number;
  132905. /**
  132906. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  132907. */
  132908. focusDistance: number;
  132909. /**
  132910. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  132911. */
  132912. focalLength: number;
  132913. private _depthTexture;
  132914. /**
  132915. * Creates a new instance CircleOfConfusionPostProcess
  132916. * @param name The name of the effect.
  132917. * @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.
  132918. * @param options The required width/height ratio to downsize to before computing the render pass.
  132919. * @param camera The camera to apply the render pass to.
  132920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132921. * @param engine The engine which the post process will be applied. (default: current engine)
  132922. * @param reusable If the post process can be reused on the same frame. (default: false)
  132923. * @param textureType Type of textures used when performing the post process. (default: 0)
  132924. * @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)
  132925. */
  132926. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132927. /**
  132928. * 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.
  132929. */
  132930. set depthTexture(value: RenderTargetTexture);
  132931. }
  132932. }
  132933. declare module BABYLON {
  132934. /** @hidden */
  132935. export var colorCorrectionPixelShader: {
  132936. name: string;
  132937. shader: string;
  132938. };
  132939. }
  132940. declare module BABYLON {
  132941. /**
  132942. *
  132943. * This post-process allows the modification of rendered colors by using
  132944. * a 'look-up table' (LUT). This effect is also called Color Grading.
  132945. *
  132946. * The object needs to be provided an url to a texture containing the color
  132947. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  132948. * Use an image editing software to tweak the LUT to match your needs.
  132949. *
  132950. * For an example of a color LUT, see here:
  132951. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  132952. * For explanations on color grading, see here:
  132953. * @see http://udn.epicgames.com/Three/ColorGrading.html
  132954. *
  132955. */
  132956. export class ColorCorrectionPostProcess extends PostProcess {
  132957. private _colorTableTexture;
  132958. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132959. }
  132960. }
  132961. declare module BABYLON {
  132962. /** @hidden */
  132963. export var convolutionPixelShader: {
  132964. name: string;
  132965. shader: string;
  132966. };
  132967. }
  132968. declare module BABYLON {
  132969. /**
  132970. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  132971. * input texture to perform effects such as edge detection or sharpening
  132972. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  132973. */
  132974. export class ConvolutionPostProcess extends PostProcess {
  132975. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  132976. kernel: number[];
  132977. /**
  132978. * Creates a new instance ConvolutionPostProcess
  132979. * @param name The name of the effect.
  132980. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  132981. * @param options The required width/height ratio to downsize to before computing the render pass.
  132982. * @param camera The camera to apply the render pass to.
  132983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132984. * @param engine The engine which the post process will be applied. (default: current engine)
  132985. * @param reusable If the post process can be reused on the same frame. (default: false)
  132986. * @param textureType Type of textures used when performing the post process. (default: 0)
  132987. */
  132988. constructor(name: string,
  132989. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  132990. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  132991. /**
  132992. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132993. */
  132994. static EdgeDetect0Kernel: number[];
  132995. /**
  132996. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132997. */
  132998. static EdgeDetect1Kernel: number[];
  132999. /**
  133000. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133001. */
  133002. static EdgeDetect2Kernel: number[];
  133003. /**
  133004. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133005. */
  133006. static SharpenKernel: number[];
  133007. /**
  133008. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133009. */
  133010. static EmbossKernel: number[];
  133011. /**
  133012. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133013. */
  133014. static GaussianKernel: number[];
  133015. }
  133016. }
  133017. declare module BABYLON {
  133018. /**
  133019. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  133020. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  133021. * based on samples that have a large difference in distance than the center pixel.
  133022. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  133023. */
  133024. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  133025. direction: Vector2;
  133026. /**
  133027. * Creates a new instance CircleOfConfusionPostProcess
  133028. * @param name The name of the effect.
  133029. * @param scene The scene the effect belongs to.
  133030. * @param direction The direction the blur should be applied.
  133031. * @param kernel The size of the kernel used to blur.
  133032. * @param options The required width/height ratio to downsize to before computing the render pass.
  133033. * @param camera The camera to apply the render pass to.
  133034. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  133035. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  133036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133037. * @param engine The engine which the post process will be applied. (default: current engine)
  133038. * @param reusable If the post process can be reused on the same frame. (default: false)
  133039. * @param textureType Type of textures used when performing the post process. (default: 0)
  133040. * @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)
  133041. */
  133042. 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);
  133043. }
  133044. }
  133045. declare module BABYLON {
  133046. /** @hidden */
  133047. export var depthOfFieldMergePixelShader: {
  133048. name: string;
  133049. shader: string;
  133050. };
  133051. }
  133052. declare module BABYLON {
  133053. /**
  133054. * Options to be set when merging outputs from the default pipeline.
  133055. */
  133056. export class DepthOfFieldMergePostProcessOptions {
  133057. /**
  133058. * The original image to merge on top of
  133059. */
  133060. originalFromInput: PostProcess;
  133061. /**
  133062. * Parameters to perform the merge of the depth of field effect
  133063. */
  133064. depthOfField?: {
  133065. circleOfConfusion: PostProcess;
  133066. blurSteps: Array<PostProcess>;
  133067. };
  133068. /**
  133069. * Parameters to perform the merge of bloom effect
  133070. */
  133071. bloom?: {
  133072. blurred: PostProcess;
  133073. weight: number;
  133074. };
  133075. }
  133076. /**
  133077. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  133078. */
  133079. export class DepthOfFieldMergePostProcess extends PostProcess {
  133080. private blurSteps;
  133081. /**
  133082. * Creates a new instance of DepthOfFieldMergePostProcess
  133083. * @param name The name of the effect.
  133084. * @param originalFromInput Post process which's input will be used for the merge.
  133085. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  133086. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  133087. * @param options The required width/height ratio to downsize to before computing the render pass.
  133088. * @param camera The camera to apply the render pass to.
  133089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133090. * @param engine The engine which the post process will be applied. (default: current engine)
  133091. * @param reusable If the post process can be reused on the same frame. (default: false)
  133092. * @param textureType Type of textures used when performing the post process. (default: 0)
  133093. * @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)
  133094. */
  133095. 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);
  133096. /**
  133097. * Updates the effect with the current post process compile time values and recompiles the shader.
  133098. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  133099. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  133100. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  133101. * @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
  133102. * @param onCompiled Called when the shader has been compiled.
  133103. * @param onError Called if there is an error when compiling a shader.
  133104. */
  133105. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  133106. }
  133107. }
  133108. declare module BABYLON {
  133109. /**
  133110. * Specifies the level of max blur that should be applied when using the depth of field effect
  133111. */
  133112. export enum DepthOfFieldEffectBlurLevel {
  133113. /**
  133114. * Subtle blur
  133115. */
  133116. Low = 0,
  133117. /**
  133118. * Medium blur
  133119. */
  133120. Medium = 1,
  133121. /**
  133122. * Large blur
  133123. */
  133124. High = 2
  133125. }
  133126. /**
  133127. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  133128. */
  133129. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  133130. private _circleOfConfusion;
  133131. /**
  133132. * @hidden Internal, blurs from high to low
  133133. */
  133134. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  133135. private _depthOfFieldBlurY;
  133136. private _dofMerge;
  133137. /**
  133138. * @hidden Internal post processes in depth of field effect
  133139. */
  133140. _effects: Array<PostProcess>;
  133141. /**
  133142. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  133143. */
  133144. set focalLength(value: number);
  133145. get focalLength(): number;
  133146. /**
  133147. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133148. */
  133149. set fStop(value: number);
  133150. get fStop(): number;
  133151. /**
  133152. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133153. */
  133154. set focusDistance(value: number);
  133155. get focusDistance(): number;
  133156. /**
  133157. * 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.
  133158. */
  133159. set lensSize(value: number);
  133160. get lensSize(): number;
  133161. /**
  133162. * Creates a new instance DepthOfFieldEffect
  133163. * @param scene The scene the effect belongs to.
  133164. * @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.
  133165. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  133166. * @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)
  133167. */
  133168. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  133169. /**
  133170. * Get the current class name of the current effet
  133171. * @returns "DepthOfFieldEffect"
  133172. */
  133173. getClassName(): string;
  133174. /**
  133175. * 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.
  133176. */
  133177. set depthTexture(value: RenderTargetTexture);
  133178. /**
  133179. * Disposes each of the internal effects for a given camera.
  133180. * @param camera The camera to dispose the effect on.
  133181. */
  133182. disposeEffects(camera: Camera): void;
  133183. /**
  133184. * @hidden Internal
  133185. */
  133186. _updateEffects(): void;
  133187. /**
  133188. * Internal
  133189. * @returns if all the contained post processes are ready.
  133190. * @hidden
  133191. */
  133192. _isReady(): boolean;
  133193. }
  133194. }
  133195. declare module BABYLON {
  133196. /** @hidden */
  133197. export var displayPassPixelShader: {
  133198. name: string;
  133199. shader: string;
  133200. };
  133201. }
  133202. declare module BABYLON {
  133203. /**
  133204. * DisplayPassPostProcess which produces an output the same as it's input
  133205. */
  133206. export class DisplayPassPostProcess extends PostProcess {
  133207. /**
  133208. * Creates the DisplayPassPostProcess
  133209. * @param name The name of the effect.
  133210. * @param options The required width/height ratio to downsize to before computing the render pass.
  133211. * @param camera The camera to apply the render pass to.
  133212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133213. * @param engine The engine which the post process will be applied. (default: current engine)
  133214. * @param reusable If the post process can be reused on the same frame. (default: false)
  133215. */
  133216. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133217. }
  133218. }
  133219. declare module BABYLON {
  133220. /** @hidden */
  133221. export var filterPixelShader: {
  133222. name: string;
  133223. shader: string;
  133224. };
  133225. }
  133226. declare module BABYLON {
  133227. /**
  133228. * Applies a kernel filter to the image
  133229. */
  133230. export class FilterPostProcess extends PostProcess {
  133231. /** The matrix to be applied to the image */
  133232. kernelMatrix: Matrix;
  133233. /**
  133234. *
  133235. * @param name The name of the effect.
  133236. * @param kernelMatrix The matrix to be applied to the image
  133237. * @param options The required width/height ratio to downsize to before computing the render pass.
  133238. * @param camera The camera to apply the render pass to.
  133239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133240. * @param engine The engine which the post process will be applied. (default: current engine)
  133241. * @param reusable If the post process can be reused on the same frame. (default: false)
  133242. */
  133243. constructor(name: string,
  133244. /** The matrix to be applied to the image */
  133245. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133246. }
  133247. }
  133248. declare module BABYLON {
  133249. /** @hidden */
  133250. export var fxaaPixelShader: {
  133251. name: string;
  133252. shader: string;
  133253. };
  133254. }
  133255. declare module BABYLON {
  133256. /** @hidden */
  133257. export var fxaaVertexShader: {
  133258. name: string;
  133259. shader: string;
  133260. };
  133261. }
  133262. declare module BABYLON {
  133263. /**
  133264. * Fxaa post process
  133265. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  133266. */
  133267. export class FxaaPostProcess extends PostProcess {
  133268. /** @hidden */
  133269. texelWidth: number;
  133270. /** @hidden */
  133271. texelHeight: number;
  133272. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133273. private _getDefines;
  133274. }
  133275. }
  133276. declare module BABYLON {
  133277. /** @hidden */
  133278. export var grainPixelShader: {
  133279. name: string;
  133280. shader: string;
  133281. };
  133282. }
  133283. declare module BABYLON {
  133284. /**
  133285. * The GrainPostProcess adds noise to the image at mid luminance levels
  133286. */
  133287. export class GrainPostProcess extends PostProcess {
  133288. /**
  133289. * The intensity of the grain added (default: 30)
  133290. */
  133291. intensity: number;
  133292. /**
  133293. * If the grain should be randomized on every frame
  133294. */
  133295. animated: boolean;
  133296. /**
  133297. * Creates a new instance of @see GrainPostProcess
  133298. * @param name The name of the effect.
  133299. * @param options The required width/height ratio to downsize to before computing the render pass.
  133300. * @param camera The camera to apply the render pass to.
  133301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133302. * @param engine The engine which the post process will be applied. (default: current engine)
  133303. * @param reusable If the post process can be reused on the same frame. (default: false)
  133304. * @param textureType Type of textures used when performing the post process. (default: 0)
  133305. * @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)
  133306. */
  133307. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133308. }
  133309. }
  133310. declare module BABYLON {
  133311. /** @hidden */
  133312. export var highlightsPixelShader: {
  133313. name: string;
  133314. shader: string;
  133315. };
  133316. }
  133317. declare module BABYLON {
  133318. /**
  133319. * Extracts highlights from the image
  133320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133321. */
  133322. export class HighlightsPostProcess extends PostProcess {
  133323. /**
  133324. * Extracts highlights from the image
  133325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133326. * @param name The name of the effect.
  133327. * @param options The required width/height ratio to downsize to before computing the render pass.
  133328. * @param camera The camera to apply the render pass to.
  133329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133330. * @param engine The engine which the post process will be applied. (default: current engine)
  133331. * @param reusable If the post process can be reused on the same frame. (default: false)
  133332. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  133333. */
  133334. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133335. }
  133336. }
  133337. declare module BABYLON {
  133338. /** @hidden */
  133339. export var mrtFragmentDeclaration: {
  133340. name: string;
  133341. shader: string;
  133342. };
  133343. }
  133344. declare module BABYLON {
  133345. /** @hidden */
  133346. export var geometryPixelShader: {
  133347. name: string;
  133348. shader: string;
  133349. };
  133350. }
  133351. declare module BABYLON {
  133352. /** @hidden */
  133353. export var geometryVertexShader: {
  133354. name: string;
  133355. shader: string;
  133356. };
  133357. }
  133358. declare module BABYLON {
  133359. /** @hidden */
  133360. interface ISavedTransformationMatrix {
  133361. world: Matrix;
  133362. viewProjection: Matrix;
  133363. }
  133364. /**
  133365. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  133366. */
  133367. export class GeometryBufferRenderer {
  133368. /**
  133369. * Constant used to retrieve the position texture index in the G-Buffer textures array
  133370. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  133371. */
  133372. static readonly POSITION_TEXTURE_TYPE: number;
  133373. /**
  133374. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  133375. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  133376. */
  133377. static readonly VELOCITY_TEXTURE_TYPE: number;
  133378. /**
  133379. * Dictionary used to store the previous transformation matrices of each rendered mesh
  133380. * in order to compute objects velocities when enableVelocity is set to "true"
  133381. * @hidden
  133382. */
  133383. _previousTransformationMatrices: {
  133384. [index: number]: ISavedTransformationMatrix;
  133385. };
  133386. /**
  133387. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  133388. * in order to compute objects velocities when enableVelocity is set to "true"
  133389. * @hidden
  133390. */
  133391. _previousBonesTransformationMatrices: {
  133392. [index: number]: Float32Array;
  133393. };
  133394. /**
  133395. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  133396. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  133397. */
  133398. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  133399. private _scene;
  133400. private _multiRenderTarget;
  133401. private _ratio;
  133402. private _enablePosition;
  133403. private _enableVelocity;
  133404. private _positionIndex;
  133405. private _velocityIndex;
  133406. protected _effect: Effect;
  133407. protected _cachedDefines: string;
  133408. /**
  133409. * Set the render list (meshes to be rendered) used in the G buffer.
  133410. */
  133411. set renderList(meshes: Mesh[]);
  133412. /**
  133413. * Gets wether or not G buffer are supported by the running hardware.
  133414. * This requires draw buffer supports
  133415. */
  133416. get isSupported(): boolean;
  133417. /**
  133418. * Returns the index of the given texture type in the G-Buffer textures array
  133419. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  133420. * @returns the index of the given texture type in the G-Buffer textures array
  133421. */
  133422. getTextureIndex(textureType: number): number;
  133423. /**
  133424. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  133425. */
  133426. get enablePosition(): boolean;
  133427. /**
  133428. * Sets whether or not objects positions are enabled for the G buffer.
  133429. */
  133430. set enablePosition(enable: boolean);
  133431. /**
  133432. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  133433. */
  133434. get enableVelocity(): boolean;
  133435. /**
  133436. * Sets wether or not objects velocities are enabled for the G buffer.
  133437. */
  133438. set enableVelocity(enable: boolean);
  133439. /**
  133440. * Gets the scene associated with the buffer.
  133441. */
  133442. get scene(): Scene;
  133443. /**
  133444. * Gets the ratio used by the buffer during its creation.
  133445. * How big is the buffer related to the main canvas.
  133446. */
  133447. get ratio(): number;
  133448. /** @hidden */
  133449. static _SceneComponentInitialization: (scene: Scene) => void;
  133450. /**
  133451. * Creates a new G Buffer for the scene
  133452. * @param scene The scene the buffer belongs to
  133453. * @param ratio How big is the buffer related to the main canvas.
  133454. */
  133455. constructor(scene: Scene, ratio?: number);
  133456. /**
  133457. * Checks wether everything is ready to render a submesh to the G buffer.
  133458. * @param subMesh the submesh to check readiness for
  133459. * @param useInstances is the mesh drawn using instance or not
  133460. * @returns true if ready otherwise false
  133461. */
  133462. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133463. /**
  133464. * Gets the current underlying G Buffer.
  133465. * @returns the buffer
  133466. */
  133467. getGBuffer(): MultiRenderTarget;
  133468. /**
  133469. * Gets the number of samples used to render the buffer (anti aliasing).
  133470. */
  133471. get samples(): number;
  133472. /**
  133473. * Sets the number of samples used to render the buffer (anti aliasing).
  133474. */
  133475. set samples(value: number);
  133476. /**
  133477. * Disposes the renderer and frees up associated resources.
  133478. */
  133479. dispose(): void;
  133480. protected _createRenderTargets(): void;
  133481. private _copyBonesTransformationMatrices;
  133482. }
  133483. }
  133484. declare module BABYLON {
  133485. interface Scene {
  133486. /** @hidden (Backing field) */
  133487. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133488. /**
  133489. * Gets or Sets the current geometry buffer associated to the scene.
  133490. */
  133491. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133492. /**
  133493. * Enables a GeometryBufferRender and associates it with the scene
  133494. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  133495. * @returns the GeometryBufferRenderer
  133496. */
  133497. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  133498. /**
  133499. * Disables the GeometryBufferRender associated with the scene
  133500. */
  133501. disableGeometryBufferRenderer(): void;
  133502. }
  133503. /**
  133504. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  133505. * in several rendering techniques.
  133506. */
  133507. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  133508. /**
  133509. * The component name helpful to identify the component in the list of scene components.
  133510. */
  133511. readonly name: string;
  133512. /**
  133513. * The scene the component belongs to.
  133514. */
  133515. scene: Scene;
  133516. /**
  133517. * Creates a new instance of the component for the given scene
  133518. * @param scene Defines the scene to register the component in
  133519. */
  133520. constructor(scene: Scene);
  133521. /**
  133522. * Registers the component in a given scene
  133523. */
  133524. register(): void;
  133525. /**
  133526. * Rebuilds the elements related to this component in case of
  133527. * context lost for instance.
  133528. */
  133529. rebuild(): void;
  133530. /**
  133531. * Disposes the component and the associated ressources
  133532. */
  133533. dispose(): void;
  133534. private _gatherRenderTargets;
  133535. }
  133536. }
  133537. declare module BABYLON {
  133538. /** @hidden */
  133539. export var motionBlurPixelShader: {
  133540. name: string;
  133541. shader: string;
  133542. };
  133543. }
  133544. declare module BABYLON {
  133545. /**
  133546. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  133547. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  133548. * As an example, all you have to do is to create the post-process:
  133549. * var mb = new BABYLON.MotionBlurPostProcess(
  133550. * 'mb', // The name of the effect.
  133551. * scene, // The scene containing the objects to blur according to their velocity.
  133552. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  133553. * camera // The camera to apply the render pass to.
  133554. * );
  133555. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  133556. */
  133557. export class MotionBlurPostProcess extends PostProcess {
  133558. /**
  133559. * Defines how much the image is blurred by the movement. Default value is equal to 1
  133560. */
  133561. motionStrength: number;
  133562. /**
  133563. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  133564. */
  133565. get motionBlurSamples(): number;
  133566. /**
  133567. * Sets the number of iterations to be used for motion blur quality
  133568. */
  133569. set motionBlurSamples(samples: number);
  133570. private _motionBlurSamples;
  133571. private _geometryBufferRenderer;
  133572. /**
  133573. * Creates a new instance MotionBlurPostProcess
  133574. * @param name The name of the effect.
  133575. * @param scene The scene containing the objects to blur according to their velocity.
  133576. * @param options The required width/height ratio to downsize to before computing the render pass.
  133577. * @param camera The camera to apply the render pass to.
  133578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133579. * @param engine The engine which the post process will be applied. (default: current engine)
  133580. * @param reusable If the post process can be reused on the same frame. (default: false)
  133581. * @param textureType Type of textures used when performing the post process. (default: 0)
  133582. * @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)
  133583. */
  133584. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133585. /**
  133586. * Excludes the given skinned mesh from computing bones velocities.
  133587. * 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.
  133588. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  133589. */
  133590. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133591. /**
  133592. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  133593. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  133594. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  133595. */
  133596. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133597. /**
  133598. * Disposes the post process.
  133599. * @param camera The camera to dispose the post process on.
  133600. */
  133601. dispose(camera?: Camera): void;
  133602. }
  133603. }
  133604. declare module BABYLON {
  133605. /** @hidden */
  133606. export var refractionPixelShader: {
  133607. name: string;
  133608. shader: string;
  133609. };
  133610. }
  133611. declare module BABYLON {
  133612. /**
  133613. * Post process which applies a refractin texture
  133614. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133615. */
  133616. export class RefractionPostProcess extends PostProcess {
  133617. /** the base color of the refraction (used to taint the rendering) */
  133618. color: Color3;
  133619. /** simulated refraction depth */
  133620. depth: number;
  133621. /** the coefficient of the base color (0 to remove base color tainting) */
  133622. colorLevel: number;
  133623. private _refTexture;
  133624. private _ownRefractionTexture;
  133625. /**
  133626. * Gets or sets the refraction texture
  133627. * Please note that you are responsible for disposing the texture if you set it manually
  133628. */
  133629. get refractionTexture(): Texture;
  133630. set refractionTexture(value: Texture);
  133631. /**
  133632. * Initializes the RefractionPostProcess
  133633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133634. * @param name The name of the effect.
  133635. * @param refractionTextureUrl Url of the refraction texture to use
  133636. * @param color the base color of the refraction (used to taint the rendering)
  133637. * @param depth simulated refraction depth
  133638. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  133639. * @param camera The camera to apply the render pass to.
  133640. * @param options The required width/height ratio to downsize to before computing the render pass.
  133641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133642. * @param engine The engine which the post process will be applied. (default: current engine)
  133643. * @param reusable If the post process can be reused on the same frame. (default: false)
  133644. */
  133645. constructor(name: string, refractionTextureUrl: string,
  133646. /** the base color of the refraction (used to taint the rendering) */
  133647. color: Color3,
  133648. /** simulated refraction depth */
  133649. depth: number,
  133650. /** the coefficient of the base color (0 to remove base color tainting) */
  133651. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133652. /**
  133653. * Disposes of the post process
  133654. * @param camera Camera to dispose post process on
  133655. */
  133656. dispose(camera: Camera): void;
  133657. }
  133658. }
  133659. declare module BABYLON {
  133660. /** @hidden */
  133661. export var sharpenPixelShader: {
  133662. name: string;
  133663. shader: string;
  133664. };
  133665. }
  133666. declare module BABYLON {
  133667. /**
  133668. * The SharpenPostProcess applies a sharpen kernel to every pixel
  133669. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133670. */
  133671. export class SharpenPostProcess extends PostProcess {
  133672. /**
  133673. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  133674. */
  133675. colorAmount: number;
  133676. /**
  133677. * How much sharpness should be applied (default: 0.3)
  133678. */
  133679. edgeAmount: number;
  133680. /**
  133681. * Creates a new instance ConvolutionPostProcess
  133682. * @param name The name of the effect.
  133683. * @param options The required width/height ratio to downsize to before computing the render pass.
  133684. * @param camera The camera to apply the render pass to.
  133685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133686. * @param engine The engine which the post process will be applied. (default: current engine)
  133687. * @param reusable If the post process can be reused on the same frame. (default: false)
  133688. * @param textureType Type of textures used when performing the post process. (default: 0)
  133689. * @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)
  133690. */
  133691. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133692. }
  133693. }
  133694. declare module BABYLON {
  133695. /**
  133696. * PostProcessRenderPipeline
  133697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133698. */
  133699. export class PostProcessRenderPipeline {
  133700. private engine;
  133701. private _renderEffects;
  133702. private _renderEffectsForIsolatedPass;
  133703. /**
  133704. * List of inspectable custom properties (used by the Inspector)
  133705. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  133706. */
  133707. inspectableCustomProperties: IInspectable[];
  133708. /**
  133709. * @hidden
  133710. */
  133711. protected _cameras: Camera[];
  133712. /** @hidden */
  133713. _name: string;
  133714. /**
  133715. * Gets pipeline name
  133716. */
  133717. get name(): string;
  133718. /** Gets the list of attached cameras */
  133719. get cameras(): Camera[];
  133720. /**
  133721. * Initializes a PostProcessRenderPipeline
  133722. * @param engine engine to add the pipeline to
  133723. * @param name name of the pipeline
  133724. */
  133725. constructor(engine: Engine, name: string);
  133726. /**
  133727. * Gets the class name
  133728. * @returns "PostProcessRenderPipeline"
  133729. */
  133730. getClassName(): string;
  133731. /**
  133732. * If all the render effects in the pipeline are supported
  133733. */
  133734. get isSupported(): boolean;
  133735. /**
  133736. * Adds an effect to the pipeline
  133737. * @param renderEffect the effect to add
  133738. */
  133739. addEffect(renderEffect: PostProcessRenderEffect): void;
  133740. /** @hidden */
  133741. _rebuild(): void;
  133742. /** @hidden */
  133743. _enableEffect(renderEffectName: string, cameras: Camera): void;
  133744. /** @hidden */
  133745. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  133746. /** @hidden */
  133747. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133748. /** @hidden */
  133749. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133750. /** @hidden */
  133751. _attachCameras(cameras: Camera, unique: boolean): void;
  133752. /** @hidden */
  133753. _attachCameras(cameras: Camera[], unique: boolean): void;
  133754. /** @hidden */
  133755. _detachCameras(cameras: Camera): void;
  133756. /** @hidden */
  133757. _detachCameras(cameras: Nullable<Camera[]>): void;
  133758. /** @hidden */
  133759. _update(): void;
  133760. /** @hidden */
  133761. _reset(): void;
  133762. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  133763. /**
  133764. * Disposes of the pipeline
  133765. */
  133766. dispose(): void;
  133767. }
  133768. }
  133769. declare module BABYLON {
  133770. /**
  133771. * PostProcessRenderPipelineManager class
  133772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133773. */
  133774. export class PostProcessRenderPipelineManager {
  133775. private _renderPipelines;
  133776. /**
  133777. * Initializes a PostProcessRenderPipelineManager
  133778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133779. */
  133780. constructor();
  133781. /**
  133782. * Gets the list of supported render pipelines
  133783. */
  133784. get supportedPipelines(): PostProcessRenderPipeline[];
  133785. /**
  133786. * Adds a pipeline to the manager
  133787. * @param renderPipeline The pipeline to add
  133788. */
  133789. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  133790. /**
  133791. * Attaches a camera to the pipeline
  133792. * @param renderPipelineName The name of the pipeline to attach to
  133793. * @param cameras the camera to attach
  133794. * @param unique if the camera can be attached multiple times to the pipeline
  133795. */
  133796. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  133797. /**
  133798. * Detaches a camera from the pipeline
  133799. * @param renderPipelineName The name of the pipeline to detach from
  133800. * @param cameras the camera to detach
  133801. */
  133802. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  133803. /**
  133804. * Enables an effect by name on a pipeline
  133805. * @param renderPipelineName the name of the pipeline to enable the effect in
  133806. * @param renderEffectName the name of the effect to enable
  133807. * @param cameras the cameras that the effect should be enabled on
  133808. */
  133809. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133810. /**
  133811. * Disables an effect by name on a pipeline
  133812. * @param renderPipelineName the name of the pipeline to disable the effect in
  133813. * @param renderEffectName the name of the effect to disable
  133814. * @param cameras the cameras that the effect should be disabled on
  133815. */
  133816. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133817. /**
  133818. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  133819. */
  133820. update(): void;
  133821. /** @hidden */
  133822. _rebuild(): void;
  133823. /**
  133824. * Disposes of the manager and pipelines
  133825. */
  133826. dispose(): void;
  133827. }
  133828. }
  133829. declare module BABYLON {
  133830. interface Scene {
  133831. /** @hidden (Backing field) */
  133832. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133833. /**
  133834. * Gets the postprocess render pipeline manager
  133835. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133836. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133837. */
  133838. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133839. }
  133840. /**
  133841. * Defines the Render Pipeline scene component responsible to rendering pipelines
  133842. */
  133843. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  133844. /**
  133845. * The component name helpfull to identify the component in the list of scene components.
  133846. */
  133847. readonly name: string;
  133848. /**
  133849. * The scene the component belongs to.
  133850. */
  133851. scene: Scene;
  133852. /**
  133853. * Creates a new instance of the component for the given scene
  133854. * @param scene Defines the scene to register the component in
  133855. */
  133856. constructor(scene: Scene);
  133857. /**
  133858. * Registers the component in a given scene
  133859. */
  133860. register(): void;
  133861. /**
  133862. * Rebuilds the elements related to this component in case of
  133863. * context lost for instance.
  133864. */
  133865. rebuild(): void;
  133866. /**
  133867. * Disposes the component and the associated ressources
  133868. */
  133869. dispose(): void;
  133870. private _gatherRenderTargets;
  133871. }
  133872. }
  133873. declare module BABYLON {
  133874. /**
  133875. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  133876. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133877. */
  133878. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  133879. private _scene;
  133880. private _camerasToBeAttached;
  133881. /**
  133882. * ID of the sharpen post process,
  133883. */
  133884. private readonly SharpenPostProcessId;
  133885. /**
  133886. * @ignore
  133887. * ID of the image processing post process;
  133888. */
  133889. readonly ImageProcessingPostProcessId: string;
  133890. /**
  133891. * @ignore
  133892. * ID of the Fast Approximate Anti-Aliasing post process;
  133893. */
  133894. readonly FxaaPostProcessId: string;
  133895. /**
  133896. * ID of the chromatic aberration post process,
  133897. */
  133898. private readonly ChromaticAberrationPostProcessId;
  133899. /**
  133900. * ID of the grain post process
  133901. */
  133902. private readonly GrainPostProcessId;
  133903. /**
  133904. * Sharpen post process which will apply a sharpen convolution to enhance edges
  133905. */
  133906. sharpen: SharpenPostProcess;
  133907. private _sharpenEffect;
  133908. private bloom;
  133909. /**
  133910. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  133911. */
  133912. depthOfField: DepthOfFieldEffect;
  133913. /**
  133914. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  133915. */
  133916. fxaa: FxaaPostProcess;
  133917. /**
  133918. * Image post processing pass used to perform operations such as tone mapping or color grading.
  133919. */
  133920. imageProcessing: ImageProcessingPostProcess;
  133921. /**
  133922. * Chromatic aberration post process which will shift rgb colors in the image
  133923. */
  133924. chromaticAberration: ChromaticAberrationPostProcess;
  133925. private _chromaticAberrationEffect;
  133926. /**
  133927. * Grain post process which add noise to the image
  133928. */
  133929. grain: GrainPostProcess;
  133930. private _grainEffect;
  133931. /**
  133932. * Glow post process which adds a glow to emissive areas of the image
  133933. */
  133934. private _glowLayer;
  133935. /**
  133936. * Animations which can be used to tweak settings over a period of time
  133937. */
  133938. animations: Animation[];
  133939. private _imageProcessingConfigurationObserver;
  133940. private _sharpenEnabled;
  133941. private _bloomEnabled;
  133942. private _depthOfFieldEnabled;
  133943. private _depthOfFieldBlurLevel;
  133944. private _fxaaEnabled;
  133945. private _imageProcessingEnabled;
  133946. private _defaultPipelineTextureType;
  133947. private _bloomScale;
  133948. private _chromaticAberrationEnabled;
  133949. private _grainEnabled;
  133950. private _buildAllowed;
  133951. /**
  133952. * Gets active scene
  133953. */
  133954. get scene(): Scene;
  133955. /**
  133956. * Enable or disable the sharpen process from the pipeline
  133957. */
  133958. set sharpenEnabled(enabled: boolean);
  133959. get sharpenEnabled(): boolean;
  133960. private _resizeObserver;
  133961. private _hardwareScaleLevel;
  133962. private _bloomKernel;
  133963. /**
  133964. * Specifies the size of the bloom blur kernel, relative to the final output size
  133965. */
  133966. get bloomKernel(): number;
  133967. set bloomKernel(value: number);
  133968. /**
  133969. * Specifies the weight of the bloom in the final rendering
  133970. */
  133971. private _bloomWeight;
  133972. /**
  133973. * Specifies the luma threshold for the area that will be blurred by the bloom
  133974. */
  133975. private _bloomThreshold;
  133976. private _hdr;
  133977. /**
  133978. * The strength of the bloom.
  133979. */
  133980. set bloomWeight(value: number);
  133981. get bloomWeight(): number;
  133982. /**
  133983. * The strength of the bloom.
  133984. */
  133985. set bloomThreshold(value: number);
  133986. get bloomThreshold(): number;
  133987. /**
  133988. * The scale of the bloom, lower value will provide better performance.
  133989. */
  133990. set bloomScale(value: number);
  133991. get bloomScale(): number;
  133992. /**
  133993. * Enable or disable the bloom from the pipeline
  133994. */
  133995. set bloomEnabled(enabled: boolean);
  133996. get bloomEnabled(): boolean;
  133997. private _rebuildBloom;
  133998. /**
  133999. * If the depth of field is enabled.
  134000. */
  134001. get depthOfFieldEnabled(): boolean;
  134002. set depthOfFieldEnabled(enabled: boolean);
  134003. /**
  134004. * Blur level of the depth of field effect. (Higher blur will effect performance)
  134005. */
  134006. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  134007. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  134008. /**
  134009. * If the anti aliasing is enabled.
  134010. */
  134011. set fxaaEnabled(enabled: boolean);
  134012. get fxaaEnabled(): boolean;
  134013. private _samples;
  134014. /**
  134015. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  134016. */
  134017. set samples(sampleCount: number);
  134018. get samples(): number;
  134019. /**
  134020. * If image processing is enabled.
  134021. */
  134022. set imageProcessingEnabled(enabled: boolean);
  134023. get imageProcessingEnabled(): boolean;
  134024. /**
  134025. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  134026. */
  134027. set glowLayerEnabled(enabled: boolean);
  134028. get glowLayerEnabled(): boolean;
  134029. /**
  134030. * Gets the glow layer (or null if not defined)
  134031. */
  134032. get glowLayer(): Nullable<GlowLayer>;
  134033. /**
  134034. * Enable or disable the chromaticAberration process from the pipeline
  134035. */
  134036. set chromaticAberrationEnabled(enabled: boolean);
  134037. get chromaticAberrationEnabled(): boolean;
  134038. /**
  134039. * Enable or disable the grain process from the pipeline
  134040. */
  134041. set grainEnabled(enabled: boolean);
  134042. get grainEnabled(): boolean;
  134043. /**
  134044. * @constructor
  134045. * @param name - The rendering pipeline name (default: "")
  134046. * @param hdr - If high dynamic range textures should be used (default: true)
  134047. * @param scene - The scene linked to this pipeline (default: the last created scene)
  134048. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  134049. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  134050. */
  134051. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  134052. /**
  134053. * Get the class name
  134054. * @returns "DefaultRenderingPipeline"
  134055. */
  134056. getClassName(): string;
  134057. /**
  134058. * Force the compilation of the entire pipeline.
  134059. */
  134060. prepare(): void;
  134061. private _hasCleared;
  134062. private _prevPostProcess;
  134063. private _prevPrevPostProcess;
  134064. private _setAutoClearAndTextureSharing;
  134065. private _depthOfFieldSceneObserver;
  134066. private _buildPipeline;
  134067. private _disposePostProcesses;
  134068. /**
  134069. * Adds a camera to the pipeline
  134070. * @param camera the camera to be added
  134071. */
  134072. addCamera(camera: Camera): void;
  134073. /**
  134074. * Removes a camera from the pipeline
  134075. * @param camera the camera to remove
  134076. */
  134077. removeCamera(camera: Camera): void;
  134078. /**
  134079. * Dispose of the pipeline and stop all post processes
  134080. */
  134081. dispose(): void;
  134082. /**
  134083. * Serialize the rendering pipeline (Used when exporting)
  134084. * @returns the serialized object
  134085. */
  134086. serialize(): any;
  134087. /**
  134088. * Parse the serialized pipeline
  134089. * @param source Source pipeline.
  134090. * @param scene The scene to load the pipeline to.
  134091. * @param rootUrl The URL of the serialized pipeline.
  134092. * @returns An instantiated pipeline from the serialized object.
  134093. */
  134094. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  134095. }
  134096. }
  134097. declare module BABYLON {
  134098. /** @hidden */
  134099. export var lensHighlightsPixelShader: {
  134100. name: string;
  134101. shader: string;
  134102. };
  134103. }
  134104. declare module BABYLON {
  134105. /** @hidden */
  134106. export var depthOfFieldPixelShader: {
  134107. name: string;
  134108. shader: string;
  134109. };
  134110. }
  134111. declare module BABYLON {
  134112. /**
  134113. * BABYLON.JS Chromatic Aberration GLSL Shader
  134114. * Author: Olivier Guyot
  134115. * Separates very slightly R, G and B colors on the edges of the screen
  134116. * Inspired by Francois Tarlier & Martins Upitis
  134117. */
  134118. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  134119. /**
  134120. * @ignore
  134121. * The chromatic aberration PostProcess id in the pipeline
  134122. */
  134123. LensChromaticAberrationEffect: string;
  134124. /**
  134125. * @ignore
  134126. * The highlights enhancing PostProcess id in the pipeline
  134127. */
  134128. HighlightsEnhancingEffect: string;
  134129. /**
  134130. * @ignore
  134131. * The depth-of-field PostProcess id in the pipeline
  134132. */
  134133. LensDepthOfFieldEffect: string;
  134134. private _scene;
  134135. private _depthTexture;
  134136. private _grainTexture;
  134137. private _chromaticAberrationPostProcess;
  134138. private _highlightsPostProcess;
  134139. private _depthOfFieldPostProcess;
  134140. private _edgeBlur;
  134141. private _grainAmount;
  134142. private _chromaticAberration;
  134143. private _distortion;
  134144. private _highlightsGain;
  134145. private _highlightsThreshold;
  134146. private _dofDistance;
  134147. private _dofAperture;
  134148. private _dofDarken;
  134149. private _dofPentagon;
  134150. private _blurNoise;
  134151. /**
  134152. * @constructor
  134153. *
  134154. * Effect parameters are as follow:
  134155. * {
  134156. * chromatic_aberration: number; // from 0 to x (1 for realism)
  134157. * edge_blur: number; // from 0 to x (1 for realism)
  134158. * distortion: number; // from 0 to x (1 for realism)
  134159. * grain_amount: number; // from 0 to 1
  134160. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  134161. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  134162. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  134163. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  134164. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  134165. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  134166. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  134167. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  134168. * }
  134169. * Note: if an effect parameter is unset, effect is disabled
  134170. *
  134171. * @param name The rendering pipeline name
  134172. * @param parameters - An object containing all parameters (see above)
  134173. * @param scene The scene linked to this pipeline
  134174. * @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)
  134175. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134176. */
  134177. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  134178. /**
  134179. * Get the class name
  134180. * @returns "LensRenderingPipeline"
  134181. */
  134182. getClassName(): string;
  134183. /**
  134184. * Gets associated scene
  134185. */
  134186. get scene(): Scene;
  134187. /**
  134188. * Gets or sets the edge blur
  134189. */
  134190. get edgeBlur(): number;
  134191. set edgeBlur(value: number);
  134192. /**
  134193. * Gets or sets the grain amount
  134194. */
  134195. get grainAmount(): number;
  134196. set grainAmount(value: number);
  134197. /**
  134198. * Gets or sets the chromatic aberration amount
  134199. */
  134200. get chromaticAberration(): number;
  134201. set chromaticAberration(value: number);
  134202. /**
  134203. * Gets or sets the depth of field aperture
  134204. */
  134205. get dofAperture(): number;
  134206. set dofAperture(value: number);
  134207. /**
  134208. * Gets or sets the edge distortion
  134209. */
  134210. get edgeDistortion(): number;
  134211. set edgeDistortion(value: number);
  134212. /**
  134213. * Gets or sets the depth of field distortion
  134214. */
  134215. get dofDistortion(): number;
  134216. set dofDistortion(value: number);
  134217. /**
  134218. * Gets or sets the darken out of focus amount
  134219. */
  134220. get darkenOutOfFocus(): number;
  134221. set darkenOutOfFocus(value: number);
  134222. /**
  134223. * Gets or sets a boolean indicating if blur noise is enabled
  134224. */
  134225. get blurNoise(): boolean;
  134226. set blurNoise(value: boolean);
  134227. /**
  134228. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  134229. */
  134230. get pentagonBokeh(): boolean;
  134231. set pentagonBokeh(value: boolean);
  134232. /**
  134233. * Gets or sets the highlight grain amount
  134234. */
  134235. get highlightsGain(): number;
  134236. set highlightsGain(value: number);
  134237. /**
  134238. * Gets or sets the highlight threshold
  134239. */
  134240. get highlightsThreshold(): number;
  134241. set highlightsThreshold(value: number);
  134242. /**
  134243. * Sets the amount of blur at the edges
  134244. * @param amount blur amount
  134245. */
  134246. setEdgeBlur(amount: number): void;
  134247. /**
  134248. * Sets edge blur to 0
  134249. */
  134250. disableEdgeBlur(): void;
  134251. /**
  134252. * Sets the amout of grain
  134253. * @param amount Amount of grain
  134254. */
  134255. setGrainAmount(amount: number): void;
  134256. /**
  134257. * Set grain amount to 0
  134258. */
  134259. disableGrain(): void;
  134260. /**
  134261. * Sets the chromatic aberration amount
  134262. * @param amount amount of chromatic aberration
  134263. */
  134264. setChromaticAberration(amount: number): void;
  134265. /**
  134266. * Sets chromatic aberration amount to 0
  134267. */
  134268. disableChromaticAberration(): void;
  134269. /**
  134270. * Sets the EdgeDistortion amount
  134271. * @param amount amount of EdgeDistortion
  134272. */
  134273. setEdgeDistortion(amount: number): void;
  134274. /**
  134275. * Sets edge distortion to 0
  134276. */
  134277. disableEdgeDistortion(): void;
  134278. /**
  134279. * Sets the FocusDistance amount
  134280. * @param amount amount of FocusDistance
  134281. */
  134282. setFocusDistance(amount: number): void;
  134283. /**
  134284. * Disables depth of field
  134285. */
  134286. disableDepthOfField(): void;
  134287. /**
  134288. * Sets the Aperture amount
  134289. * @param amount amount of Aperture
  134290. */
  134291. setAperture(amount: number): void;
  134292. /**
  134293. * Sets the DarkenOutOfFocus amount
  134294. * @param amount amount of DarkenOutOfFocus
  134295. */
  134296. setDarkenOutOfFocus(amount: number): void;
  134297. private _pentagonBokehIsEnabled;
  134298. /**
  134299. * Creates a pentagon bokeh effect
  134300. */
  134301. enablePentagonBokeh(): void;
  134302. /**
  134303. * Disables the pentagon bokeh effect
  134304. */
  134305. disablePentagonBokeh(): void;
  134306. /**
  134307. * Enables noise blur
  134308. */
  134309. enableNoiseBlur(): void;
  134310. /**
  134311. * Disables noise blur
  134312. */
  134313. disableNoiseBlur(): void;
  134314. /**
  134315. * Sets the HighlightsGain amount
  134316. * @param amount amount of HighlightsGain
  134317. */
  134318. setHighlightsGain(amount: number): void;
  134319. /**
  134320. * Sets the HighlightsThreshold amount
  134321. * @param amount amount of HighlightsThreshold
  134322. */
  134323. setHighlightsThreshold(amount: number): void;
  134324. /**
  134325. * Disables highlights
  134326. */
  134327. disableHighlights(): void;
  134328. /**
  134329. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  134330. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  134331. */
  134332. dispose(disableDepthRender?: boolean): void;
  134333. private _createChromaticAberrationPostProcess;
  134334. private _createHighlightsPostProcess;
  134335. private _createDepthOfFieldPostProcess;
  134336. private _createGrainTexture;
  134337. }
  134338. }
  134339. declare module BABYLON {
  134340. /** @hidden */
  134341. export var ssao2PixelShader: {
  134342. name: string;
  134343. shader: string;
  134344. };
  134345. }
  134346. declare module BABYLON {
  134347. /** @hidden */
  134348. export var ssaoCombinePixelShader: {
  134349. name: string;
  134350. shader: string;
  134351. };
  134352. }
  134353. declare module BABYLON {
  134354. /**
  134355. * Render pipeline to produce ssao effect
  134356. */
  134357. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  134358. /**
  134359. * @ignore
  134360. * The PassPostProcess id in the pipeline that contains the original scene color
  134361. */
  134362. SSAOOriginalSceneColorEffect: string;
  134363. /**
  134364. * @ignore
  134365. * The SSAO PostProcess id in the pipeline
  134366. */
  134367. SSAORenderEffect: string;
  134368. /**
  134369. * @ignore
  134370. * The horizontal blur PostProcess id in the pipeline
  134371. */
  134372. SSAOBlurHRenderEffect: string;
  134373. /**
  134374. * @ignore
  134375. * The vertical blur PostProcess id in the pipeline
  134376. */
  134377. SSAOBlurVRenderEffect: string;
  134378. /**
  134379. * @ignore
  134380. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134381. */
  134382. SSAOCombineRenderEffect: string;
  134383. /**
  134384. * The output strength of the SSAO post-process. Default value is 1.0.
  134385. */
  134386. totalStrength: number;
  134387. /**
  134388. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  134389. */
  134390. maxZ: number;
  134391. /**
  134392. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  134393. */
  134394. minZAspect: number;
  134395. private _samples;
  134396. /**
  134397. * Number of samples used for the SSAO calculations. Default value is 8
  134398. */
  134399. set samples(n: number);
  134400. get samples(): number;
  134401. private _textureSamples;
  134402. /**
  134403. * Number of samples to use for antialiasing
  134404. */
  134405. set textureSamples(n: number);
  134406. get textureSamples(): number;
  134407. /**
  134408. * Ratio object used for SSAO ratio and blur ratio
  134409. */
  134410. private _ratio;
  134411. /**
  134412. * Dynamically generated sphere sampler.
  134413. */
  134414. private _sampleSphere;
  134415. /**
  134416. * Blur filter offsets
  134417. */
  134418. private _samplerOffsets;
  134419. private _expensiveBlur;
  134420. /**
  134421. * If bilateral blur should be used
  134422. */
  134423. set expensiveBlur(b: boolean);
  134424. get expensiveBlur(): boolean;
  134425. /**
  134426. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  134427. */
  134428. radius: number;
  134429. /**
  134430. * The base color of the SSAO post-process
  134431. * The final result is "base + ssao" between [0, 1]
  134432. */
  134433. base: number;
  134434. /**
  134435. * Support test.
  134436. */
  134437. static get IsSupported(): boolean;
  134438. private _scene;
  134439. private _depthTexture;
  134440. private _normalTexture;
  134441. private _randomTexture;
  134442. private _originalColorPostProcess;
  134443. private _ssaoPostProcess;
  134444. private _blurHPostProcess;
  134445. private _blurVPostProcess;
  134446. private _ssaoCombinePostProcess;
  134447. /**
  134448. * Gets active scene
  134449. */
  134450. get scene(): Scene;
  134451. /**
  134452. * @constructor
  134453. * @param name The rendering pipeline name
  134454. * @param scene The scene linked to this pipeline
  134455. * @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 }
  134456. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134457. */
  134458. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134459. /**
  134460. * Get the class name
  134461. * @returns "SSAO2RenderingPipeline"
  134462. */
  134463. getClassName(): string;
  134464. /**
  134465. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134466. */
  134467. dispose(disableGeometryBufferRenderer?: boolean): void;
  134468. private _createBlurPostProcess;
  134469. /** @hidden */
  134470. _rebuild(): void;
  134471. private _bits;
  134472. private _radicalInverse_VdC;
  134473. private _hammersley;
  134474. private _hemisphereSample_uniform;
  134475. private _generateHemisphere;
  134476. private _createSSAOPostProcess;
  134477. private _createSSAOCombinePostProcess;
  134478. private _createRandomTexture;
  134479. /**
  134480. * Serialize the rendering pipeline (Used when exporting)
  134481. * @returns the serialized object
  134482. */
  134483. serialize(): any;
  134484. /**
  134485. * Parse the serialized pipeline
  134486. * @param source Source pipeline.
  134487. * @param scene The scene to load the pipeline to.
  134488. * @param rootUrl The URL of the serialized pipeline.
  134489. * @returns An instantiated pipeline from the serialized object.
  134490. */
  134491. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  134492. }
  134493. }
  134494. declare module BABYLON {
  134495. /** @hidden */
  134496. export var ssaoPixelShader: {
  134497. name: string;
  134498. shader: string;
  134499. };
  134500. }
  134501. declare module BABYLON {
  134502. /**
  134503. * Render pipeline to produce ssao effect
  134504. */
  134505. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  134506. /**
  134507. * @ignore
  134508. * The PassPostProcess id in the pipeline that contains the original scene color
  134509. */
  134510. SSAOOriginalSceneColorEffect: string;
  134511. /**
  134512. * @ignore
  134513. * The SSAO PostProcess id in the pipeline
  134514. */
  134515. SSAORenderEffect: string;
  134516. /**
  134517. * @ignore
  134518. * The horizontal blur PostProcess id in the pipeline
  134519. */
  134520. SSAOBlurHRenderEffect: string;
  134521. /**
  134522. * @ignore
  134523. * The vertical blur PostProcess id in the pipeline
  134524. */
  134525. SSAOBlurVRenderEffect: string;
  134526. /**
  134527. * @ignore
  134528. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134529. */
  134530. SSAOCombineRenderEffect: string;
  134531. /**
  134532. * The output strength of the SSAO post-process. Default value is 1.0.
  134533. */
  134534. totalStrength: number;
  134535. /**
  134536. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  134537. */
  134538. radius: number;
  134539. /**
  134540. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  134541. * Must not be equal to fallOff and superior to fallOff.
  134542. * Default value is 0.0075
  134543. */
  134544. area: number;
  134545. /**
  134546. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  134547. * Must not be equal to area and inferior to area.
  134548. * Default value is 0.000001
  134549. */
  134550. fallOff: number;
  134551. /**
  134552. * The base color of the SSAO post-process
  134553. * The final result is "base + ssao" between [0, 1]
  134554. */
  134555. base: number;
  134556. private _scene;
  134557. private _depthTexture;
  134558. private _randomTexture;
  134559. private _originalColorPostProcess;
  134560. private _ssaoPostProcess;
  134561. private _blurHPostProcess;
  134562. private _blurVPostProcess;
  134563. private _ssaoCombinePostProcess;
  134564. private _firstUpdate;
  134565. /**
  134566. * Gets active scene
  134567. */
  134568. get scene(): Scene;
  134569. /**
  134570. * @constructor
  134571. * @param name - The rendering pipeline name
  134572. * @param scene - The scene linked to this pipeline
  134573. * @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 }
  134574. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  134575. */
  134576. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134577. /**
  134578. * Get the class name
  134579. * @returns "SSAORenderingPipeline"
  134580. */
  134581. getClassName(): string;
  134582. /**
  134583. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134584. */
  134585. dispose(disableDepthRender?: boolean): void;
  134586. private _createBlurPostProcess;
  134587. /** @hidden */
  134588. _rebuild(): void;
  134589. private _createSSAOPostProcess;
  134590. private _createSSAOCombinePostProcess;
  134591. private _createRandomTexture;
  134592. }
  134593. }
  134594. declare module BABYLON {
  134595. /** @hidden */
  134596. export var standardPixelShader: {
  134597. name: string;
  134598. shader: string;
  134599. };
  134600. }
  134601. declare module BABYLON {
  134602. /**
  134603. * Standard rendering pipeline
  134604. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134605. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  134606. */
  134607. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134608. /**
  134609. * Public members
  134610. */
  134611. /**
  134612. * Post-process which contains the original scene color before the pipeline applies all the effects
  134613. */
  134614. originalPostProcess: Nullable<PostProcess>;
  134615. /**
  134616. * Post-process used to down scale an image x4
  134617. */
  134618. downSampleX4PostProcess: Nullable<PostProcess>;
  134619. /**
  134620. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  134621. */
  134622. brightPassPostProcess: Nullable<PostProcess>;
  134623. /**
  134624. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  134625. */
  134626. blurHPostProcesses: PostProcess[];
  134627. /**
  134628. * Post-process array storing all the vertical blur post-processes used by the pipeline
  134629. */
  134630. blurVPostProcesses: PostProcess[];
  134631. /**
  134632. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  134633. */
  134634. textureAdderPostProcess: Nullable<PostProcess>;
  134635. /**
  134636. * Post-process used to create volumetric lighting effect
  134637. */
  134638. volumetricLightPostProcess: Nullable<PostProcess>;
  134639. /**
  134640. * Post-process used to smooth the previous volumetric light post-process on the X axis
  134641. */
  134642. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  134643. /**
  134644. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  134645. */
  134646. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  134647. /**
  134648. * Post-process used to merge the volumetric light effect and the real scene color
  134649. */
  134650. volumetricLightMergePostProces: Nullable<PostProcess>;
  134651. /**
  134652. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  134653. */
  134654. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  134655. /**
  134656. * Base post-process used to calculate the average luminance of the final image for HDR
  134657. */
  134658. luminancePostProcess: Nullable<PostProcess>;
  134659. /**
  134660. * Post-processes used to create down sample post-processes in order to get
  134661. * the average luminance of the final image for HDR
  134662. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  134663. */
  134664. luminanceDownSamplePostProcesses: PostProcess[];
  134665. /**
  134666. * Post-process used to create a HDR effect (light adaptation)
  134667. */
  134668. hdrPostProcess: Nullable<PostProcess>;
  134669. /**
  134670. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  134671. */
  134672. textureAdderFinalPostProcess: Nullable<PostProcess>;
  134673. /**
  134674. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  134675. */
  134676. lensFlareFinalPostProcess: Nullable<PostProcess>;
  134677. /**
  134678. * Post-process used to merge the final HDR post-process and the real scene color
  134679. */
  134680. hdrFinalPostProcess: Nullable<PostProcess>;
  134681. /**
  134682. * Post-process used to create a lens flare effect
  134683. */
  134684. lensFlarePostProcess: Nullable<PostProcess>;
  134685. /**
  134686. * Post-process that merges the result of the lens flare post-process and the real scene color
  134687. */
  134688. lensFlareComposePostProcess: Nullable<PostProcess>;
  134689. /**
  134690. * Post-process used to create a motion blur effect
  134691. */
  134692. motionBlurPostProcess: Nullable<PostProcess>;
  134693. /**
  134694. * Post-process used to create a depth of field effect
  134695. */
  134696. depthOfFieldPostProcess: Nullable<PostProcess>;
  134697. /**
  134698. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134699. */
  134700. fxaaPostProcess: Nullable<FxaaPostProcess>;
  134701. /**
  134702. * Represents the brightness threshold in order to configure the illuminated surfaces
  134703. */
  134704. brightThreshold: number;
  134705. /**
  134706. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  134707. */
  134708. blurWidth: number;
  134709. /**
  134710. * Sets if the blur for highlighted surfaces must be only horizontal
  134711. */
  134712. horizontalBlur: boolean;
  134713. /**
  134714. * Gets the overall exposure used by the pipeline
  134715. */
  134716. get exposure(): number;
  134717. /**
  134718. * Sets the overall exposure used by the pipeline
  134719. */
  134720. set exposure(value: number);
  134721. /**
  134722. * Texture used typically to simulate "dirty" on camera lens
  134723. */
  134724. lensTexture: Nullable<Texture>;
  134725. /**
  134726. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  134727. */
  134728. volumetricLightCoefficient: number;
  134729. /**
  134730. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  134731. */
  134732. volumetricLightPower: number;
  134733. /**
  134734. * Used the set the blur intensity to smooth the volumetric lights
  134735. */
  134736. volumetricLightBlurScale: number;
  134737. /**
  134738. * Light (spot or directional) used to generate the volumetric lights rays
  134739. * The source light must have a shadow generate so the pipeline can get its
  134740. * depth map
  134741. */
  134742. sourceLight: Nullable<SpotLight | DirectionalLight>;
  134743. /**
  134744. * For eye adaptation, represents the minimum luminance the eye can see
  134745. */
  134746. hdrMinimumLuminance: number;
  134747. /**
  134748. * For eye adaptation, represents the decrease luminance speed
  134749. */
  134750. hdrDecreaseRate: number;
  134751. /**
  134752. * For eye adaptation, represents the increase luminance speed
  134753. */
  134754. hdrIncreaseRate: number;
  134755. /**
  134756. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134757. */
  134758. get hdrAutoExposure(): boolean;
  134759. /**
  134760. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134761. */
  134762. set hdrAutoExposure(value: boolean);
  134763. /**
  134764. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  134765. */
  134766. lensColorTexture: Nullable<Texture>;
  134767. /**
  134768. * The overall strengh for the lens flare effect
  134769. */
  134770. lensFlareStrength: number;
  134771. /**
  134772. * Dispersion coefficient for lens flare ghosts
  134773. */
  134774. lensFlareGhostDispersal: number;
  134775. /**
  134776. * Main lens flare halo width
  134777. */
  134778. lensFlareHaloWidth: number;
  134779. /**
  134780. * Based on the lens distortion effect, defines how much the lens flare result
  134781. * is distorted
  134782. */
  134783. lensFlareDistortionStrength: number;
  134784. /**
  134785. * Configures the blur intensity used for for lens flare (halo)
  134786. */
  134787. lensFlareBlurWidth: number;
  134788. /**
  134789. * Lens star texture must be used to simulate rays on the flares and is available
  134790. * in the documentation
  134791. */
  134792. lensStarTexture: Nullable<Texture>;
  134793. /**
  134794. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  134795. * flare effect by taking account of the dirt texture
  134796. */
  134797. lensFlareDirtTexture: Nullable<Texture>;
  134798. /**
  134799. * Represents the focal length for the depth of field effect
  134800. */
  134801. depthOfFieldDistance: number;
  134802. /**
  134803. * Represents the blur intensity for the blurred part of the depth of field effect
  134804. */
  134805. depthOfFieldBlurWidth: number;
  134806. /**
  134807. * Gets how much the image is blurred by the movement while using the motion blur post-process
  134808. */
  134809. get motionStrength(): number;
  134810. /**
  134811. * Sets how much the image is blurred by the movement while using the motion blur post-process
  134812. */
  134813. set motionStrength(strength: number);
  134814. /**
  134815. * Gets wether or not the motion blur post-process is object based or screen based.
  134816. */
  134817. get objectBasedMotionBlur(): boolean;
  134818. /**
  134819. * Sets wether or not the motion blur post-process should be object based or screen based
  134820. */
  134821. set objectBasedMotionBlur(value: boolean);
  134822. /**
  134823. * List of animations for the pipeline (IAnimatable implementation)
  134824. */
  134825. animations: Animation[];
  134826. /**
  134827. * Private members
  134828. */
  134829. private _scene;
  134830. private _currentDepthOfFieldSource;
  134831. private _basePostProcess;
  134832. private _fixedExposure;
  134833. private _currentExposure;
  134834. private _hdrAutoExposure;
  134835. private _hdrCurrentLuminance;
  134836. private _motionStrength;
  134837. private _isObjectBasedMotionBlur;
  134838. private _floatTextureType;
  134839. private _camerasToBeAttached;
  134840. private _ratio;
  134841. private _bloomEnabled;
  134842. private _depthOfFieldEnabled;
  134843. private _vlsEnabled;
  134844. private _lensFlareEnabled;
  134845. private _hdrEnabled;
  134846. private _motionBlurEnabled;
  134847. private _fxaaEnabled;
  134848. private _motionBlurSamples;
  134849. private _volumetricLightStepsCount;
  134850. private _samples;
  134851. /**
  134852. * @ignore
  134853. * Specifies if the bloom pipeline is enabled
  134854. */
  134855. get BloomEnabled(): boolean;
  134856. set BloomEnabled(enabled: boolean);
  134857. /**
  134858. * @ignore
  134859. * Specifies if the depth of field pipeline is enabed
  134860. */
  134861. get DepthOfFieldEnabled(): boolean;
  134862. set DepthOfFieldEnabled(enabled: boolean);
  134863. /**
  134864. * @ignore
  134865. * Specifies if the lens flare pipeline is enabed
  134866. */
  134867. get LensFlareEnabled(): boolean;
  134868. set LensFlareEnabled(enabled: boolean);
  134869. /**
  134870. * @ignore
  134871. * Specifies if the HDR pipeline is enabled
  134872. */
  134873. get HDREnabled(): boolean;
  134874. set HDREnabled(enabled: boolean);
  134875. /**
  134876. * @ignore
  134877. * Specifies if the volumetric lights scattering effect is enabled
  134878. */
  134879. get VLSEnabled(): boolean;
  134880. set VLSEnabled(enabled: boolean);
  134881. /**
  134882. * @ignore
  134883. * Specifies if the motion blur effect is enabled
  134884. */
  134885. get MotionBlurEnabled(): boolean;
  134886. set MotionBlurEnabled(enabled: boolean);
  134887. /**
  134888. * Specifies if anti-aliasing is enabled
  134889. */
  134890. get fxaaEnabled(): boolean;
  134891. set fxaaEnabled(enabled: boolean);
  134892. /**
  134893. * Specifies the number of steps used to calculate the volumetric lights
  134894. * Typically in interval [50, 200]
  134895. */
  134896. get volumetricLightStepsCount(): number;
  134897. set volumetricLightStepsCount(count: number);
  134898. /**
  134899. * Specifies the number of samples used for the motion blur effect
  134900. * Typically in interval [16, 64]
  134901. */
  134902. get motionBlurSamples(): number;
  134903. set motionBlurSamples(samples: number);
  134904. /**
  134905. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  134906. */
  134907. get samples(): number;
  134908. set samples(sampleCount: number);
  134909. /**
  134910. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134911. * @constructor
  134912. * @param name The rendering pipeline name
  134913. * @param scene The scene linked to this pipeline
  134914. * @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)
  134915. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  134916. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134917. */
  134918. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  134919. private _buildPipeline;
  134920. private _createDownSampleX4PostProcess;
  134921. private _createBrightPassPostProcess;
  134922. private _createBlurPostProcesses;
  134923. private _createTextureAdderPostProcess;
  134924. private _createVolumetricLightPostProcess;
  134925. private _createLuminancePostProcesses;
  134926. private _createHdrPostProcess;
  134927. private _createLensFlarePostProcess;
  134928. private _createDepthOfFieldPostProcess;
  134929. private _createMotionBlurPostProcess;
  134930. private _getDepthTexture;
  134931. private _disposePostProcesses;
  134932. /**
  134933. * Dispose of the pipeline and stop all post processes
  134934. */
  134935. dispose(): void;
  134936. /**
  134937. * Serialize the rendering pipeline (Used when exporting)
  134938. * @returns the serialized object
  134939. */
  134940. serialize(): any;
  134941. /**
  134942. * Parse the serialized pipeline
  134943. * @param source Source pipeline.
  134944. * @param scene The scene to load the pipeline to.
  134945. * @param rootUrl The URL of the serialized pipeline.
  134946. * @returns An instantiated pipeline from the serialized object.
  134947. */
  134948. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  134949. /**
  134950. * Luminance steps
  134951. */
  134952. static LuminanceSteps: number;
  134953. }
  134954. }
  134955. declare module BABYLON {
  134956. /** @hidden */
  134957. export var tonemapPixelShader: {
  134958. name: string;
  134959. shader: string;
  134960. };
  134961. }
  134962. declare module BABYLON {
  134963. /** Defines operator used for tonemapping */
  134964. export enum TonemappingOperator {
  134965. /** Hable */
  134966. Hable = 0,
  134967. /** Reinhard */
  134968. Reinhard = 1,
  134969. /** HejiDawson */
  134970. HejiDawson = 2,
  134971. /** Photographic */
  134972. Photographic = 3
  134973. }
  134974. /**
  134975. * Defines a post process to apply tone mapping
  134976. */
  134977. export class TonemapPostProcess extends PostProcess {
  134978. private _operator;
  134979. /** Defines the required exposure adjustement */
  134980. exposureAdjustment: number;
  134981. /**
  134982. * Creates a new TonemapPostProcess
  134983. * @param name defines the name of the postprocess
  134984. * @param _operator defines the operator to use
  134985. * @param exposureAdjustment defines the required exposure adjustement
  134986. * @param camera defines the camera to use (can be null)
  134987. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  134988. * @param engine defines the hosting engine (can be ignore if camera is set)
  134989. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  134990. */
  134991. constructor(name: string, _operator: TonemappingOperator,
  134992. /** Defines the required exposure adjustement */
  134993. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  134994. }
  134995. }
  134996. declare module BABYLON {
  134997. /** @hidden */
  134998. export var depthVertexShader: {
  134999. name: string;
  135000. shader: string;
  135001. };
  135002. }
  135003. declare module BABYLON {
  135004. /** @hidden */
  135005. export var volumetricLightScatteringPixelShader: {
  135006. name: string;
  135007. shader: string;
  135008. };
  135009. }
  135010. declare module BABYLON {
  135011. /** @hidden */
  135012. export var volumetricLightScatteringPassVertexShader: {
  135013. name: string;
  135014. shader: string;
  135015. };
  135016. }
  135017. declare module BABYLON {
  135018. /** @hidden */
  135019. export var volumetricLightScatteringPassPixelShader: {
  135020. name: string;
  135021. shader: string;
  135022. };
  135023. }
  135024. declare module BABYLON {
  135025. /**
  135026. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  135027. */
  135028. export class VolumetricLightScatteringPostProcess extends PostProcess {
  135029. private _volumetricLightScatteringPass;
  135030. private _volumetricLightScatteringRTT;
  135031. private _viewPort;
  135032. private _screenCoordinates;
  135033. private _cachedDefines;
  135034. /**
  135035. * If not undefined, the mesh position is computed from the attached node position
  135036. */
  135037. attachedNode: {
  135038. position: Vector3;
  135039. };
  135040. /**
  135041. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  135042. */
  135043. customMeshPosition: Vector3;
  135044. /**
  135045. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  135046. */
  135047. useCustomMeshPosition: boolean;
  135048. /**
  135049. * If the post-process should inverse the light scattering direction
  135050. */
  135051. invert: boolean;
  135052. /**
  135053. * The internal mesh used by the post-process
  135054. */
  135055. mesh: Mesh;
  135056. /**
  135057. * @hidden
  135058. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  135059. */
  135060. get useDiffuseColor(): boolean;
  135061. set useDiffuseColor(useDiffuseColor: boolean);
  135062. /**
  135063. * Array containing the excluded meshes not rendered in the internal pass
  135064. */
  135065. excludedMeshes: AbstractMesh[];
  135066. /**
  135067. * Controls the overall intensity of the post-process
  135068. */
  135069. exposure: number;
  135070. /**
  135071. * Dissipates each sample's contribution in range [0, 1]
  135072. */
  135073. decay: number;
  135074. /**
  135075. * Controls the overall intensity of each sample
  135076. */
  135077. weight: number;
  135078. /**
  135079. * Controls the density of each sample
  135080. */
  135081. density: number;
  135082. /**
  135083. * @constructor
  135084. * @param name The post-process name
  135085. * @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)
  135086. * @param camera The camera that the post-process will be attached to
  135087. * @param mesh The mesh used to create the light scattering
  135088. * @param samples The post-process quality, default 100
  135089. * @param samplingModeThe post-process filtering mode
  135090. * @param engine The babylon engine
  135091. * @param reusable If the post-process is reusable
  135092. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  135093. */
  135094. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  135095. /**
  135096. * Returns the string "VolumetricLightScatteringPostProcess"
  135097. * @returns "VolumetricLightScatteringPostProcess"
  135098. */
  135099. getClassName(): string;
  135100. private _isReady;
  135101. /**
  135102. * Sets the new light position for light scattering effect
  135103. * @param position The new custom light position
  135104. */
  135105. setCustomMeshPosition(position: Vector3): void;
  135106. /**
  135107. * Returns the light position for light scattering effect
  135108. * @return Vector3 The custom light position
  135109. */
  135110. getCustomMeshPosition(): Vector3;
  135111. /**
  135112. * Disposes the internal assets and detaches the post-process from the camera
  135113. */
  135114. dispose(camera: Camera): void;
  135115. /**
  135116. * Returns the render target texture used by the post-process
  135117. * @return the render target texture used by the post-process
  135118. */
  135119. getPass(): RenderTargetTexture;
  135120. private _meshExcluded;
  135121. private _createPass;
  135122. private _updateMeshScreenCoordinates;
  135123. /**
  135124. * Creates a default mesh for the Volumeric Light Scattering post-process
  135125. * @param name The mesh name
  135126. * @param scene The scene where to create the mesh
  135127. * @return the default mesh
  135128. */
  135129. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  135130. }
  135131. }
  135132. declare module BABYLON {
  135133. interface Scene {
  135134. /** @hidden (Backing field) */
  135135. _boundingBoxRenderer: BoundingBoxRenderer;
  135136. /** @hidden (Backing field) */
  135137. _forceShowBoundingBoxes: boolean;
  135138. /**
  135139. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  135140. */
  135141. forceShowBoundingBoxes: boolean;
  135142. /**
  135143. * Gets the bounding box renderer associated with the scene
  135144. * @returns a BoundingBoxRenderer
  135145. */
  135146. getBoundingBoxRenderer(): BoundingBoxRenderer;
  135147. }
  135148. interface AbstractMesh {
  135149. /** @hidden (Backing field) */
  135150. _showBoundingBox: boolean;
  135151. /**
  135152. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  135153. */
  135154. showBoundingBox: boolean;
  135155. }
  135156. /**
  135157. * Component responsible of rendering the bounding box of the meshes in a scene.
  135158. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  135159. */
  135160. export class BoundingBoxRenderer implements ISceneComponent {
  135161. /**
  135162. * The component name helpfull to identify the component in the list of scene components.
  135163. */
  135164. readonly name: string;
  135165. /**
  135166. * The scene the component belongs to.
  135167. */
  135168. scene: Scene;
  135169. /**
  135170. * Color of the bounding box lines placed in front of an object
  135171. */
  135172. frontColor: Color3;
  135173. /**
  135174. * Color of the bounding box lines placed behind an object
  135175. */
  135176. backColor: Color3;
  135177. /**
  135178. * Defines if the renderer should show the back lines or not
  135179. */
  135180. showBackLines: boolean;
  135181. /**
  135182. * @hidden
  135183. */
  135184. renderList: SmartArray<BoundingBox>;
  135185. private _colorShader;
  135186. private _vertexBuffers;
  135187. private _indexBuffer;
  135188. private _fillIndexBuffer;
  135189. private _fillIndexData;
  135190. /**
  135191. * Instantiates a new bounding box renderer in a scene.
  135192. * @param scene the scene the renderer renders in
  135193. */
  135194. constructor(scene: Scene);
  135195. /**
  135196. * Registers the component in a given scene
  135197. */
  135198. register(): void;
  135199. private _evaluateSubMesh;
  135200. private _activeMesh;
  135201. private _prepareRessources;
  135202. private _createIndexBuffer;
  135203. /**
  135204. * Rebuilds the elements related to this component in case of
  135205. * context lost for instance.
  135206. */
  135207. rebuild(): void;
  135208. /**
  135209. * @hidden
  135210. */
  135211. reset(): void;
  135212. /**
  135213. * Render the bounding boxes of a specific rendering group
  135214. * @param renderingGroupId defines the rendering group to render
  135215. */
  135216. render(renderingGroupId: number): void;
  135217. /**
  135218. * In case of occlusion queries, we can render the occlusion bounding box through this method
  135219. * @param mesh Define the mesh to render the occlusion bounding box for
  135220. */
  135221. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  135222. /**
  135223. * Dispose and release the resources attached to this renderer.
  135224. */
  135225. dispose(): void;
  135226. }
  135227. }
  135228. declare module BABYLON {
  135229. /** @hidden */
  135230. export var depthPixelShader: {
  135231. name: string;
  135232. shader: string;
  135233. };
  135234. }
  135235. declare module BABYLON {
  135236. /**
  135237. * This represents a depth renderer in Babylon.
  135238. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135239. */
  135240. export class DepthRenderer {
  135241. private _scene;
  135242. private _depthMap;
  135243. private _effect;
  135244. private readonly _storeNonLinearDepth;
  135245. private readonly _clearColor;
  135246. /** Get if the depth renderer is using packed depth or not */
  135247. readonly isPacked: boolean;
  135248. private _cachedDefines;
  135249. private _camera;
  135250. /**
  135251. * Specifiess that the depth renderer will only be used within
  135252. * the camera it is created for.
  135253. * This can help forcing its rendering during the camera processing.
  135254. */
  135255. useOnlyInActiveCamera: boolean;
  135256. /** @hidden */
  135257. static _SceneComponentInitialization: (scene: Scene) => void;
  135258. /**
  135259. * Instantiates a depth renderer
  135260. * @param scene The scene the renderer belongs to
  135261. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135262. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135263. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135264. */
  135265. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135266. /**
  135267. * Creates the depth rendering effect and checks if the effect is ready.
  135268. * @param subMesh The submesh to be used to render the depth map of
  135269. * @param useInstances If multiple world instances should be used
  135270. * @returns if the depth renderer is ready to render the depth map
  135271. */
  135272. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135273. /**
  135274. * Gets the texture which the depth map will be written to.
  135275. * @returns The depth map texture
  135276. */
  135277. getDepthMap(): RenderTargetTexture;
  135278. /**
  135279. * Disposes of the depth renderer.
  135280. */
  135281. dispose(): void;
  135282. }
  135283. }
  135284. declare module BABYLON {
  135285. interface Scene {
  135286. /** @hidden (Backing field) */
  135287. _depthRenderer: {
  135288. [id: string]: DepthRenderer;
  135289. };
  135290. /**
  135291. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  135292. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  135293. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135294. * @returns the created depth renderer
  135295. */
  135296. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  135297. /**
  135298. * Disables a depth renderer for a given camera
  135299. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  135300. */
  135301. disableDepthRenderer(camera?: Nullable<Camera>): void;
  135302. }
  135303. /**
  135304. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  135305. * in several rendering techniques.
  135306. */
  135307. export class DepthRendererSceneComponent implements ISceneComponent {
  135308. /**
  135309. * The component name helpfull to identify the component in the list of scene components.
  135310. */
  135311. readonly name: string;
  135312. /**
  135313. * The scene the component belongs to.
  135314. */
  135315. scene: Scene;
  135316. /**
  135317. * Creates a new instance of the component for the given scene
  135318. * @param scene Defines the scene to register the component in
  135319. */
  135320. constructor(scene: Scene);
  135321. /**
  135322. * Registers the component in a given scene
  135323. */
  135324. register(): void;
  135325. /**
  135326. * Rebuilds the elements related to this component in case of
  135327. * context lost for instance.
  135328. */
  135329. rebuild(): void;
  135330. /**
  135331. * Disposes the component and the associated ressources
  135332. */
  135333. dispose(): void;
  135334. private _gatherRenderTargets;
  135335. private _gatherActiveCameraRenderTargets;
  135336. }
  135337. }
  135338. declare module BABYLON {
  135339. /** @hidden */
  135340. export var outlinePixelShader: {
  135341. name: string;
  135342. shader: string;
  135343. };
  135344. }
  135345. declare module BABYLON {
  135346. /** @hidden */
  135347. export var outlineVertexShader: {
  135348. name: string;
  135349. shader: string;
  135350. };
  135351. }
  135352. declare module BABYLON {
  135353. interface Scene {
  135354. /** @hidden */
  135355. _outlineRenderer: OutlineRenderer;
  135356. /**
  135357. * Gets the outline renderer associated with the scene
  135358. * @returns a OutlineRenderer
  135359. */
  135360. getOutlineRenderer(): OutlineRenderer;
  135361. }
  135362. interface AbstractMesh {
  135363. /** @hidden (Backing field) */
  135364. _renderOutline: boolean;
  135365. /**
  135366. * Gets or sets a boolean indicating if the outline must be rendered as well
  135367. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  135368. */
  135369. renderOutline: boolean;
  135370. /** @hidden (Backing field) */
  135371. _renderOverlay: boolean;
  135372. /**
  135373. * Gets or sets a boolean indicating if the overlay must be rendered as well
  135374. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  135375. */
  135376. renderOverlay: boolean;
  135377. }
  135378. /**
  135379. * This class is responsible to draw bothe outline/overlay of meshes.
  135380. * It should not be used directly but through the available method on mesh.
  135381. */
  135382. export class OutlineRenderer implements ISceneComponent {
  135383. /**
  135384. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  135385. */
  135386. private static _StencilReference;
  135387. /**
  135388. * The name of the component. Each component must have a unique name.
  135389. */
  135390. name: string;
  135391. /**
  135392. * The scene the component belongs to.
  135393. */
  135394. scene: Scene;
  135395. /**
  135396. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  135397. */
  135398. zOffset: number;
  135399. private _engine;
  135400. private _effect;
  135401. private _cachedDefines;
  135402. private _savedDepthWrite;
  135403. /**
  135404. * Instantiates a new outline renderer. (There could be only one per scene).
  135405. * @param scene Defines the scene it belongs to
  135406. */
  135407. constructor(scene: Scene);
  135408. /**
  135409. * Register the component to one instance of a scene.
  135410. */
  135411. register(): void;
  135412. /**
  135413. * Rebuilds the elements related to this component in case of
  135414. * context lost for instance.
  135415. */
  135416. rebuild(): void;
  135417. /**
  135418. * Disposes the component and the associated ressources.
  135419. */
  135420. dispose(): void;
  135421. /**
  135422. * Renders the outline in the canvas.
  135423. * @param subMesh Defines the sumesh to render
  135424. * @param batch Defines the batch of meshes in case of instances
  135425. * @param useOverlay Defines if the rendering is for the overlay or the outline
  135426. */
  135427. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  135428. /**
  135429. * Returns whether or not the outline renderer is ready for a given submesh.
  135430. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  135431. * @param subMesh Defines the submesh to check readyness for
  135432. * @param useInstances Defines wheter wee are trying to render instances or not
  135433. * @returns true if ready otherwise false
  135434. */
  135435. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135436. private _beforeRenderingMesh;
  135437. private _afterRenderingMesh;
  135438. }
  135439. }
  135440. declare module BABYLON {
  135441. /**
  135442. * Defines the basic options interface of a Sprite Frame Source Size.
  135443. */
  135444. export interface ISpriteJSONSpriteSourceSize {
  135445. /**
  135446. * number of the original width of the Frame
  135447. */
  135448. w: number;
  135449. /**
  135450. * number of the original height of the Frame
  135451. */
  135452. h: number;
  135453. }
  135454. /**
  135455. * Defines the basic options interface of a Sprite Frame Data.
  135456. */
  135457. export interface ISpriteJSONSpriteFrameData {
  135458. /**
  135459. * number of the x offset of the Frame
  135460. */
  135461. x: number;
  135462. /**
  135463. * number of the y offset of the Frame
  135464. */
  135465. y: number;
  135466. /**
  135467. * number of the width of the Frame
  135468. */
  135469. w: number;
  135470. /**
  135471. * number of the height of the Frame
  135472. */
  135473. h: number;
  135474. }
  135475. /**
  135476. * Defines the basic options interface of a JSON Sprite.
  135477. */
  135478. export interface ISpriteJSONSprite {
  135479. /**
  135480. * string name of the Frame
  135481. */
  135482. filename: string;
  135483. /**
  135484. * ISpriteJSONSpriteFrame basic object of the frame data
  135485. */
  135486. frame: ISpriteJSONSpriteFrameData;
  135487. /**
  135488. * boolean to flag is the frame was rotated.
  135489. */
  135490. rotated: boolean;
  135491. /**
  135492. * boolean to flag is the frame was trimmed.
  135493. */
  135494. trimmed: boolean;
  135495. /**
  135496. * ISpriteJSONSpriteFrame basic object of the source data
  135497. */
  135498. spriteSourceSize: ISpriteJSONSpriteFrameData;
  135499. /**
  135500. * ISpriteJSONSpriteFrame basic object of the source data
  135501. */
  135502. sourceSize: ISpriteJSONSpriteSourceSize;
  135503. }
  135504. /**
  135505. * Defines the basic options interface of a JSON atlas.
  135506. */
  135507. export interface ISpriteJSONAtlas {
  135508. /**
  135509. * Array of objects that contain the frame data.
  135510. */
  135511. frames: Array<ISpriteJSONSprite>;
  135512. /**
  135513. * object basic object containing the sprite meta data.
  135514. */
  135515. meta?: object;
  135516. }
  135517. }
  135518. declare module BABYLON {
  135519. /** @hidden */
  135520. export var spriteMapPixelShader: {
  135521. name: string;
  135522. shader: string;
  135523. };
  135524. }
  135525. declare module BABYLON {
  135526. /** @hidden */
  135527. export var spriteMapVertexShader: {
  135528. name: string;
  135529. shader: string;
  135530. };
  135531. }
  135532. declare module BABYLON {
  135533. /**
  135534. * Defines the basic options interface of a SpriteMap
  135535. */
  135536. export interface ISpriteMapOptions {
  135537. /**
  135538. * Vector2 of the number of cells in the grid.
  135539. */
  135540. stageSize?: Vector2;
  135541. /**
  135542. * Vector2 of the size of the output plane in World Units.
  135543. */
  135544. outputSize?: Vector2;
  135545. /**
  135546. * Vector3 of the position of the output plane in World Units.
  135547. */
  135548. outputPosition?: Vector3;
  135549. /**
  135550. * Vector3 of the rotation of the output plane.
  135551. */
  135552. outputRotation?: Vector3;
  135553. /**
  135554. * number of layers that the system will reserve in resources.
  135555. */
  135556. layerCount?: number;
  135557. /**
  135558. * number of max animation frames a single cell will reserve in resources.
  135559. */
  135560. maxAnimationFrames?: number;
  135561. /**
  135562. * number cell index of the base tile when the system compiles.
  135563. */
  135564. baseTile?: number;
  135565. /**
  135566. * boolean flip the sprite after its been repositioned by the framing data.
  135567. */
  135568. flipU?: boolean;
  135569. /**
  135570. * Vector3 scalar of the global RGB values of the SpriteMap.
  135571. */
  135572. colorMultiply?: Vector3;
  135573. }
  135574. /**
  135575. * Defines the IDisposable interface in order to be cleanable from resources.
  135576. */
  135577. export interface ISpriteMap extends IDisposable {
  135578. /**
  135579. * String name of the SpriteMap.
  135580. */
  135581. name: string;
  135582. /**
  135583. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  135584. */
  135585. atlasJSON: ISpriteJSONAtlas;
  135586. /**
  135587. * Texture of the SpriteMap.
  135588. */
  135589. spriteSheet: Texture;
  135590. /**
  135591. * The parameters to initialize the SpriteMap with.
  135592. */
  135593. options: ISpriteMapOptions;
  135594. }
  135595. /**
  135596. * Class used to manage a grid restricted sprite deployment on an Output plane.
  135597. */
  135598. export class SpriteMap implements ISpriteMap {
  135599. /** The Name of the spriteMap */
  135600. name: string;
  135601. /** The JSON file with the frame and meta data */
  135602. atlasJSON: ISpriteJSONAtlas;
  135603. /** The systems Sprite Sheet Texture */
  135604. spriteSheet: Texture;
  135605. /** Arguments passed with the Constructor */
  135606. options: ISpriteMapOptions;
  135607. /** Public Sprite Storage array, parsed from atlasJSON */
  135608. sprites: Array<ISpriteJSONSprite>;
  135609. /** Returns the Number of Sprites in the System */
  135610. get spriteCount(): number;
  135611. /** Returns the Position of Output Plane*/
  135612. get position(): Vector3;
  135613. /** Returns the Position of Output Plane*/
  135614. set position(v: Vector3);
  135615. /** Returns the Rotation of Output Plane*/
  135616. get rotation(): Vector3;
  135617. /** Returns the Rotation of Output Plane*/
  135618. set rotation(v: Vector3);
  135619. /** Sets the AnimationMap*/
  135620. get animationMap(): RawTexture;
  135621. /** Sets the AnimationMap*/
  135622. set animationMap(v: RawTexture);
  135623. /** Scene that the SpriteMap was created in */
  135624. private _scene;
  135625. /** Texture Buffer of Float32 that holds tile frame data*/
  135626. private _frameMap;
  135627. /** Texture Buffers of Float32 that holds tileMap data*/
  135628. private _tileMaps;
  135629. /** Texture Buffer of Float32 that holds Animation Data*/
  135630. private _animationMap;
  135631. /** Custom ShaderMaterial Central to the System*/
  135632. private _material;
  135633. /** Custom ShaderMaterial Central to the System*/
  135634. private _output;
  135635. /** Systems Time Ticker*/
  135636. private _time;
  135637. /**
  135638. * Creates a new SpriteMap
  135639. * @param name defines the SpriteMaps Name
  135640. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  135641. * @param spriteSheet is the Texture that the Sprites are on.
  135642. * @param options a basic deployment configuration
  135643. * @param scene The Scene that the map is deployed on
  135644. */
  135645. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  135646. /**
  135647. * Returns tileID location
  135648. * @returns Vector2 the cell position ID
  135649. */
  135650. getTileID(): Vector2;
  135651. /**
  135652. * Gets the UV location of the mouse over the SpriteMap.
  135653. * @returns Vector2 the UV position of the mouse interaction
  135654. */
  135655. getMousePosition(): Vector2;
  135656. /**
  135657. * Creates the "frame" texture Buffer
  135658. * -------------------------------------
  135659. * Structure of frames
  135660. * "filename": "Falling-Water-2.png",
  135661. * "frame": {"x":69,"y":103,"w":24,"h":32},
  135662. * "rotated": true,
  135663. * "trimmed": true,
  135664. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  135665. * "sourceSize": {"w":32,"h":32}
  135666. * @returns RawTexture of the frameMap
  135667. */
  135668. private _createFrameBuffer;
  135669. /**
  135670. * Creates the tileMap texture Buffer
  135671. * @param buffer normally and array of numbers, or a false to generate from scratch
  135672. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  135673. * @returns RawTexture of the tileMap
  135674. */
  135675. private _createTileBuffer;
  135676. /**
  135677. * Modifies the data of the tileMaps
  135678. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  135679. * @param pos is the iVector2 Coordinates of the Tile
  135680. * @param tile The SpriteIndex of the new Tile
  135681. */
  135682. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  135683. /**
  135684. * Creates the animationMap texture Buffer
  135685. * @param buffer normally and array of numbers, or a false to generate from scratch
  135686. * @returns RawTexture of the animationMap
  135687. */
  135688. private _createTileAnimationBuffer;
  135689. /**
  135690. * Modifies the data of the animationMap
  135691. * @param cellID is the Index of the Sprite
  135692. * @param _frame is the target Animation frame
  135693. * @param toCell is the Target Index of the next frame of the animation
  135694. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  135695. * @param speed is a global scalar of the time variable on the map.
  135696. */
  135697. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  135698. /**
  135699. * Exports the .tilemaps file
  135700. */
  135701. saveTileMaps(): void;
  135702. /**
  135703. * Imports the .tilemaps file
  135704. * @param url of the .tilemaps file
  135705. */
  135706. loadTileMaps(url: string): void;
  135707. /**
  135708. * Release associated resources
  135709. */
  135710. dispose(): void;
  135711. }
  135712. }
  135713. declare module BABYLON {
  135714. /**
  135715. * Class used to manage multiple sprites of different sizes on the same spritesheet
  135716. * @see http://doc.babylonjs.com/babylon101/sprites
  135717. */
  135718. export class SpritePackedManager extends SpriteManager {
  135719. /** defines the packed manager's name */
  135720. name: string;
  135721. /**
  135722. * Creates a new sprite manager from a packed sprite sheet
  135723. * @param name defines the manager's name
  135724. * @param imgUrl defines the sprite sheet url
  135725. * @param capacity defines the maximum allowed number of sprites
  135726. * @param scene defines the hosting scene
  135727. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  135728. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  135729. * @param samplingMode defines the smapling mode to use with spritesheet
  135730. * @param fromPacked set to true; do not alter
  135731. */
  135732. constructor(
  135733. /** defines the packed manager's name */
  135734. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  135735. }
  135736. }
  135737. declare module BABYLON {
  135738. /**
  135739. * Defines the list of states available for a task inside a AssetsManager
  135740. */
  135741. export enum AssetTaskState {
  135742. /**
  135743. * Initialization
  135744. */
  135745. INIT = 0,
  135746. /**
  135747. * Running
  135748. */
  135749. RUNNING = 1,
  135750. /**
  135751. * Done
  135752. */
  135753. DONE = 2,
  135754. /**
  135755. * Error
  135756. */
  135757. ERROR = 3
  135758. }
  135759. /**
  135760. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  135761. */
  135762. export abstract class AbstractAssetTask {
  135763. /**
  135764. * Task name
  135765. */ name: string;
  135766. /**
  135767. * Callback called when the task is successful
  135768. */
  135769. onSuccess: (task: any) => void;
  135770. /**
  135771. * Callback called when the task is not successful
  135772. */
  135773. onError: (task: any, message?: string, exception?: any) => void;
  135774. /**
  135775. * Creates a new AssetsManager
  135776. * @param name defines the name of the task
  135777. */
  135778. constructor(
  135779. /**
  135780. * Task name
  135781. */ name: string);
  135782. private _isCompleted;
  135783. private _taskState;
  135784. private _errorObject;
  135785. /**
  135786. * Get if the task is completed
  135787. */
  135788. get isCompleted(): boolean;
  135789. /**
  135790. * Gets the current state of the task
  135791. */
  135792. get taskState(): AssetTaskState;
  135793. /**
  135794. * Gets the current error object (if task is in error)
  135795. */
  135796. get errorObject(): {
  135797. message?: string;
  135798. exception?: any;
  135799. };
  135800. /**
  135801. * Internal only
  135802. * @hidden
  135803. */
  135804. _setErrorObject(message?: string, exception?: any): void;
  135805. /**
  135806. * Execute the current task
  135807. * @param scene defines the scene where you want your assets to be loaded
  135808. * @param onSuccess is a callback called when the task is successfully executed
  135809. * @param onError is a callback called if an error occurs
  135810. */
  135811. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135812. /**
  135813. * Execute the current task
  135814. * @param scene defines the scene where you want your assets to be loaded
  135815. * @param onSuccess is a callback called when the task is successfully executed
  135816. * @param onError is a callback called if an error occurs
  135817. */
  135818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135819. /**
  135820. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  135821. * This can be used with failed tasks that have the reason for failure fixed.
  135822. */
  135823. reset(): void;
  135824. private onErrorCallback;
  135825. private onDoneCallback;
  135826. }
  135827. /**
  135828. * Define the interface used by progress events raised during assets loading
  135829. */
  135830. export interface IAssetsProgressEvent {
  135831. /**
  135832. * Defines the number of remaining tasks to process
  135833. */
  135834. remainingCount: number;
  135835. /**
  135836. * Defines the total number of tasks
  135837. */
  135838. totalCount: number;
  135839. /**
  135840. * Defines the task that was just processed
  135841. */
  135842. task: AbstractAssetTask;
  135843. }
  135844. /**
  135845. * Class used to share progress information about assets loading
  135846. */
  135847. export class AssetsProgressEvent implements IAssetsProgressEvent {
  135848. /**
  135849. * Defines the number of remaining tasks to process
  135850. */
  135851. remainingCount: number;
  135852. /**
  135853. * Defines the total number of tasks
  135854. */
  135855. totalCount: number;
  135856. /**
  135857. * Defines the task that was just processed
  135858. */
  135859. task: AbstractAssetTask;
  135860. /**
  135861. * Creates a AssetsProgressEvent
  135862. * @param remainingCount defines the number of remaining tasks to process
  135863. * @param totalCount defines the total number of tasks
  135864. * @param task defines the task that was just processed
  135865. */
  135866. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  135867. }
  135868. /**
  135869. * Define a task used by AssetsManager to load meshes
  135870. */
  135871. export class MeshAssetTask extends AbstractAssetTask {
  135872. /**
  135873. * Defines the name of the task
  135874. */
  135875. name: string;
  135876. /**
  135877. * Defines the list of mesh's names you want to load
  135878. */
  135879. meshesNames: any;
  135880. /**
  135881. * Defines the root url to use as a base to load your meshes and associated resources
  135882. */
  135883. rootUrl: string;
  135884. /**
  135885. * Defines the filename of the scene to load from
  135886. */
  135887. sceneFilename: string;
  135888. /**
  135889. * Gets the list of loaded meshes
  135890. */
  135891. loadedMeshes: Array<AbstractMesh>;
  135892. /**
  135893. * Gets the list of loaded particle systems
  135894. */
  135895. loadedParticleSystems: Array<IParticleSystem>;
  135896. /**
  135897. * Gets the list of loaded skeletons
  135898. */
  135899. loadedSkeletons: Array<Skeleton>;
  135900. /**
  135901. * Gets the list of loaded animation groups
  135902. */
  135903. loadedAnimationGroups: Array<AnimationGroup>;
  135904. /**
  135905. * Callback called when the task is successful
  135906. */
  135907. onSuccess: (task: MeshAssetTask) => void;
  135908. /**
  135909. * Callback called when the task is successful
  135910. */
  135911. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  135912. /**
  135913. * Creates a new MeshAssetTask
  135914. * @param name defines the name of the task
  135915. * @param meshesNames defines the list of mesh's names you want to load
  135916. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  135917. * @param sceneFilename defines the filename of the scene to load from
  135918. */
  135919. constructor(
  135920. /**
  135921. * Defines the name of the task
  135922. */
  135923. name: string,
  135924. /**
  135925. * Defines the list of mesh's names you want to load
  135926. */
  135927. meshesNames: any,
  135928. /**
  135929. * Defines the root url to use as a base to load your meshes and associated resources
  135930. */
  135931. rootUrl: string,
  135932. /**
  135933. * Defines the filename of the scene to load from
  135934. */
  135935. sceneFilename: string);
  135936. /**
  135937. * Execute the current task
  135938. * @param scene defines the scene where you want your assets to be loaded
  135939. * @param onSuccess is a callback called when the task is successfully executed
  135940. * @param onError is a callback called if an error occurs
  135941. */
  135942. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135943. }
  135944. /**
  135945. * Define a task used by AssetsManager to load text content
  135946. */
  135947. export class TextFileAssetTask extends AbstractAssetTask {
  135948. /**
  135949. * Defines the name of the task
  135950. */
  135951. name: string;
  135952. /**
  135953. * Defines the location of the file to load
  135954. */
  135955. url: string;
  135956. /**
  135957. * Gets the loaded text string
  135958. */
  135959. text: string;
  135960. /**
  135961. * Callback called when the task is successful
  135962. */
  135963. onSuccess: (task: TextFileAssetTask) => void;
  135964. /**
  135965. * Callback called when the task is successful
  135966. */
  135967. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  135968. /**
  135969. * Creates a new TextFileAssetTask object
  135970. * @param name defines the name of the task
  135971. * @param url defines the location of the file to load
  135972. */
  135973. constructor(
  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. * Execute the current task
  135984. * @param scene defines the scene where you want your assets to be loaded
  135985. * @param onSuccess is a callback called when the task is successfully executed
  135986. * @param onError is a callback called if an error occurs
  135987. */
  135988. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135989. }
  135990. /**
  135991. * Define a task used by AssetsManager to load binary data
  135992. */
  135993. export class BinaryFileAssetTask extends AbstractAssetTask {
  135994. /**
  135995. * Defines the name of the task
  135996. */
  135997. name: string;
  135998. /**
  135999. * Defines the location of the file to load
  136000. */
  136001. url: string;
  136002. /**
  136003. * Gets the lodaded data (as an array buffer)
  136004. */
  136005. data: ArrayBuffer;
  136006. /**
  136007. * Callback called when the task is successful
  136008. */
  136009. onSuccess: (task: BinaryFileAssetTask) => void;
  136010. /**
  136011. * Callback called when the task is successful
  136012. */
  136013. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  136014. /**
  136015. * Creates a new BinaryFileAssetTask object
  136016. * @param name defines the name of the new task
  136017. * @param url defines the location of the file to load
  136018. */
  136019. constructor(
  136020. /**
  136021. * Defines the name of the task
  136022. */
  136023. name: string,
  136024. /**
  136025. * Defines the location of the file to load
  136026. */
  136027. url: string);
  136028. /**
  136029. * Execute the current task
  136030. * @param scene defines the scene where you want your assets to be loaded
  136031. * @param onSuccess is a callback called when the task is successfully executed
  136032. * @param onError is a callback called if an error occurs
  136033. */
  136034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136035. }
  136036. /**
  136037. * Define a task used by AssetsManager to load images
  136038. */
  136039. export class ImageAssetTask extends AbstractAssetTask {
  136040. /**
  136041. * Defines the name of the task
  136042. */
  136043. name: string;
  136044. /**
  136045. * Defines the location of the image to load
  136046. */
  136047. url: string;
  136048. /**
  136049. * Gets the loaded images
  136050. */
  136051. image: HTMLImageElement;
  136052. /**
  136053. * Callback called when the task is successful
  136054. */
  136055. onSuccess: (task: ImageAssetTask) => void;
  136056. /**
  136057. * Callback called when the task is successful
  136058. */
  136059. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  136060. /**
  136061. * Creates a new ImageAssetTask
  136062. * @param name defines the name of the task
  136063. * @param url defines the location of the image to load
  136064. */
  136065. constructor(
  136066. /**
  136067. * Defines the name of the task
  136068. */
  136069. name: string,
  136070. /**
  136071. * Defines the location of the image to load
  136072. */
  136073. url: string);
  136074. /**
  136075. * Execute the current task
  136076. * @param scene defines the scene where you want your assets to be loaded
  136077. * @param onSuccess is a callback called when the task is successfully executed
  136078. * @param onError is a callback called if an error occurs
  136079. */
  136080. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136081. }
  136082. /**
  136083. * Defines the interface used by texture loading tasks
  136084. */
  136085. export interface ITextureAssetTask<TEX extends BaseTexture> {
  136086. /**
  136087. * Gets the loaded texture
  136088. */
  136089. texture: TEX;
  136090. }
  136091. /**
  136092. * Define a task used by AssetsManager to load 2D textures
  136093. */
  136094. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  136095. /**
  136096. * Defines the name of the task
  136097. */
  136098. name: string;
  136099. /**
  136100. * Defines the location of the file to load
  136101. */
  136102. url: string;
  136103. /**
  136104. * Defines if mipmap should not be generated (default is false)
  136105. */
  136106. noMipmap?: boolean | undefined;
  136107. /**
  136108. * Defines if texture must be inverted on Y axis (default is false)
  136109. */
  136110. invertY?: boolean | undefined;
  136111. /**
  136112. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136113. */
  136114. samplingMode: number;
  136115. /**
  136116. * Gets the loaded texture
  136117. */
  136118. texture: Texture;
  136119. /**
  136120. * Callback called when the task is successful
  136121. */
  136122. onSuccess: (task: TextureAssetTask) => void;
  136123. /**
  136124. * Callback called when the task is successful
  136125. */
  136126. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  136127. /**
  136128. * Creates a new TextureAssetTask object
  136129. * @param name defines the name of the task
  136130. * @param url defines the location of the file to load
  136131. * @param noMipmap defines if mipmap should not be generated (default is false)
  136132. * @param invertY defines if texture must be inverted on Y axis (default is false)
  136133. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136134. */
  136135. constructor(
  136136. /**
  136137. * Defines the name of the task
  136138. */
  136139. name: string,
  136140. /**
  136141. * Defines the location of the file to load
  136142. */
  136143. url: string,
  136144. /**
  136145. * Defines if mipmap should not be generated (default is false)
  136146. */
  136147. noMipmap?: boolean | undefined,
  136148. /**
  136149. * Defines if texture must be inverted on Y axis (default is false)
  136150. */
  136151. invertY?: boolean | undefined,
  136152. /**
  136153. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136154. */
  136155. samplingMode?: number);
  136156. /**
  136157. * Execute the current task
  136158. * @param scene defines the scene where you want your assets to be loaded
  136159. * @param onSuccess is a callback called when the task is successfully executed
  136160. * @param onError is a callback called if an error occurs
  136161. */
  136162. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136163. }
  136164. /**
  136165. * Define a task used by AssetsManager to load cube textures
  136166. */
  136167. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  136168. /**
  136169. * Defines the name of the task
  136170. */
  136171. name: string;
  136172. /**
  136173. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136174. */
  136175. url: string;
  136176. /**
  136177. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136178. */
  136179. extensions?: string[] | undefined;
  136180. /**
  136181. * Defines if mipmaps should not be generated (default is false)
  136182. */
  136183. noMipmap?: boolean | undefined;
  136184. /**
  136185. * Defines the explicit list of files (undefined by default)
  136186. */
  136187. files?: string[] | undefined;
  136188. /**
  136189. * Gets the loaded texture
  136190. */
  136191. texture: CubeTexture;
  136192. /**
  136193. * Callback called when the task is successful
  136194. */
  136195. onSuccess: (task: CubeTextureAssetTask) => void;
  136196. /**
  136197. * Callback called when the task is successful
  136198. */
  136199. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  136200. /**
  136201. * Creates a new CubeTextureAssetTask
  136202. * @param name defines the name of the task
  136203. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136204. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136205. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136206. * @param files defines the explicit list of files (undefined by default)
  136207. */
  136208. constructor(
  136209. /**
  136210. * Defines the name of the task
  136211. */
  136212. name: string,
  136213. /**
  136214. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136215. */
  136216. url: string,
  136217. /**
  136218. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136219. */
  136220. extensions?: string[] | undefined,
  136221. /**
  136222. * Defines if mipmaps should not be generated (default is false)
  136223. */
  136224. noMipmap?: boolean | undefined,
  136225. /**
  136226. * Defines the explicit list of files (undefined by default)
  136227. */
  136228. files?: string[] | undefined);
  136229. /**
  136230. * Execute the current task
  136231. * @param scene defines the scene where you want your assets to be loaded
  136232. * @param onSuccess is a callback called when the task is successfully executed
  136233. * @param onError is a callback called if an error occurs
  136234. */
  136235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136236. }
  136237. /**
  136238. * Define a task used by AssetsManager to load HDR cube textures
  136239. */
  136240. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  136241. /**
  136242. * Defines the name of the task
  136243. */
  136244. name: string;
  136245. /**
  136246. * Defines the location of the file to load
  136247. */
  136248. url: string;
  136249. /**
  136250. * Defines the desired size (the more it increases the longer the generation will be)
  136251. */
  136252. size: number;
  136253. /**
  136254. * Defines if mipmaps should not be generated (default is false)
  136255. */
  136256. noMipmap: boolean;
  136257. /**
  136258. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136259. */
  136260. generateHarmonics: boolean;
  136261. /**
  136262. * 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)
  136263. */
  136264. gammaSpace: boolean;
  136265. /**
  136266. * Internal Use Only
  136267. */
  136268. reserved: boolean;
  136269. /**
  136270. * Gets the loaded texture
  136271. */
  136272. texture: HDRCubeTexture;
  136273. /**
  136274. * Callback called when the task is successful
  136275. */
  136276. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  136277. /**
  136278. * Callback called when the task is successful
  136279. */
  136280. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  136281. /**
  136282. * Creates a new HDRCubeTextureAssetTask object
  136283. * @param name defines the name of the task
  136284. * @param url defines the location of the file to load
  136285. * @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.
  136286. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136287. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136288. * @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)
  136289. * @param reserved Internal use only
  136290. */
  136291. constructor(
  136292. /**
  136293. * Defines the name of the task
  136294. */
  136295. name: string,
  136296. /**
  136297. * Defines the location of the file to load
  136298. */
  136299. url: string,
  136300. /**
  136301. * Defines the desired size (the more it increases the longer the generation will be)
  136302. */
  136303. size: number,
  136304. /**
  136305. * Defines if mipmaps should not be generated (default is false)
  136306. */
  136307. noMipmap?: boolean,
  136308. /**
  136309. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136310. */
  136311. generateHarmonics?: boolean,
  136312. /**
  136313. * 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)
  136314. */
  136315. gammaSpace?: boolean,
  136316. /**
  136317. * Internal Use Only
  136318. */
  136319. reserved?: boolean);
  136320. /**
  136321. * Execute the current task
  136322. * @param scene defines the scene where you want your assets to be loaded
  136323. * @param onSuccess is a callback called when the task is successfully executed
  136324. * @param onError is a callback called if an error occurs
  136325. */
  136326. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136327. }
  136328. /**
  136329. * Define a task used by AssetsManager to load Equirectangular cube textures
  136330. */
  136331. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  136332. /**
  136333. * Defines the name of the task
  136334. */
  136335. name: string;
  136336. /**
  136337. * Defines the location of the file to load
  136338. */
  136339. url: string;
  136340. /**
  136341. * Defines the desired size (the more it increases the longer the generation will be)
  136342. */
  136343. size: number;
  136344. /**
  136345. * Defines if mipmaps should not be generated (default is false)
  136346. */
  136347. noMipmap: boolean;
  136348. /**
  136349. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136350. * but the standard material would require them in Gamma space) (default is true)
  136351. */
  136352. gammaSpace: boolean;
  136353. /**
  136354. * Gets the loaded texture
  136355. */
  136356. texture: EquiRectangularCubeTexture;
  136357. /**
  136358. * Callback called when the task is successful
  136359. */
  136360. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  136361. /**
  136362. * Callback called when the task is successful
  136363. */
  136364. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  136365. /**
  136366. * Creates a new EquiRectangularCubeTextureAssetTask object
  136367. * @param name defines the name of the task
  136368. * @param url defines the location of the file to load
  136369. * @param size defines the desired size (the more it increases the longer the generation will be)
  136370. * If the size is omitted this implies you are using a preprocessed cubemap.
  136371. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136372. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  136373. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  136374. * (default is true)
  136375. */
  136376. constructor(
  136377. /**
  136378. * Defines the name of the task
  136379. */
  136380. name: string,
  136381. /**
  136382. * Defines the location of the file to load
  136383. */
  136384. url: string,
  136385. /**
  136386. * Defines the desired size (the more it increases the longer the generation will be)
  136387. */
  136388. size: number,
  136389. /**
  136390. * Defines if mipmaps should not be generated (default is false)
  136391. */
  136392. noMipmap?: boolean,
  136393. /**
  136394. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136395. * but the standard material would require them in Gamma space) (default is true)
  136396. */
  136397. gammaSpace?: boolean);
  136398. /**
  136399. * Execute the current task
  136400. * @param scene defines the scene where you want your assets to be loaded
  136401. * @param onSuccess is a callback called when the task is successfully executed
  136402. * @param onError is a callback called if an error occurs
  136403. */
  136404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136405. }
  136406. /**
  136407. * This class can be used to easily import assets into a scene
  136408. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  136409. */
  136410. export class AssetsManager {
  136411. private _scene;
  136412. private _isLoading;
  136413. protected _tasks: AbstractAssetTask[];
  136414. protected _waitingTasksCount: number;
  136415. protected _totalTasksCount: number;
  136416. /**
  136417. * Callback called when all tasks are processed
  136418. */
  136419. onFinish: (tasks: AbstractAssetTask[]) => void;
  136420. /**
  136421. * Callback called when a task is successful
  136422. */
  136423. onTaskSuccess: (task: AbstractAssetTask) => void;
  136424. /**
  136425. * Callback called when a task had an error
  136426. */
  136427. onTaskError: (task: AbstractAssetTask) => void;
  136428. /**
  136429. * Callback called when a task is done (whatever the result is)
  136430. */
  136431. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  136432. /**
  136433. * Observable called when all tasks are processed
  136434. */
  136435. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  136436. /**
  136437. * Observable called when a task had an error
  136438. */
  136439. onTaskErrorObservable: Observable<AbstractAssetTask>;
  136440. /**
  136441. * Observable called when all tasks were executed
  136442. */
  136443. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  136444. /**
  136445. * Observable called when a task is done (whatever the result is)
  136446. */
  136447. onProgressObservable: Observable<IAssetsProgressEvent>;
  136448. /**
  136449. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  136450. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  136451. */
  136452. useDefaultLoadingScreen: boolean;
  136453. /**
  136454. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  136455. * when all assets have been downloaded.
  136456. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  136457. */
  136458. autoHideLoadingUI: boolean;
  136459. /**
  136460. * Creates a new AssetsManager
  136461. * @param scene defines the scene to work on
  136462. */
  136463. constructor(scene: Scene);
  136464. /**
  136465. * Add a MeshAssetTask to the list of active tasks
  136466. * @param taskName defines the name of the new task
  136467. * @param meshesNames defines the name of meshes to load
  136468. * @param rootUrl defines the root url to use to locate files
  136469. * @param sceneFilename defines the filename of the scene file
  136470. * @returns a new MeshAssetTask object
  136471. */
  136472. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  136473. /**
  136474. * Add a TextFileAssetTask to the list of active tasks
  136475. * @param taskName defines the name of the new task
  136476. * @param url defines the url of the file to load
  136477. * @returns a new TextFileAssetTask object
  136478. */
  136479. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  136480. /**
  136481. * Add a BinaryFileAssetTask to the list of active tasks
  136482. * @param taskName defines the name of the new task
  136483. * @param url defines the url of the file to load
  136484. * @returns a new BinaryFileAssetTask object
  136485. */
  136486. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  136487. /**
  136488. * Add a ImageAssetTask to the list of active tasks
  136489. * @param taskName defines the name of the new task
  136490. * @param url defines the url of the file to load
  136491. * @returns a new ImageAssetTask object
  136492. */
  136493. addImageTask(taskName: string, url: string): ImageAssetTask;
  136494. /**
  136495. * Add a TextureAssetTask to the list of active tasks
  136496. * @param taskName defines the name of the new task
  136497. * @param url defines the url of the file to load
  136498. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136499. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  136500. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  136501. * @returns a new TextureAssetTask object
  136502. */
  136503. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  136504. /**
  136505. * Add a CubeTextureAssetTask to the list of active tasks
  136506. * @param taskName defines the name of the new task
  136507. * @param url defines the url of the file to load
  136508. * @param extensions defines the extension to use to load the cube map (can be null)
  136509. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136510. * @param files defines the list of files to load (can be null)
  136511. * @returns a new CubeTextureAssetTask object
  136512. */
  136513. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  136514. /**
  136515. *
  136516. * Add a HDRCubeTextureAssetTask to the list of active tasks
  136517. * @param taskName defines the name of the new task
  136518. * @param url defines the url of the file to load
  136519. * @param size defines the size you want for the cubemap (can be null)
  136520. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136521. * @param generateHarmonics defines if you want to automatically generate (true by default)
  136522. * @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)
  136523. * @param reserved Internal use only
  136524. * @returns a new HDRCubeTextureAssetTask object
  136525. */
  136526. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  136527. /**
  136528. *
  136529. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  136530. * @param taskName defines the name of the new task
  136531. * @param url defines the url of the file to load
  136532. * @param size defines the size you want for the cubemap (can be null)
  136533. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136534. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136535. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136536. * @returns a new EquiRectangularCubeTextureAssetTask object
  136537. */
  136538. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  136539. /**
  136540. * Remove a task from the assets manager.
  136541. * @param task the task to remove
  136542. */
  136543. removeTask(task: AbstractAssetTask): void;
  136544. private _decreaseWaitingTasksCount;
  136545. private _runTask;
  136546. /**
  136547. * Reset the AssetsManager and remove all tasks
  136548. * @return the current instance of the AssetsManager
  136549. */
  136550. reset(): AssetsManager;
  136551. /**
  136552. * Start the loading process
  136553. * @return the current instance of the AssetsManager
  136554. */
  136555. load(): AssetsManager;
  136556. /**
  136557. * Start the loading process as an async operation
  136558. * @return a promise returning the list of failed tasks
  136559. */
  136560. loadAsync(): Promise<void>;
  136561. }
  136562. }
  136563. declare module BABYLON {
  136564. /**
  136565. * Wrapper class for promise with external resolve and reject.
  136566. */
  136567. export class Deferred<T> {
  136568. /**
  136569. * The promise associated with this deferred object.
  136570. */
  136571. readonly promise: Promise<T>;
  136572. private _resolve;
  136573. private _reject;
  136574. /**
  136575. * The resolve method of the promise associated with this deferred object.
  136576. */
  136577. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  136578. /**
  136579. * The reject method of the promise associated with this deferred object.
  136580. */
  136581. get reject(): (reason?: any) => void;
  136582. /**
  136583. * Constructor for this deferred object.
  136584. */
  136585. constructor();
  136586. }
  136587. }
  136588. declare module BABYLON {
  136589. /**
  136590. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  136591. */
  136592. export class MeshExploder {
  136593. private _centerMesh;
  136594. private _meshes;
  136595. private _meshesOrigins;
  136596. private _toCenterVectors;
  136597. private _scaledDirection;
  136598. private _newPosition;
  136599. private _centerPosition;
  136600. /**
  136601. * Explodes meshes from a center mesh.
  136602. * @param meshes The meshes to explode.
  136603. * @param centerMesh The mesh to be center of explosion.
  136604. */
  136605. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  136606. private _setCenterMesh;
  136607. /**
  136608. * Get class name
  136609. * @returns "MeshExploder"
  136610. */
  136611. getClassName(): string;
  136612. /**
  136613. * "Exploded meshes"
  136614. * @returns Array of meshes with the centerMesh at index 0.
  136615. */
  136616. getMeshes(): Array<Mesh>;
  136617. /**
  136618. * Explodes meshes giving a specific direction
  136619. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  136620. */
  136621. explode(direction?: number): void;
  136622. }
  136623. }
  136624. declare module BABYLON {
  136625. /**
  136626. * Class used to help managing file picking and drag'n'drop
  136627. */
  136628. export class FilesInput {
  136629. /**
  136630. * List of files ready to be loaded
  136631. */
  136632. static get FilesToLoad(): {
  136633. [key: string]: File;
  136634. };
  136635. /**
  136636. * Callback called when a file is processed
  136637. */
  136638. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  136639. private _engine;
  136640. private _currentScene;
  136641. private _sceneLoadedCallback;
  136642. private _progressCallback;
  136643. private _additionalRenderLoopLogicCallback;
  136644. private _textureLoadingCallback;
  136645. private _startingProcessingFilesCallback;
  136646. private _onReloadCallback;
  136647. private _errorCallback;
  136648. private _elementToMonitor;
  136649. private _sceneFileToLoad;
  136650. private _filesToLoad;
  136651. /**
  136652. * Creates a new FilesInput
  136653. * @param engine defines the rendering engine
  136654. * @param scene defines the hosting scene
  136655. * @param sceneLoadedCallback callback called when scene is loaded
  136656. * @param progressCallback callback called to track progress
  136657. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  136658. * @param textureLoadingCallback callback called when a texture is loading
  136659. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  136660. * @param onReloadCallback callback called when a reload is requested
  136661. * @param errorCallback callback call if an error occurs
  136662. */
  136663. 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);
  136664. private _dragEnterHandler;
  136665. private _dragOverHandler;
  136666. private _dropHandler;
  136667. /**
  136668. * Calls this function to listen to drag'n'drop events on a specific DOM element
  136669. * @param elementToMonitor defines the DOM element to track
  136670. */
  136671. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  136672. /**
  136673. * Release all associated resources
  136674. */
  136675. dispose(): void;
  136676. private renderFunction;
  136677. private drag;
  136678. private drop;
  136679. private _traverseFolder;
  136680. private _processFiles;
  136681. /**
  136682. * Load files from a drop event
  136683. * @param event defines the drop event to use as source
  136684. */
  136685. loadFiles(event: any): void;
  136686. private _processReload;
  136687. /**
  136688. * Reload the current scene from the loaded files
  136689. */
  136690. reload(): void;
  136691. }
  136692. }
  136693. declare module BABYLON {
  136694. /**
  136695. * Defines the root class used to create scene optimization to use with SceneOptimizer
  136696. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136697. */
  136698. export class SceneOptimization {
  136699. /**
  136700. * Defines the priority of this optimization (0 by default which means first in the list)
  136701. */
  136702. priority: number;
  136703. /**
  136704. * Gets a string describing the action executed by the current optimization
  136705. * @returns description string
  136706. */
  136707. getDescription(): string;
  136708. /**
  136709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136710. * @param scene defines the current scene where to apply this optimization
  136711. * @param optimizer defines the current optimizer
  136712. * @returns true if everything that can be done was applied
  136713. */
  136714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136715. /**
  136716. * Creates the SceneOptimization object
  136717. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136718. * @param desc defines the description associated with the optimization
  136719. */
  136720. constructor(
  136721. /**
  136722. * Defines the priority of this optimization (0 by default which means first in the list)
  136723. */
  136724. priority?: number);
  136725. }
  136726. /**
  136727. * Defines an optimization used to reduce the size of render target textures
  136728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136729. */
  136730. export class TextureOptimization extends SceneOptimization {
  136731. /**
  136732. * Defines the priority of this optimization (0 by default which means first in the list)
  136733. */
  136734. priority: number;
  136735. /**
  136736. * 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
  136737. */
  136738. maximumSize: number;
  136739. /**
  136740. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136741. */
  136742. step: number;
  136743. /**
  136744. * Gets a string describing the action executed by the current optimization
  136745. * @returns description string
  136746. */
  136747. getDescription(): string;
  136748. /**
  136749. * Creates the TextureOptimization object
  136750. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136751. * @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
  136752. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136753. */
  136754. constructor(
  136755. /**
  136756. * Defines the priority of this optimization (0 by default which means first in the list)
  136757. */
  136758. priority?: number,
  136759. /**
  136760. * 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
  136761. */
  136762. maximumSize?: number,
  136763. /**
  136764. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136765. */
  136766. step?: number);
  136767. /**
  136768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136769. * @param scene defines the current scene where to apply this optimization
  136770. * @param optimizer defines the current optimizer
  136771. * @returns true if everything that can be done was applied
  136772. */
  136773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136774. }
  136775. /**
  136776. * Defines an optimization used to increase or decrease the rendering resolution
  136777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136778. */
  136779. export class HardwareScalingOptimization extends SceneOptimization {
  136780. /**
  136781. * Defines the priority of this optimization (0 by default which means first in the list)
  136782. */
  136783. priority: number;
  136784. /**
  136785. * Defines the maximum scale to use (2 by default)
  136786. */
  136787. maximumScale: number;
  136788. /**
  136789. * Defines the step to use between two passes (0.5 by default)
  136790. */
  136791. step: number;
  136792. private _currentScale;
  136793. private _directionOffset;
  136794. /**
  136795. * Gets a string describing the action executed by the current optimization
  136796. * @return description string
  136797. */
  136798. getDescription(): string;
  136799. /**
  136800. * Creates the HardwareScalingOptimization object
  136801. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136802. * @param maximumScale defines the maximum scale to use (2 by default)
  136803. * @param step defines the step to use between two passes (0.5 by default)
  136804. */
  136805. constructor(
  136806. /**
  136807. * Defines the priority of this optimization (0 by default which means first in the list)
  136808. */
  136809. priority?: number,
  136810. /**
  136811. * Defines the maximum scale to use (2 by default)
  136812. */
  136813. maximumScale?: number,
  136814. /**
  136815. * Defines the step to use between two passes (0.5 by default)
  136816. */
  136817. step?: number);
  136818. /**
  136819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136820. * @param scene defines the current scene where to apply this optimization
  136821. * @param optimizer defines the current optimizer
  136822. * @returns true if everything that can be done was applied
  136823. */
  136824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136825. }
  136826. /**
  136827. * Defines an optimization used to remove shadows
  136828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136829. */
  136830. export class ShadowsOptimization extends SceneOptimization {
  136831. /**
  136832. * Gets a string describing the action executed by the current optimization
  136833. * @return description string
  136834. */
  136835. getDescription(): string;
  136836. /**
  136837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136838. * @param scene defines the current scene where to apply this optimization
  136839. * @param optimizer defines the current optimizer
  136840. * @returns true if everything that can be done was applied
  136841. */
  136842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136843. }
  136844. /**
  136845. * Defines an optimization used to turn post-processes off
  136846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136847. */
  136848. export class PostProcessesOptimization extends SceneOptimization {
  136849. /**
  136850. * Gets a string describing the action executed by the current optimization
  136851. * @return description string
  136852. */
  136853. getDescription(): string;
  136854. /**
  136855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136856. * @param scene defines the current scene where to apply this optimization
  136857. * @param optimizer defines the current optimizer
  136858. * @returns true if everything that can be done was applied
  136859. */
  136860. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136861. }
  136862. /**
  136863. * Defines an optimization used to turn lens flares off
  136864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136865. */
  136866. export class LensFlaresOptimization extends SceneOptimization {
  136867. /**
  136868. * Gets a string describing the action executed by the current optimization
  136869. * @return description string
  136870. */
  136871. getDescription(): string;
  136872. /**
  136873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136874. * @param scene defines the current scene where to apply this optimization
  136875. * @param optimizer defines the current optimizer
  136876. * @returns true if everything that can be done was applied
  136877. */
  136878. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136879. }
  136880. /**
  136881. * Defines an optimization based on user defined callback.
  136882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136883. */
  136884. export class CustomOptimization extends SceneOptimization {
  136885. /**
  136886. * Callback called to apply the custom optimization.
  136887. */
  136888. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  136889. /**
  136890. * Callback called to get custom description
  136891. */
  136892. onGetDescription: () => string;
  136893. /**
  136894. * Gets a string describing the action executed by the current optimization
  136895. * @returns description string
  136896. */
  136897. getDescription(): string;
  136898. /**
  136899. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136900. * @param scene defines the current scene where to apply this optimization
  136901. * @param optimizer defines the current optimizer
  136902. * @returns true if everything that can be done was applied
  136903. */
  136904. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136905. }
  136906. /**
  136907. * Defines an optimization used to turn particles off
  136908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136909. */
  136910. export class ParticlesOptimization extends SceneOptimization {
  136911. /**
  136912. * Gets a string describing the action executed by the current optimization
  136913. * @return description string
  136914. */
  136915. getDescription(): string;
  136916. /**
  136917. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136918. * @param scene defines the current scene where to apply this optimization
  136919. * @param optimizer defines the current optimizer
  136920. * @returns true if everything that can be done was applied
  136921. */
  136922. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136923. }
  136924. /**
  136925. * Defines an optimization used to turn render targets off
  136926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136927. */
  136928. export class RenderTargetsOptimization extends SceneOptimization {
  136929. /**
  136930. * Gets a string describing the action executed by the current optimization
  136931. * @return description string
  136932. */
  136933. getDescription(): string;
  136934. /**
  136935. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136936. * @param scene defines the current scene where to apply this optimization
  136937. * @param optimizer defines the current optimizer
  136938. * @returns true if everything that can be done was applied
  136939. */
  136940. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136941. }
  136942. /**
  136943. * Defines an optimization used to merge meshes with compatible materials
  136944. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136945. */
  136946. export class MergeMeshesOptimization extends SceneOptimization {
  136947. private static _UpdateSelectionTree;
  136948. /**
  136949. * Gets or sets a boolean which defines if optimization octree has to be updated
  136950. */
  136951. static get UpdateSelectionTree(): boolean;
  136952. /**
  136953. * Gets or sets a boolean which defines if optimization octree has to be updated
  136954. */
  136955. static set UpdateSelectionTree(value: boolean);
  136956. /**
  136957. * Gets a string describing the action executed by the current optimization
  136958. * @return description string
  136959. */
  136960. getDescription(): string;
  136961. private _canBeMerged;
  136962. /**
  136963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136964. * @param scene defines the current scene where to apply this optimization
  136965. * @param optimizer defines the current optimizer
  136966. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  136967. * @returns true if everything that can be done was applied
  136968. */
  136969. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  136970. }
  136971. /**
  136972. * Defines a list of options used by SceneOptimizer
  136973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136974. */
  136975. export class SceneOptimizerOptions {
  136976. /**
  136977. * Defines the target frame rate to reach (60 by default)
  136978. */
  136979. targetFrameRate: number;
  136980. /**
  136981. * Defines the interval between two checkes (2000ms by default)
  136982. */
  136983. trackerDuration: number;
  136984. /**
  136985. * Gets the list of optimizations to apply
  136986. */
  136987. optimizations: SceneOptimization[];
  136988. /**
  136989. * Creates a new list of options used by SceneOptimizer
  136990. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  136991. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  136992. */
  136993. constructor(
  136994. /**
  136995. * Defines the target frame rate to reach (60 by default)
  136996. */
  136997. targetFrameRate?: number,
  136998. /**
  136999. * Defines the interval between two checkes (2000ms by default)
  137000. */
  137001. trackerDuration?: number);
  137002. /**
  137003. * Add a new optimization
  137004. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  137005. * @returns the current SceneOptimizerOptions
  137006. */
  137007. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  137008. /**
  137009. * Add a new custom optimization
  137010. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  137011. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  137012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  137013. * @returns the current SceneOptimizerOptions
  137014. */
  137015. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  137016. /**
  137017. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  137018. * @param targetFrameRate defines the target frame rate (60 by default)
  137019. * @returns a SceneOptimizerOptions object
  137020. */
  137021. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137022. /**
  137023. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  137024. * @param targetFrameRate defines the target frame rate (60 by default)
  137025. * @returns a SceneOptimizerOptions object
  137026. */
  137027. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137028. /**
  137029. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  137030. * @param targetFrameRate defines the target frame rate (60 by default)
  137031. * @returns a SceneOptimizerOptions object
  137032. */
  137033. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137034. }
  137035. /**
  137036. * Class used to run optimizations in order to reach a target frame rate
  137037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137038. */
  137039. export class SceneOptimizer implements IDisposable {
  137040. private _isRunning;
  137041. private _options;
  137042. private _scene;
  137043. private _currentPriorityLevel;
  137044. private _targetFrameRate;
  137045. private _trackerDuration;
  137046. private _currentFrameRate;
  137047. private _sceneDisposeObserver;
  137048. private _improvementMode;
  137049. /**
  137050. * Defines an observable called when the optimizer reaches the target frame rate
  137051. */
  137052. onSuccessObservable: Observable<SceneOptimizer>;
  137053. /**
  137054. * Defines an observable called when the optimizer enables an optimization
  137055. */
  137056. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  137057. /**
  137058. * Defines an observable called when the optimizer is not able to reach the target frame rate
  137059. */
  137060. onFailureObservable: Observable<SceneOptimizer>;
  137061. /**
  137062. * Gets a boolean indicating if the optimizer is in improvement mode
  137063. */
  137064. get isInImprovementMode(): boolean;
  137065. /**
  137066. * Gets the current priority level (0 at start)
  137067. */
  137068. get currentPriorityLevel(): number;
  137069. /**
  137070. * Gets the current frame rate checked by the SceneOptimizer
  137071. */
  137072. get currentFrameRate(): number;
  137073. /**
  137074. * Gets or sets the current target frame rate (60 by default)
  137075. */
  137076. get targetFrameRate(): number;
  137077. /**
  137078. * Gets or sets the current target frame rate (60 by default)
  137079. */
  137080. set targetFrameRate(value: number);
  137081. /**
  137082. * Gets or sets the current interval between two checks (every 2000ms by default)
  137083. */
  137084. get trackerDuration(): number;
  137085. /**
  137086. * Gets or sets the current interval between two checks (every 2000ms by default)
  137087. */
  137088. set trackerDuration(value: number);
  137089. /**
  137090. * Gets the list of active optimizations
  137091. */
  137092. get optimizations(): SceneOptimization[];
  137093. /**
  137094. * Creates a new SceneOptimizer
  137095. * @param scene defines the scene to work on
  137096. * @param options defines the options to use with the SceneOptimizer
  137097. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  137098. * @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)
  137099. */
  137100. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  137101. /**
  137102. * Stops the current optimizer
  137103. */
  137104. stop(): void;
  137105. /**
  137106. * Reset the optimizer to initial step (current priority level = 0)
  137107. */
  137108. reset(): void;
  137109. /**
  137110. * Start the optimizer. By default it will try to reach a specific framerate
  137111. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  137112. */
  137113. start(): void;
  137114. private _checkCurrentState;
  137115. /**
  137116. * Release all resources
  137117. */
  137118. dispose(): void;
  137119. /**
  137120. * Helper function to create a SceneOptimizer with one single line of code
  137121. * @param scene defines the scene to work on
  137122. * @param options defines the options to use with the SceneOptimizer
  137123. * @param onSuccess defines a callback to call on success
  137124. * @param onFailure defines a callback to call on failure
  137125. * @returns the new SceneOptimizer object
  137126. */
  137127. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  137128. }
  137129. }
  137130. declare module BABYLON {
  137131. /**
  137132. * Class used to serialize a scene into a string
  137133. */
  137134. export class SceneSerializer {
  137135. /**
  137136. * Clear cache used by a previous serialization
  137137. */
  137138. static ClearCache(): void;
  137139. /**
  137140. * Serialize a scene into a JSON compatible object
  137141. * @param scene defines the scene to serialize
  137142. * @returns a JSON compatible object
  137143. */
  137144. static Serialize(scene: Scene): any;
  137145. /**
  137146. * Serialize a mesh into a JSON compatible object
  137147. * @param toSerialize defines the mesh to serialize
  137148. * @param withParents defines if parents must be serialized as well
  137149. * @param withChildren defines if children must be serialized as well
  137150. * @returns a JSON compatible object
  137151. */
  137152. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  137153. }
  137154. }
  137155. declare module BABYLON {
  137156. /**
  137157. * Class used to host texture specific utilities
  137158. */
  137159. export class TextureTools {
  137160. /**
  137161. * Uses the GPU to create a copy texture rescaled at a given size
  137162. * @param texture Texture to copy from
  137163. * @param width defines the desired width
  137164. * @param height defines the desired height
  137165. * @param useBilinearMode defines if bilinear mode has to be used
  137166. * @return the generated texture
  137167. */
  137168. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  137169. }
  137170. }
  137171. declare module BABYLON {
  137172. /**
  137173. * This represents the different options available for the video capture.
  137174. */
  137175. export interface VideoRecorderOptions {
  137176. /** Defines the mime type of the video. */
  137177. mimeType: string;
  137178. /** Defines the FPS the video should be recorded at. */
  137179. fps: number;
  137180. /** Defines the chunk size for the recording data. */
  137181. recordChunckSize: number;
  137182. /** The audio tracks to attach to the recording. */
  137183. audioTracks?: MediaStreamTrack[];
  137184. }
  137185. /**
  137186. * This can help with recording videos from BabylonJS.
  137187. * This is based on the available WebRTC functionalities of the browser.
  137188. *
  137189. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  137190. */
  137191. export class VideoRecorder {
  137192. private static readonly _defaultOptions;
  137193. /**
  137194. * Returns whether or not the VideoRecorder is available in your browser.
  137195. * @param engine Defines the Babylon Engine.
  137196. * @returns true if supported otherwise false.
  137197. */
  137198. static IsSupported(engine: Engine): boolean;
  137199. private readonly _options;
  137200. private _canvas;
  137201. private _mediaRecorder;
  137202. private _recordedChunks;
  137203. private _fileName;
  137204. private _resolve;
  137205. private _reject;
  137206. /**
  137207. * True when a recording is already in progress.
  137208. */
  137209. get isRecording(): boolean;
  137210. /**
  137211. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  137212. * @param engine Defines the BabylonJS Engine you wish to record.
  137213. * @param options Defines options that can be used to customize the capture.
  137214. */
  137215. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  137216. /**
  137217. * Stops the current recording before the default capture timeout passed in the startRecording function.
  137218. */
  137219. stopRecording(): void;
  137220. /**
  137221. * Starts recording the canvas for a max duration specified in parameters.
  137222. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  137223. * If null no automatic download will start and you can rely on the promise to get the data back.
  137224. * @param maxDuration Defines the maximum recording time in seconds.
  137225. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  137226. * @return A promise callback at the end of the recording with the video data in Blob.
  137227. */
  137228. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  137229. /**
  137230. * Releases internal resources used during the recording.
  137231. */
  137232. dispose(): void;
  137233. private _handleDataAvailable;
  137234. private _handleError;
  137235. private _handleStop;
  137236. }
  137237. }
  137238. declare module BABYLON {
  137239. /**
  137240. * Class containing a set of static utilities functions for screenshots
  137241. */
  137242. export class ScreenshotTools {
  137243. /**
  137244. * Captures a screenshot of the current rendering
  137245. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137246. * @param engine defines the rendering engine
  137247. * @param camera defines the source camera
  137248. * @param size This parameter can be set to a single number or to an object with the
  137249. * following (optional) properties: precision, width, height. If a single number is passed,
  137250. * it will be used for both width and height. If an object is passed, the screenshot size
  137251. * will be derived from the parameters. The precision property is a multiplier allowing
  137252. * rendering at a higher or lower resolution
  137253. * @param successCallback defines the callback receives a single parameter which contains the
  137254. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137255. * src parameter of an <img> to display it
  137256. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137257. * Check your browser for supported MIME types
  137258. */
  137259. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  137260. /**
  137261. * Captures a screenshot of the current rendering
  137262. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137263. * @param engine defines the rendering engine
  137264. * @param camera defines the source camera
  137265. * @param size This parameter can be set to a single number or to an object with the
  137266. * following (optional) properties: precision, width, height. If a single number is passed,
  137267. * it will be used for both width and height. If an object is passed, the screenshot size
  137268. * will be derived from the parameters. The precision property is a multiplier allowing
  137269. * rendering at a higher or lower resolution
  137270. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137271. * Check your browser for supported MIME types
  137272. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137273. * to the src parameter of an <img> to display it
  137274. */
  137275. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  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 successCallback The callback receives a single parameter which contains the
  137287. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137288. * src parameter of an <img> to display it
  137289. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137290. * Check your browser for supported MIME types
  137291. * @param samples Texture samples (default: 1)
  137292. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137293. * @param fileName A name for for the downloaded file.
  137294. */
  137295. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  137296. /**
  137297. * Generates an image screenshot from the specified camera.
  137298. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137299. * @param engine The engine to use for rendering
  137300. * @param camera The camera to use for rendering
  137301. * @param size This parameter can be set to a single number or to an object with the
  137302. * following (optional) properties: precision, width, height. If a single number is passed,
  137303. * it will be used for both width and height. If an object is passed, the screenshot size
  137304. * will be derived from the parameters. The precision property is a multiplier allowing
  137305. * rendering at a higher or lower resolution
  137306. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137307. * Check your browser for supported MIME types
  137308. * @param samples Texture samples (default: 1)
  137309. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137310. * @param fileName A name for for the downloaded file.
  137311. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137312. * to the src parameter of an <img> to display it
  137313. */
  137314. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  137315. /**
  137316. * Gets height and width for screenshot size
  137317. * @private
  137318. */
  137319. private static _getScreenshotSize;
  137320. }
  137321. }
  137322. declare module BABYLON {
  137323. /**
  137324. * Interface for a data buffer
  137325. */
  137326. export interface IDataBuffer {
  137327. /**
  137328. * Reads bytes from the data buffer.
  137329. * @param byteOffset The byte offset to read
  137330. * @param byteLength The byte length to read
  137331. * @returns A promise that resolves when the bytes are read
  137332. */
  137333. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  137334. /**
  137335. * The byte length of the buffer.
  137336. */
  137337. readonly byteLength: number;
  137338. }
  137339. /**
  137340. * Utility class for reading from a data buffer
  137341. */
  137342. export class DataReader {
  137343. /**
  137344. * The data buffer associated with this data reader.
  137345. */
  137346. readonly buffer: IDataBuffer;
  137347. /**
  137348. * The current byte offset from the beginning of the data buffer.
  137349. */
  137350. byteOffset: number;
  137351. private _dataView;
  137352. private _dataByteOffset;
  137353. /**
  137354. * Constructor
  137355. * @param buffer The buffer to read
  137356. */
  137357. constructor(buffer: IDataBuffer);
  137358. /**
  137359. * Loads the given byte length.
  137360. * @param byteLength The byte length to load
  137361. * @returns A promise that resolves when the load is complete
  137362. */
  137363. loadAsync(byteLength: number): Promise<void>;
  137364. /**
  137365. * Read a unsigned 32-bit integer from the currently loaded data range.
  137366. * @returns The 32-bit integer read
  137367. */
  137368. readUint32(): number;
  137369. /**
  137370. * Read a byte array from the currently loaded data range.
  137371. * @param byteLength The byte length to read
  137372. * @returns The byte array read
  137373. */
  137374. readUint8Array(byteLength: number): Uint8Array;
  137375. /**
  137376. * Read a string from the currently loaded data range.
  137377. * @param byteLength The byte length to read
  137378. * @returns The string read
  137379. */
  137380. readString(byteLength: number): string;
  137381. /**
  137382. * Skips the given byte length the currently loaded data range.
  137383. * @param byteLength The byte length to skip
  137384. */
  137385. skipBytes(byteLength: number): void;
  137386. }
  137387. }
  137388. declare module BABYLON {
  137389. /**
  137390. * A cursor which tracks a point on a path
  137391. */
  137392. export class PathCursor {
  137393. private path;
  137394. /**
  137395. * Stores path cursor callbacks for when an onchange event is triggered
  137396. */
  137397. private _onchange;
  137398. /**
  137399. * The value of the path cursor
  137400. */
  137401. value: number;
  137402. /**
  137403. * The animation array of the path cursor
  137404. */
  137405. animations: Animation[];
  137406. /**
  137407. * Initializes the path cursor
  137408. * @param path The path to track
  137409. */
  137410. constructor(path: Path2);
  137411. /**
  137412. * Gets the cursor point on the path
  137413. * @returns A point on the path cursor at the cursor location
  137414. */
  137415. getPoint(): Vector3;
  137416. /**
  137417. * Moves the cursor ahead by the step amount
  137418. * @param step The amount to move the cursor forward
  137419. * @returns This path cursor
  137420. */
  137421. moveAhead(step?: number): PathCursor;
  137422. /**
  137423. * Moves the cursor behind by the step amount
  137424. * @param step The amount to move the cursor back
  137425. * @returns This path cursor
  137426. */
  137427. moveBack(step?: number): PathCursor;
  137428. /**
  137429. * Moves the cursor by the step amount
  137430. * If the step amount is greater than one, an exception is thrown
  137431. * @param step The amount to move the cursor
  137432. * @returns This path cursor
  137433. */
  137434. move(step: number): PathCursor;
  137435. /**
  137436. * Ensures that the value is limited between zero and one
  137437. * @returns This path cursor
  137438. */
  137439. private ensureLimits;
  137440. /**
  137441. * Runs onchange callbacks on change (used by the animation engine)
  137442. * @returns This path cursor
  137443. */
  137444. private raiseOnChange;
  137445. /**
  137446. * Executes a function on change
  137447. * @param f A path cursor onchange callback
  137448. * @returns This path cursor
  137449. */
  137450. onchange(f: (cursor: PathCursor) => void): PathCursor;
  137451. }
  137452. }
  137453. declare module BABYLON {
  137454. /** @hidden */
  137455. export var blurPixelShader: {
  137456. name: string;
  137457. shader: string;
  137458. };
  137459. }
  137460. declare module BABYLON {
  137461. /** @hidden */
  137462. export var pointCloudVertexDeclaration: {
  137463. name: string;
  137464. shader: string;
  137465. };
  137466. }
  137467. // Mixins
  137468. interface Window {
  137469. mozIndexedDB: IDBFactory;
  137470. webkitIndexedDB: IDBFactory;
  137471. msIndexedDB: IDBFactory;
  137472. webkitURL: typeof URL;
  137473. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  137474. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  137475. WebGLRenderingContext: WebGLRenderingContext;
  137476. MSGesture: MSGesture;
  137477. CANNON: any;
  137478. AudioContext: AudioContext;
  137479. webkitAudioContext: AudioContext;
  137480. PointerEvent: any;
  137481. Math: Math;
  137482. Uint8Array: Uint8ArrayConstructor;
  137483. Float32Array: Float32ArrayConstructor;
  137484. mozURL: typeof URL;
  137485. msURL: typeof URL;
  137486. VRFrameData: any; // WebVR, from specs 1.1
  137487. DracoDecoderModule: any;
  137488. setImmediate(handler: (...args: any[]) => void): number;
  137489. }
  137490. interface HTMLCanvasElement {
  137491. requestPointerLock(): void;
  137492. msRequestPointerLock?(): void;
  137493. mozRequestPointerLock?(): void;
  137494. webkitRequestPointerLock?(): void;
  137495. /** Track wether a record is in progress */
  137496. isRecording: boolean;
  137497. /** Capture Stream method defined by some browsers */
  137498. captureStream(fps?: number): MediaStream;
  137499. }
  137500. interface CanvasRenderingContext2D {
  137501. msImageSmoothingEnabled: boolean;
  137502. }
  137503. interface MouseEvent {
  137504. mozMovementX: number;
  137505. mozMovementY: number;
  137506. webkitMovementX: number;
  137507. webkitMovementY: number;
  137508. msMovementX: number;
  137509. msMovementY: number;
  137510. }
  137511. interface Navigator {
  137512. mozGetVRDevices: (any: any) => any;
  137513. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137514. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137515. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137516. webkitGetGamepads(): Gamepad[];
  137517. msGetGamepads(): Gamepad[];
  137518. webkitGamepads(): Gamepad[];
  137519. }
  137520. interface HTMLVideoElement {
  137521. mozSrcObject: any;
  137522. }
  137523. interface Math {
  137524. fround(x: number): number;
  137525. imul(a: number, b: number): number;
  137526. }
  137527. interface WebGLRenderingContext {
  137528. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  137529. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  137530. vertexAttribDivisor(index: number, divisor: number): void;
  137531. createVertexArray(): any;
  137532. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  137533. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  137534. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  137535. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  137536. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  137537. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  137538. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  137539. // Queries
  137540. createQuery(): WebGLQuery;
  137541. deleteQuery(query: WebGLQuery): void;
  137542. beginQuery(target: number, query: WebGLQuery): void;
  137543. endQuery(target: number): void;
  137544. getQueryParameter(query: WebGLQuery, pname: number): any;
  137545. getQuery(target: number, pname: number): any;
  137546. MAX_SAMPLES: number;
  137547. RGBA8: number;
  137548. READ_FRAMEBUFFER: number;
  137549. DRAW_FRAMEBUFFER: number;
  137550. UNIFORM_BUFFER: number;
  137551. HALF_FLOAT_OES: number;
  137552. RGBA16F: number;
  137553. RGBA32F: number;
  137554. R32F: number;
  137555. RG32F: number;
  137556. RGB32F: number;
  137557. R16F: number;
  137558. RG16F: number;
  137559. RGB16F: number;
  137560. RED: number;
  137561. RG: number;
  137562. R8: number;
  137563. RG8: number;
  137564. UNSIGNED_INT_24_8: number;
  137565. DEPTH24_STENCIL8: number;
  137566. MIN: number;
  137567. MAX: number;
  137568. /* Multiple Render Targets */
  137569. drawBuffers(buffers: number[]): void;
  137570. readBuffer(src: number): void;
  137571. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  137572. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  137573. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  137574. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  137575. // Occlusion Query
  137576. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  137577. ANY_SAMPLES_PASSED: number;
  137578. QUERY_RESULT_AVAILABLE: number;
  137579. QUERY_RESULT: number;
  137580. }
  137581. interface WebGLProgram {
  137582. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  137583. }
  137584. interface EXT_disjoint_timer_query {
  137585. QUERY_COUNTER_BITS_EXT: number;
  137586. TIME_ELAPSED_EXT: number;
  137587. TIMESTAMP_EXT: number;
  137588. GPU_DISJOINT_EXT: number;
  137589. QUERY_RESULT_EXT: number;
  137590. QUERY_RESULT_AVAILABLE_EXT: number;
  137591. queryCounterEXT(query: WebGLQuery, target: number): void;
  137592. createQueryEXT(): WebGLQuery;
  137593. beginQueryEXT(target: number, query: WebGLQuery): void;
  137594. endQueryEXT(target: number): void;
  137595. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  137596. deleteQueryEXT(query: WebGLQuery): void;
  137597. }
  137598. interface WebGLUniformLocation {
  137599. _currentState: any;
  137600. }
  137601. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  137602. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  137603. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  137604. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137605. interface WebGLRenderingContext {
  137606. readonly RASTERIZER_DISCARD: number;
  137607. readonly DEPTH_COMPONENT24: number;
  137608. readonly TEXTURE_3D: number;
  137609. readonly TEXTURE_2D_ARRAY: number;
  137610. readonly TEXTURE_COMPARE_FUNC: number;
  137611. readonly TEXTURE_COMPARE_MODE: number;
  137612. readonly COMPARE_REF_TO_TEXTURE: number;
  137613. readonly TEXTURE_WRAP_R: number;
  137614. readonly HALF_FLOAT: number;
  137615. readonly RGB8: number;
  137616. readonly RED_INTEGER: number;
  137617. readonly RG_INTEGER: number;
  137618. readonly RGB_INTEGER: number;
  137619. readonly RGBA_INTEGER: number;
  137620. readonly R8_SNORM: number;
  137621. readonly RG8_SNORM: number;
  137622. readonly RGB8_SNORM: number;
  137623. readonly RGBA8_SNORM: number;
  137624. readonly R8I: number;
  137625. readonly RG8I: number;
  137626. readonly RGB8I: number;
  137627. readonly RGBA8I: number;
  137628. readonly R8UI: number;
  137629. readonly RG8UI: number;
  137630. readonly RGB8UI: number;
  137631. readonly RGBA8UI: number;
  137632. readonly R16I: number;
  137633. readonly RG16I: number;
  137634. readonly RGB16I: number;
  137635. readonly RGBA16I: number;
  137636. readonly R16UI: number;
  137637. readonly RG16UI: number;
  137638. readonly RGB16UI: number;
  137639. readonly RGBA16UI: number;
  137640. readonly R32I: number;
  137641. readonly RG32I: number;
  137642. readonly RGB32I: number;
  137643. readonly RGBA32I: number;
  137644. readonly R32UI: number;
  137645. readonly RG32UI: number;
  137646. readonly RGB32UI: number;
  137647. readonly RGBA32UI: number;
  137648. readonly RGB10_A2UI: number;
  137649. readonly R11F_G11F_B10F: number;
  137650. readonly RGB9_E5: number;
  137651. readonly RGB10_A2: number;
  137652. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  137653. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  137654. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  137655. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  137656. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  137657. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  137658. 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;
  137659. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  137660. readonly TRANSFORM_FEEDBACK: number;
  137661. readonly INTERLEAVED_ATTRIBS: number;
  137662. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  137663. createTransformFeedback(): WebGLTransformFeedback;
  137664. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  137665. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  137666. beginTransformFeedback(primitiveMode: number): void;
  137667. endTransformFeedback(): void;
  137668. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  137669. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137670. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137671. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137672. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  137673. }
  137674. interface ImageBitmap {
  137675. readonly width: number;
  137676. readonly height: number;
  137677. close(): void;
  137678. }
  137679. interface WebGLQuery extends WebGLObject {
  137680. }
  137681. declare var WebGLQuery: {
  137682. prototype: WebGLQuery;
  137683. new(): WebGLQuery;
  137684. };
  137685. interface WebGLSampler extends WebGLObject {
  137686. }
  137687. declare var WebGLSampler: {
  137688. prototype: WebGLSampler;
  137689. new(): WebGLSampler;
  137690. };
  137691. interface WebGLSync extends WebGLObject {
  137692. }
  137693. declare var WebGLSync: {
  137694. prototype: WebGLSync;
  137695. new(): WebGLSync;
  137696. };
  137697. interface WebGLTransformFeedback extends WebGLObject {
  137698. }
  137699. declare var WebGLTransformFeedback: {
  137700. prototype: WebGLTransformFeedback;
  137701. new(): WebGLTransformFeedback;
  137702. };
  137703. interface WebGLVertexArrayObject extends WebGLObject {
  137704. }
  137705. declare var WebGLVertexArrayObject: {
  137706. prototype: WebGLVertexArrayObject;
  137707. new(): WebGLVertexArrayObject;
  137708. };
  137709. // Type definitions for WebVR API
  137710. // Project: https://w3c.github.io/webvr/
  137711. // Definitions by: six a <https://github.com/lostfictions>
  137712. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137713. interface VRDisplay extends EventTarget {
  137714. /**
  137715. * Dictionary of capabilities describing the VRDisplay.
  137716. */
  137717. readonly capabilities: VRDisplayCapabilities;
  137718. /**
  137719. * z-depth defining the far plane of the eye view frustum
  137720. * enables mapping of values in the render target depth
  137721. * attachment to scene coordinates. Initially set to 10000.0.
  137722. */
  137723. depthFar: number;
  137724. /**
  137725. * z-depth defining the near plane of the eye view frustum
  137726. * enables mapping of values in the render target depth
  137727. * attachment to scene coordinates. Initially set to 0.01.
  137728. */
  137729. depthNear: number;
  137730. /**
  137731. * An identifier for this distinct VRDisplay. Used as an
  137732. * association point in the Gamepad API.
  137733. */
  137734. readonly displayId: number;
  137735. /**
  137736. * A display name, a user-readable name identifying it.
  137737. */
  137738. readonly displayName: string;
  137739. readonly isConnected: boolean;
  137740. readonly isPresenting: boolean;
  137741. /**
  137742. * If this VRDisplay supports room-scale experiences, the optional
  137743. * stage attribute contains details on the room-scale parameters.
  137744. */
  137745. readonly stageParameters: VRStageParameters | null;
  137746. /**
  137747. * Passing the value returned by `requestAnimationFrame` to
  137748. * `cancelAnimationFrame` will unregister the callback.
  137749. * @param handle Define the hanle of the request to cancel
  137750. */
  137751. cancelAnimationFrame(handle: number): void;
  137752. /**
  137753. * Stops presenting to the VRDisplay.
  137754. * @returns a promise to know when it stopped
  137755. */
  137756. exitPresent(): Promise<void>;
  137757. /**
  137758. * Return the current VREyeParameters for the given eye.
  137759. * @param whichEye Define the eye we want the parameter for
  137760. * @returns the eye parameters
  137761. */
  137762. getEyeParameters(whichEye: string): VREyeParameters;
  137763. /**
  137764. * Populates the passed VRFrameData with the information required to render
  137765. * the current frame.
  137766. * @param frameData Define the data structure to populate
  137767. * @returns true if ok otherwise false
  137768. */
  137769. getFrameData(frameData: VRFrameData): boolean;
  137770. /**
  137771. * Get the layers currently being presented.
  137772. * @returns the list of VR layers
  137773. */
  137774. getLayers(): VRLayer[];
  137775. /**
  137776. * Return a VRPose containing the future predicted pose of the VRDisplay
  137777. * when the current frame will be presented. The value returned will not
  137778. * change until JavaScript has returned control to the browser.
  137779. *
  137780. * The VRPose will contain the position, orientation, velocity,
  137781. * and acceleration of each of these properties.
  137782. * @returns the pose object
  137783. */
  137784. getPose(): VRPose;
  137785. /**
  137786. * Return the current instantaneous pose of the VRDisplay, with no
  137787. * prediction applied.
  137788. * @returns the current instantaneous pose
  137789. */
  137790. getImmediatePose(): VRPose;
  137791. /**
  137792. * The callback passed to `requestAnimationFrame` will be called
  137793. * any time a new frame should be rendered. When the VRDisplay is
  137794. * presenting the callback will be called at the native refresh
  137795. * rate of the HMD. When not presenting this function acts
  137796. * identically to how window.requestAnimationFrame acts. Content should
  137797. * make no assumptions of frame rate or vsync behavior as the HMD runs
  137798. * asynchronously from other displays and at differing refresh rates.
  137799. * @param callback Define the eaction to run next frame
  137800. * @returns the request handle it
  137801. */
  137802. requestAnimationFrame(callback: FrameRequestCallback): number;
  137803. /**
  137804. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  137805. * Repeat calls while already presenting will update the VRLayers being displayed.
  137806. * @param layers Define the list of layer to present
  137807. * @returns a promise to know when the request has been fulfilled
  137808. */
  137809. requestPresent(layers: VRLayer[]): Promise<void>;
  137810. /**
  137811. * Reset the pose for this display, treating its current position and
  137812. * orientation as the "origin/zero" values. VRPose.position,
  137813. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  137814. * updated when calling resetPose(). This should be called in only
  137815. * sitting-space experiences.
  137816. */
  137817. resetPose(): void;
  137818. /**
  137819. * The VRLayer provided to the VRDisplay will be captured and presented
  137820. * in the HMD. Calling this function has the same effect on the source
  137821. * canvas as any other operation that uses its source image, and canvases
  137822. * created without preserveDrawingBuffer set to true will be cleared.
  137823. * @param pose Define the pose to submit
  137824. */
  137825. submitFrame(pose?: VRPose): void;
  137826. }
  137827. declare var VRDisplay: {
  137828. prototype: VRDisplay;
  137829. new(): VRDisplay;
  137830. };
  137831. interface VRLayer {
  137832. leftBounds?: number[] | Float32Array | null;
  137833. rightBounds?: number[] | Float32Array | null;
  137834. source?: HTMLCanvasElement | null;
  137835. }
  137836. interface VRDisplayCapabilities {
  137837. readonly canPresent: boolean;
  137838. readonly hasExternalDisplay: boolean;
  137839. readonly hasOrientation: boolean;
  137840. readonly hasPosition: boolean;
  137841. readonly maxLayers: number;
  137842. }
  137843. interface VREyeParameters {
  137844. /** @deprecated */
  137845. readonly fieldOfView: VRFieldOfView;
  137846. readonly offset: Float32Array;
  137847. readonly renderHeight: number;
  137848. readonly renderWidth: number;
  137849. }
  137850. interface VRFieldOfView {
  137851. readonly downDegrees: number;
  137852. readonly leftDegrees: number;
  137853. readonly rightDegrees: number;
  137854. readonly upDegrees: number;
  137855. }
  137856. interface VRFrameData {
  137857. readonly leftProjectionMatrix: Float32Array;
  137858. readonly leftViewMatrix: Float32Array;
  137859. readonly pose: VRPose;
  137860. readonly rightProjectionMatrix: Float32Array;
  137861. readonly rightViewMatrix: Float32Array;
  137862. readonly timestamp: number;
  137863. }
  137864. interface VRPose {
  137865. readonly angularAcceleration: Float32Array | null;
  137866. readonly angularVelocity: Float32Array | null;
  137867. readonly linearAcceleration: Float32Array | null;
  137868. readonly linearVelocity: Float32Array | null;
  137869. readonly orientation: Float32Array | null;
  137870. readonly position: Float32Array | null;
  137871. readonly timestamp: number;
  137872. }
  137873. interface VRStageParameters {
  137874. sittingToStandingTransform?: Float32Array;
  137875. sizeX?: number;
  137876. sizeY?: number;
  137877. }
  137878. interface Navigator {
  137879. getVRDisplays(): Promise<VRDisplay[]>;
  137880. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  137881. }
  137882. interface Window {
  137883. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  137884. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  137885. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  137886. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137887. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137888. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  137889. }
  137890. interface Gamepad {
  137891. readonly displayId: number;
  137892. }
  137893. type XRSessionMode =
  137894. | "inline"
  137895. | "immersive-vr"
  137896. | "immersive-ar";
  137897. type XRReferenceSpaceType =
  137898. | "viewer"
  137899. | "local"
  137900. | "local-floor"
  137901. | "bounded-floor"
  137902. | "unbounded";
  137903. type XREnvironmentBlendMode =
  137904. | "opaque"
  137905. | "additive"
  137906. | "alpha-blend";
  137907. type XRVisibilityState =
  137908. | "visible"
  137909. | "visible-blurred"
  137910. | "hidden";
  137911. type XRHandedness =
  137912. | "none"
  137913. | "left"
  137914. | "right";
  137915. type XRTargetRayMode =
  137916. | "gaze"
  137917. | "tracked-pointer"
  137918. | "screen";
  137919. type XREye =
  137920. | "none"
  137921. | "left"
  137922. | "right";
  137923. interface XRSpace extends EventTarget {
  137924. }
  137925. interface XRRenderState {
  137926. depthNear?: number;
  137927. depthFar?: number;
  137928. inlineVerticalFieldOfView?: number;
  137929. baseLayer?: XRWebGLLayer;
  137930. }
  137931. interface XRInputSource {
  137932. handedness: XRHandedness;
  137933. targetRayMode: XRTargetRayMode;
  137934. targetRaySpace: XRSpace;
  137935. gripSpace: XRSpace | undefined;
  137936. gamepad: Gamepad | undefined;
  137937. profiles: Array<string>;
  137938. }
  137939. interface XRSession extends XRAnchorCreator {
  137940. addEventListener: Function;
  137941. removeEventListener: Function;
  137942. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  137943. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  137944. requestAnimationFrame: Function;
  137945. end(): Promise<void>;
  137946. renderState: XRRenderState;
  137947. inputSources: Array<XRInputSource>;
  137948. // AR hit test
  137949. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  137950. updateWorldTrackingState(options: {
  137951. planeDetectionState?: { enabled: boolean; }
  137952. }): void;
  137953. }
  137954. interface XRReferenceSpace extends XRSpace {
  137955. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  137956. onreset: any;
  137957. }
  137958. type XRPlaneSet = Set<XRPlane>;
  137959. type XRAnchorSet = Set<XRAnchor>;
  137960. interface XRFrame {
  137961. session: XRSession;
  137962. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  137963. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  137964. // Anchors
  137965. trackedAnchors?: XRAnchorSet;
  137966. // Planes
  137967. worldInformation: {
  137968. detectedPlanes?: XRPlaneSet;
  137969. };
  137970. }
  137971. interface XRViewerPose extends XRPose {
  137972. views: Array<XRView>;
  137973. }
  137974. interface XRPose {
  137975. transform: XRRigidTransform;
  137976. emulatedPosition: boolean;
  137977. }
  137978. interface XRWebGLLayerOptions {
  137979. antialias?: boolean;
  137980. depth?: boolean;
  137981. stencil?: boolean;
  137982. alpha?: boolean;
  137983. multiview?: boolean;
  137984. framebufferScaleFactor?: number;
  137985. }
  137986. declare var XRWebGLLayer: {
  137987. prototype: XRWebGLLayer;
  137988. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  137989. };
  137990. interface XRWebGLLayer {
  137991. framebuffer: WebGLFramebuffer;
  137992. framebufferWidth: number;
  137993. framebufferHeight: number;
  137994. getViewport: Function;
  137995. }
  137996. declare class XRRigidTransform {
  137997. constructor(matrix: Float32Array);
  137998. position: DOMPointReadOnly;
  137999. orientation: DOMPointReadOnly;
  138000. matrix: Float32Array;
  138001. inverse: XRRigidTransform;
  138002. }
  138003. interface XRView {
  138004. eye: XREye;
  138005. projectionMatrix: Float32Array;
  138006. transform: XRRigidTransform;
  138007. }
  138008. interface XRInputSourceChangeEvent {
  138009. session: XRSession;
  138010. removed: Array<XRInputSource>;
  138011. added: Array<XRInputSource>;
  138012. }
  138013. interface XRInputSourceEvent extends Event {
  138014. readonly frame: XRFrame;
  138015. readonly inputSource: XRInputSource;
  138016. }
  138017. // Experimental(er) features
  138018. declare class XRRay {
  138019. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  138020. origin: DOMPointReadOnly;
  138021. direction: DOMPointReadOnly;
  138022. matrix: Float32Array;
  138023. }
  138024. interface XRHitResult {
  138025. hitMatrix: Float32Array;
  138026. }
  138027. interface XRAnchor {
  138028. // remove?
  138029. id?: string;
  138030. anchorSpace: XRSpace;
  138031. lastChangedTime: number;
  138032. detach(): void;
  138033. }
  138034. interface XRPlane extends XRAnchorCreator {
  138035. orientation: "Horizontal" | "Vertical";
  138036. planeSpace: XRSpace;
  138037. polygon: Array<DOMPointReadOnly>;
  138038. lastChangedTime: number;
  138039. }
  138040. interface XRAnchorCreator {
  138041. // AR Anchors
  138042. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  138043. }